Skip to content

Commit

Permalink
Consolidate docker tests into 2D matrix
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Feb 3, 2025
1 parent 9045aed commit cd3e443
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 53 deletions.
72 changes: 19 additions & 53 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
path: ./dist/artifacts/*.test
compression-level: 9
retention-days: 1
# For upgrade and skew tests, we need to know the branch name this run is based off.
# For upgrade and skew tests, we need to know the channel this run is based off.
# Since this is predetermined, we can run this step before the actual test job, saving time.
- name: Determine channel
id: channel_step
Expand All @@ -175,34 +175,45 @@ jobs:
fi
docker-go:
needs: [build, build-go-tests]
name: Docker AMD64
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [build, build-arm64, build-go-tests]
name: Docker
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
dtest: [basics, bootstraptoken, cacerts, etcd, lazypull, skew, snapshotrestore, upgrade]
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
env:
CHANNEL: ${{ needs.build-go-tests.outputs.channel }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Download K3s image"
- name: "Download K3s image (amd64)"
if: ${{ matrix.arch == 'amd64' }}
uses: actions/download-artifact@v4
with:
name: k3s
path: ./dist/artifacts
- name: "Download K3s image (arm64)"
if: ${{ matrix.arch == 'arm64' }}
uses: actions/download-artifact@v4
with:
name: k3s-arm64
path: ./dist/artifacts
- name: Load and set K3s image
run: |
if [ ${{ matrix.arch }} = "arm64" ]; then
mv ./dist/artifacts/k3s-arm64 ./dist/artifacts/k3s
fi
chmod +x ./dist/artifacts/k3s
docker image load -i ./dist/artifacts/k3s-image.tar
IMAGE_TAG=$(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep 'rancher/k3s')
echo "K3S_IMAGE=$IMAGE_TAG" >> $GITHUB_ENV
- name: Download Go Tests
uses: actions/download-artifact@v4
with:
name: docker-go-tests-amd64
name: docker-go-tests-${{ matrix.arch }}
path: ./dist/artifacts
- name: Run ${{ matrix.dtest }} Test
# Put the compiled test binary back in the same place as the test source
Expand All @@ -216,49 +227,4 @@ jobs:
./${{ matrix.dtest }}.test -ci
else
./${{ matrix.dtest }}.test -k3sImage=$K3S_IMAGE
fi
docker-go-arm64:
needs: [build-arm64, build-go-tests]
name: Docker ARM64
runs-on: ubuntu-24.04-arm
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
dtest: [basics, bootstraptoken, cacerts, etcd ]
env:
BRANCH_NAME: ${{ needs.build-go-tests.outputs.branch_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Download K3s image"
uses: actions/download-artifact@v4
with:
name: k3s-arm64
path: ./dist/artifacts
- name: Load and set K3s image
run: |
mv ./dist/artifacts/k3s-arm64 ./dist/artifacts/k3s
chmod +x ./dist/artifacts/k3s
docker image load -i ./dist/artifacts/k3s-image.tar
IMAGE_TAG=$(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep 'rancher/k3s')
echo "K3S_IMAGE=$IMAGE_TAG" >> $GITHUB_ENV
- name: Download Go Tests
uses: actions/download-artifact@v4
with:
name: docker-go-tests-arm64
path: ./dist/artifacts
- name: Run ${{ matrix.dtest }} Test
# Put the compiled test binary back in the same place as the test source
run: |
chmod +x ./dist/artifacts/${{ matrix.dtest }}.test
mv ./dist/artifacts/${{ matrix.dtest }}.test ./tests/docker/${{ matrix.dtest }}/
cd ./tests/docker/${{ matrix.dtest }}
./${{ matrix.dtest }}.test -k3sImage=$K3S_IMAGE
- name: On Failure, Launch Debug Session
uses: dereknola/[email protected]
if: ${{ failure() }}
with:
## If no one connects after 5 minutes, shut down server.
wait-timeout-minutes: 5
fi
1 change: 1 addition & 0 deletions tests/docker/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ var _ = Describe("Upgrade Tests", Ordered, func() {
Expect(err).NotTo(HaveOccurred())
cVersion := strings.Split(*k3sImage, ":")[1]
cVersion = strings.Replace(cVersion, "-amd64", "", 1)
cVersion = strings.Replace(cVersion, "-arm64", "", 1)
cVersion = strings.Replace(cVersion, "-", "+", 1)
Expect(out).To(ContainSubstring(cVersion))
}
Expand Down

0 comments on commit cd3e443

Please sign in to comment.