Skip to content

Commit

Permalink
Overhaul integration testing (#5679)
Browse files Browse the repository at this point in the history
* Make proper integration folder structure
* Remove old publish script
* Add integration test  GH workflow
* Rework etcd test to use new test framework
* Enable rke2 binary with go coverage option

Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Apr 17, 2024
1 parent a24d751 commit e7a6404
Show file tree
Hide file tree
Showing 10 changed files with 594 additions and 223 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Integration Test Coverage
on:
push:
paths-ignore:
- "**.md"
- "channel.yaml"
- "install.sh"
- "tests/**"
- "!tests/integration**"
- ".github/**"
- "!.github/workflows/integration.yaml"
pull_request:
paths-ignore:
- "**.md"
- "channel.yaml"
- "install.sh"
- "tests/**"
- "!tests/integration**"
- "!tests/e2e**"
- ".github/**"
- "!.github/workflows/integration.yaml"
workflow_dispatch: {}

permissions:
contents: read

jobs:
build:
name: Build RKE2 Images and Binary
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install OS Packages
run: sudo apt-get install -y libarchive-tools
- name: Build RKE2 Binary and Runtime Image
run: |
GOCOVER=true make build-binary
make package-image-runtime
cp ./bin/rke2 ./build/images/rke2-binary
# Can only upload from a single path, so we need to copy the binary to the image directory
- name: Upload RKE2 Binary and Runtime Image
uses: actions/upload-artifact@v4
with:
name: rke2-test-artifacts
path: ./build/images/*
test:
needs: build
name: Integration Tests
runs-on: ubuntu-22.04
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
itest: [etcdsnapshot]
max-parallel: 3
env:
GOCOVERDIR: /tmp/rke2cov
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup Build Directories
run: |
mkdir -p ./bin ./build/images
- name: Download RKE2 Binary and Runtime Image
uses: actions/download-artifact@v4
with:
name: rke2-test-artifacts
path: ./build/images
- name: Setup Binary
run: |
mv ./build/images/rke2-binary ./bin/rke2
chmod +x ./bin/rke2
- name: Run Integration Tests
run: |
mkdir -p $GOCOVERDIR
sudo -E env "PATH=$PATH" go test -v -timeout=45m ./tests/integration/${{ matrix.itest }}/... -run Integration
- name: Generate coverage report
run: go tool covdata textfmt -i $GOCOVERDIR -o ${{ matrix.itest }}.out
- name: Upload Results To Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./${{ matrix.itest }}.out
flags: inttests # optional
verbose: true # optional (default = false)
- name: On Failure, Dump Server Logs
if: ${{ failure() }}
run: cat ./tests/integration/${{ matrix.itest }}/r2log.txt
- name: On Failure, Launch Debug Session
uses: dereknola/action-upterm@main
if: ${{ failure() }}
with:
## If no one connects after 5 minutes, shut down server.
wait-timeout-minutes: 5
limit-access-to-actor: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN zypper install -y systemd-rpm-macros

# Dapper/Drone/CI environment
FROM build AS dapper
ENV DAPPER_ENV GODEBUG REPO TAG DRONE_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ENV DAPPER_ENV GODEBUG GOCOVER REPO TAG DRONE_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,10 @@ build-images: ## Build all images and image tarballs
build-windows-images: ## Build only the Windows images and tarballs (including airgap)
./scripts/build-windows-images

.PHONY: build-image-kubernetes
build-image-kubernetes: ## Build the kubernetes image
./scripts/build-image-kubernetes

.PHONY: build-image-runtime
build-image-runtime: ## Build the runtime image
./scripts/build-image-runtime

.PHONY: publish-image-kubernetes
publish-image-kubernetes: build-image-kubernetes
./scripts/publish-image-kubernetes

.PHONY: publish-image-runtime
publish-image-runtime: build-image-runtime
./scripts/publish-image-runtime
Expand Down Expand Up @@ -136,6 +128,10 @@ package-images: build-images ## Package docker images for airgap environment
package-windows-images: build-windows-images ## Package Windows crane images for airgap environment
./scripts/package-windows-images

.PHONY: package-image-runtime
package-image-runtime: build-image-runtime ## Package runtime image for GH Actions testing
./scripts/package-image-runtime

.PHONY: package-bundle
package-bundle: build-binary ## Package the tarball bundle
./scripts/package-bundle
Expand Down
5 changes: 5 additions & 0 deletions scripts/build-binary
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ else
DEBUG_GO_GCFLAGS='-gcflags=all=-N -l'
fi

if [ -n "${GOCOVER}" ]; then
GO_BUILDTAGS="${GO_BUILDTAGS} cover"
GO_BUILD_FLAGS="${GO_BUILD_FLAGS} -cover"
fi

REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .dirty; fi)
RELEASE=${PROG}.${GOOS}-${GOARCH}

Expand Down
14 changes: 14 additions & 0 deletions scripts/package-image-runtime
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ex

cd $(dirname $0)/..

source ./scripts/version.sh

if [ "${GOARCH}" == "s390x" ] || [ "${GOARCH}" == "arm64" ]; then
exit 0
fi

docker image save \
${REGISTRY}/${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION} | \
zstd -T0 -16 -f --long=25 --no-progress - -o build/images/${PROG}-images.${PLATFORM}.tar.zst
8 changes: 0 additions & 8 deletions scripts/publish-image-kubernetes

This file was deleted.

105 changes: 0 additions & 105 deletions tests/etcd_int_test.go

This file was deleted.

Loading

0 comments on commit e7a6404

Please sign in to comment.