Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Subset of Docker tests in GitHub Actions #9698

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build-k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
type: boolean
required: false
default: false
upload-image:
type: boolean
required: false
default: false

permissions:
contents: read
Expand All @@ -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: |
Expand All @@ -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
Expand Down
39 changes: 34 additions & 5 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,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

Expand All @@ -64,7 +66,7 @@ jobs:
name: k3s
path: ./dist/artifacts

- name: Run E2E Tests
- name: Run ${{ matrix.etest }} Test
env:
E2E_GOCOVER: "true"
run: |
Expand All @@ -83,4 +85,31 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
files: tests/e2e/${{ matrix.etest }}/coverage.out
flags: e2etests # optional
verbose: true # optional (default = false)
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 $?"
6 changes: 3 additions & 3 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ env:
jobs:
build:
uses: ./.github/workflows/build-k3s.yaml
test:
itest:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the significance of the 'i'?

Copy link
Member

@brandond brandond Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short for integration?

jobs:
  itest:
    name: Integration Tests

The job key has no external significance, other than being able reference it as a dependency in the needs section of other jobs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. This tag is necessary for the structure but ultimately irrelevant because there are no further jobs in this workflow. I just kept seeing test over and over in the workflows, and I want to make it something slightly more descriptive.

needs: build
name: Integration Tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
Expand Down Expand Up @@ -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)
31 changes: 17 additions & 14 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,34 @@ 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 $?"

. ./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' ] && \
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/btrfs/btrfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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+"))
})
})
})
Expand Down
Loading