From fa53f1f03feec87ff157182c21b6708edae7aace Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Wed, 6 Mar 2024 14:18:04 -0800 Subject: [PATCH 1/3] Run docker tests in E2E GH Action Build image with new input option Run most of the basic docker tests in E2E Signed-off-by: Derek Nola --- .github/workflows/build-k3s.yaml | 10 ++++++++ .github/workflows/e2e.yaml | 37 ++++++++++++++++++++++++++---- .github/workflows/integration.yaml | 6 ++--- scripts/test | 31 ++++++++++++++----------- 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-k3s.yaml b/.github/workflows/build-k3s.yaml index 6f262c0230db..10ca581f5434 100644 --- a/.github/workflows/build-k3s.yaml +++ b/.github/workflows/build-k3s.yaml @@ -7,6 +7,10 @@ on: type: boolean required: false default: false + upload-image: + type: boolean + required: false + default: false permissions: contents: read @@ -23,6 +27,9 @@ jobs: run: | DOCKER_BUILDKIT=1 SKIP_IMAGE=1 SKIP_AIRGAP=1 SKIP_VALIDATE=1 GOCOVER=1 make sha256sum dist/artifacts/k3s | sed 's|dist/artifacts/||' > dist/artifacts/k3s.sha256sum + - name: Build K3s image + if: inputs.upload-image == true + run: make package-image - name: bundle repo if: inputs.upload-repo == true run: | @@ -34,6 +41,9 @@ jobs: with: name: k3s-repo.tar.gz path: k3s-repo.tar.gz + - name: "Save K3s image" + if: inputs.upload-image == true + run: docker image save rancher/k3s -o ./dist/artifacts/k3s-image.tar - name: "Upload K3s binary" if: inputs.upload-repo == false uses: actions/upload-artifact@v4 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index f024c34dbd58..97c667c1ff72 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -26,8 +26,10 @@ permissions: jobs: build: uses: ./.github/workflows/build-k3s.yaml - test: - name: "E2E Test" + with: + upload-image: true + e2e: + name: "E2E Tests" needs: build runs-on: ubuntu-latest timeout-minutes: 40 @@ -64,7 +66,7 @@ jobs: name: k3s path: ./dist/artifacts - - name: Run E2E Tests + - name: Run ${{ matrix.etest }} Test env: E2E_GOCOVER: "true" run: | @@ -83,4 +85,31 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} files: tests/e2e/${{ matrix.etest }}/coverage.out flags: e2etests # optional - verbose: true # optional (default = false) \ No newline at end of file + verbose: true # optional (default = false) + docker: + needs: build + name: Docker Tests + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + dtest: [basics, bootstraptoken, cacerts, lazypull, upgrade] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: "Download k3s image" + uses: actions/download-artifact@v4 + with: + name: k3s + path: ./dist/artifacts + - name: Load k3s image + run: docker image load -i ./dist/artifacts/k3s-image.tar + - name: Run ${{ matrix.dtest }} Test + run: | + chmod +x ./dist/artifacts/k3s + . ./tests/docker/test-helpers + . ./tests/docker/test-run-${{ matrix.dtest }} + echo "Did test-run-${{ matrix.dtest }} pass $?" \ No newline at end of file diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 0868873e87a0..2cde5fc0a9c1 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -30,10 +30,10 @@ env: jobs: build: uses: ./.github/workflows/build-k3s.yaml - test: + itest: needs: build name: Integration Tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 45 strategy: fail-fast: false @@ -71,4 +71,4 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} files: ./${{ matrix.itest }}.out flags: inttests # optional - verbose: true # optional (default = false) + verbose: true # optional (default = false) \ No newline at end of file diff --git a/scripts/test b/scripts/test index b6b042fd32c8..684e1398003e 100755 --- a/scripts/test +++ b/scripts/test @@ -20,9 +20,24 @@ mkdir -p $artifacts docker ps # --- +# Only run basic tests on non amd64 archs, we use GitHub Actions for amd64 +if [ "$ARCH" != 'amd64' ]; then -. ./tests/docker/test-run-basics -echo "Did test-run-basics $?" + . ./tests/docker/test-run-basics + echo "Did test-run-basics $?" + + . ./tests/docker/test-run-cacerts + echo "Did test-run-cacerts $?" + + . ./tests/docker/test-run-bootstraptoken + echo "Did test-run-bootstraptoken $?" + + . ./tests/docker/test-run-upgrade + echo "Did test-run-upgrade $?" + + . ./tests/docker/test-run-lazypull + echo "Did test-run-lazypull $?" +fi . ./tests/docker/test-run-compat echo "Did test-run-compat $?" @@ -30,21 +45,9 @@ echo "Did test-run-compat $?" . ./tests/docker/test-run-hardened echo "Did test-run-hardened $?" -. ./tests/docker/test-run-cacerts -echo "Did test-run-cacerts $?" - -. ./tests/docker/test-run-bootstraptoken -echo "Did test-run-bootstraptoken $?" - -. ./tests/docker/test-run-upgrade -echo "Did test-run-upgrade $?" - . ./tests/docker/test-run-etcd echo "Did test-run-etcd $?" -. ./tests/docker/test-run-lazypull -echo "Did test-run-lazypull $?" - # --- [ "$ARCH" != 'amd64' ] && \ From 5508bb9d7b0b10fd97282e76d0769f4040707b2b Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Thu, 7 Mar 2024 11:00:44 -0800 Subject: [PATCH 2/3] Fix e2e vagrant cacheing Signed-off-by: Derek Nola --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 97c667c1ff72..9c4767c9df57 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -51,7 +51,7 @@ jobs: with: path: | ~/.vagrant.d/boxes - key: vagrant-box-${{ matrix.vm }} + key: vagrant-box-ubuntu-2204 - name: "Vagrant Plugin(s)" run: vagrant plugin install vagrant-k3s vagrant-reload vagrant-scp From 074250df2813b96f64c407cf92b18fe18fdeec5d Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Thu, 7 Mar 2024 11:37:11 -0800 Subject: [PATCH 3/3] Fix flaky check in btrfs test Signed-off-by: Derek Nola --- tests/e2e/btrfs/btrfs_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/btrfs/btrfs_test.go b/tests/e2e/btrfs/btrfs_test.go index 4311dd65bc45..01bdb3384bed 100644 --- a/tests/e2e/btrfs/btrfs_test.go +++ b/tests/e2e/btrfs/btrfs_test.go @@ -78,8 +78,8 @@ var _ = Describe("Verify that btrfs based servers work", Ordered, func() { cmd := "btrfs subvolume list /var/lib/rancher/k3s/agent/containerd/io.containerd.snapshotter.v1.btrfs" res, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred()) - Expect(res).To(ContainSubstring("agent/containerd/io.containerd.snapshotter.v1.btrfs/active/2")) - Expect(res).To(ContainSubstring("agent/containerd/io.containerd.snapshotter.v1.btrfs/snapshots/3")) + Expect(res).To(MatchRegexp("agent/containerd/io.containerd.snapshotter.v1.btrfs/active/\\d+")) + Expect(res).To(MatchRegexp("agent/containerd/io.containerd.snapshotter.v1.btrfs/snapshots/\\d+")) }) }) })