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 1, 2024
1 parent 07addcb commit 3c5d56a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
35 changes: 28 additions & 7 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 @@ -191,11 +191,31 @@ jobs:
run: |
echo "TT_CLI_TARANTOOL_PREFIX=${GITHUB_WORKSPACE}/include/" >> $GITHUB_ENV
- name: Run unit tests
run: mage unitfull
- name: Check docker
run: docker run --rm hello-world

- name: Start and configure colima
run: |
colima delete
colima prune -a
chmod 666 ${HOME}/.colima/default/docker.sock
docker context use colima
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: Check permissions
run: 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 +227,12 @@ jobs:
ETCD_TT_BIN=${ETCD_PATH}etcd;
pkill -SIGINT -f ${ETCD_TT_BIN} || true
- name: Kill tarantool, if it was left
- name: Kill colima
if: always()
run: |
TARANTOOL_BIN=${GITHUB_WORKSPACE}/bin/tarantool;
pkill -SIGINT -f ${TARANTOOL_BIN} || true
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
6 changes: 3 additions & 3 deletions test/integration/pack/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ 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', "--privileged", "--user=root",
'-v', '{0}:/usr/src/'.format(base_dir),
'-v', '{0}:/tmp/unpack'.format(unpacked_pkg_dir),
'-w', '/usr/src',
'jrei/systemd-ubuntu',
Expand All @@ -1128,7 +1128,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 3c5d56a

Please sign in to comment.