From 7d17e08396d73e3d146f185c7d44165bb571b791 Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Fri, 19 Jan 2024 15:57:17 +0000 Subject: [PATCH] add docker-in-docker e2e test Signed-off-by: Jorge Prendes --- .github/workflows/e2e.yaml | 24 ++++++++++++++++++++++++ justfile | 3 +++ tests/dind/daemon.json | 7 +++++++ tests/dind/run.sh | 20 ++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 tests/dind/daemon.json create mode 100755 tests/dind/run.sh diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index e732a2932..fb2f3f628 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -182,3 +182,27 @@ jobs: run: chmod +x ./youki - name: Run tests run: just test-rootless-podman + + docker-in-docker: + runs-on: ${{ matrix.os }} + needs: [youki-build] + timeout-minutes: 5 + strategy: + matrix: + # ubuntu 20.04 has cgroups-v1 + # ubuntu 22.04 has cgroups-v2 + os: [ "ubuntu-22.04", "ubuntu-20.04" ] + steps: + - uses: actions/checkout@v3 + - name: Install just + uses: taiki-e/install-action@just + - name: Download youki binary + uses: actions/download-artifact@v3 + with: + name: youki-x86_64-musl + - name: Add the permission to run + run: chmod +x ./youki + - name: Run tests + run: just test-dind + + diff --git a/justfile b/justfile index 59ebf1b90..853a0cf1b 100644 --- a/justfile +++ b/justfile @@ -65,6 +65,9 @@ validate-contest-runc: contest test-rootless-podman: {{ cwd }}/tests/rootless-tests/run.sh {{ cwd }}/youki +# test docker-in-docker works with youki +test-dind: + {{ cwd }}/tests/dind/run.sh # run containerd integration tests containerd-test: youki-dev diff --git a/tests/dind/daemon.json b/tests/dind/daemon.json new file mode 100644 index 000000000..a1cdbedd1 --- /dev/null +++ b/tests/dind/daemon.json @@ -0,0 +1,7 @@ +{ + "runtimes": { + "youki": { + "path": "/usr/bin/youki" + } + } +} \ No newline at end of file diff --git a/tests/dind/run.sh b/tests/dind/run.sh new file mode 100755 index 000000000..0aced7203 --- /dev/null +++ b/tests/dind/run.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +ROOT=$(git rev-parse --show-toplevel) + +docker run --privileged -dq \ + --name youki-test-dind \ + -v $ROOT/youki:/usr/bin/youki \ + -v $ROOT/tests/dind/daemon.json:/etc/docker/daemon.json \ + docker:dind > /dev/null + +trap "docker rm -f youki-test-dind > /dev/null" EXIT + +# wait for docker to start +timeout 30s \ + grep -q -m1 "/var/run/docker.sock" \ + <(docker logs -f youki-test-dind 2>&1) + +docker exec -i youki-test-dind \ + docker run -q --runtime=youki hello-world