Skip to content

Commit

Permalink
ci: fix macos docker tests
Browse files Browse the repository at this point in the history
There were a lot of problems related with docker runtime on macOS, so
the tests on it always fail.

After the patch `colima` (container runtime for macos) was added to CI
pipeline.

Closes #931
  • Loading branch information
themilchenko committed Oct 2, 2024
1 parent 07addcb commit fc7126e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 28 deletions.
79 changes: 55 additions & 24 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:

- name: Install dependencies
run: |
brew install --overwrite go mage wget node
brew install --overwrite go mage wget node docker colima docker-credential-helper
pip3 install -r test/requirements.txt
- name: Install etcd
Expand All @@ -176,26 +176,56 @@ jobs:
TT_CLI_BUILD_SSL: 'static'
run: mage build

- name: Install tarantool
run: |
./tt init
./tt install tarantool 3.0.2
# Delete the tt config so that it does not affect the test environment.
rm -f tt.yaml
- name: Add Tarantool to Path
run: |
echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
- name: Set Tarantool include directory to the environment
run: |
echo "TT_CLI_TARANTOOL_PREFIX=${GITHUB_WORKSPACE}/include/" >> $GITHUB_ENV
- name: Run unit tests
run: mage unitfull
# - name: Install tarantool
# run: |
# ./tt init
# ./tt install tarantool 3.0.2
# # Delete the tt config so that it does not affect the test environment.
# rm -f tt.yaml
#
# - name: Add Tarantool to Path
# run: |
# echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
#
# - name: Set Tarantool include directory to the environment
# run: |
# echo "TT_CLI_TARANTOOL_PREFIX=${GITHUB_WORKSPACE}/include/" >> $GITHUB_ENV

# - name: Stop colima
# run: |
# pkill -SIGINT -f $(which colima) || true
# rm -rf ~/.colima

# - name: Edit permissions
# run: |
# chmod -R 777 /private/var/folders
# chown -R $(whoami) /private/var/folders

# - name: Start and configure colima
# run: |
# colima start --vm-type vz --mount-type virtiofs --mount=/private/var/folders:w,/var/folders:w --network-address
#
# echo "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock" >> $GITHUB_ENV
# echo "TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')" >> $GITHUB_ENV
# echo "DOCKER_HOST=unix:///${HOME}/.colima/default/docker.sock" >> $GITHUB_ENV
- name: Set up Docker
uses: docker/setup-buildx-action@v1

- name: Check docker
run: docker run --rm hello-world

# - name: Check permissions
# run: |
# chmod -R 777 ${HOME}/.colima
# ls -la ${HOME}/.colima/docker.sock

# - name: Run unit tests
# run: mage unitfull

- name: Integration tests
run: mage integrationfull
# run: mage integrationfull
run: |
python3 -m pytest test/integration/pack/test_pack.py::test_pack_deb -s
# Etcd can be still running after integration tests when:
# 1. pytest recieve SIGALRM (can be caused by pytest-timeout plugin)
Expand All @@ -207,11 +237,12 @@ jobs:
ETCD_TT_BIN=${ETCD_PATH}etcd;
pkill -SIGINT -f ${ETCD_TT_BIN} || true
- name: Kill tarantool, if it was left
if: always()
run: |
TARANTOOL_BIN=${GITHUB_WORKSPACE}/bin/tarantool;
pkill -SIGINT -f ${TARANTOOL_BIN} || true
# - name: Kill colima
# if: always()
# run: |
# colima delete -f
# colima prune -a
# rm -rf ~/.colima

# ee suffix means that the job runs ee integration tests.
full-ci-macOS-ee:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:

- name: Install dependencies
run: |
brew install --overwrite go mage node
brew install --overwrite go mage node docker colima
pip3 install -r test/requirements.txt
- name: Install etcd
Expand Down Expand Up @@ -190,6 +190,9 @@ jobs:
- name: Unit tests
run: mage unit

- name: Start colima and patch mount options
run: colima start --vm-type vz --mount /private/var/folders:w

- name: Run integration tests
run: mage integration

Expand All @@ -202,3 +205,7 @@ jobs:
run: |
ETCD_TT_BIN=${ETCD_PATH}etcd;
pkill -SIGINT -f ${ETCD_TT_BIN} || true
- name: Kill colima
if: always()
run: colima delete
9 changes: 6 additions & 3 deletions test/integration/pack/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,12 +1113,15 @@ def test_pack_deb(tt_cmd, tmp_path):
unpacked_pkg_dir = os.path.join(tmp_path, 'unpacked')
os.mkdir(unpacked_pkg_dir)

rc, output = run_command_and_get_output(['docker', 'run', '--rm', '-v',
'{0}:/usr/src/'.format(base_dir),
rc, output = run_command_and_get_output(['docker', 'run', '--rm', '--tmpfs', '/tmp:size=512',
'-v', '{0}:/usr/src/'.format(base_dir),
'-v', '{0}:/tmp/unpack'.format(unpacked_pkg_dir),
'-w', '/usr/src',
'jrei/systemd-ubuntu',
'/bin/bash', '-c',
'chmod 777 /usr/src/ -R && chmod 777 /tmp/unpack -R && '
'chown -R {1}:{2} /tmp/unpack && '
'chown -R {1}:{2} /usr/src/ && '
'/bin/dpkg -i {0} && '
'ls /usr/share/tarantool/bundle1 '
'&& systemctl list-unit-files | grep app'
Expand All @@ -1128,7 +1131,7 @@ def test_pack_deb(tt_cmd, tmp_path):
'&& id tarantool '
' && stat -c "%U:%G" /var/log/tarantool '
'/var/lib/tarantool /var/run/tarantool '
' && dpkg -x {0} /tmp/unpack '
' && dpkg -x {0} /tmp/unpack'
' && chown {1}:{2} /tmp/unpack -R'.
format(package_file_name, os.getuid(), os.getgid())
])
Expand Down

0 comments on commit fc7126e

Please sign in to comment.