From 73ccdb005ba3d49ef09ddffa967fafe45c0d098e Mon Sep 17 00:00:00 2001 From: Mohamed Mahmoud Date: Wed, 29 May 2024 14:38:38 -0400 Subject: [PATCH] add k8s intg test to pull pr workflow Signed-off-by: Mohamed Mahmoud --- .github/workflows/pull_request.yml | 62 ++++++++++++++++++++++++++++++ test/integration/suite_test.go | 20 ++-------- 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 376b2a406..3c7ed2155 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -37,3 +37,65 @@ jobs: fail_ci_if_error: true verbose: true + kubernetes-integration-tests: + needs: [ build-lint-test ] + runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.21'] + env: + BPFMAN_AGENT_IMG: quay.io/bpfman/bpfman-agent:int-test + BPFMAN_OPERATOR_IMG: quay.io/bpfman/bpfman-operator:int-test + XDP_PASS_PRIVATE_IMAGE_CREDS: ${{ secrets.XDP_PASS_PRIVATE_IMAGE_CREDS }} + steps: + - name: Check disk space + run: df -h + + - name: Free up space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo rm -rf /usr/local/lib/android + + - name: Check disk space again + run: df -h + + - name: set up go 1.x + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + + - name: cache go modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-build-codegen- + - name: checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + ## TODO(astoycos) Currently this is just done to ensure we have coverage + ## on all image builds. Ultimately we should be running the integration + ## tests with these locally built bytecode images. + - name: build images + run: make build-images + + - name: run integration tests + run: make test-integration + + - name: Check disk space + run: df -h + + ## Upload diagnostics if integration test step failed. + - name: upload diagnostics + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: kubernetes-integration-test-diag + path: /tmp/ktf-diag* + if-no-files-found: ignore diff --git a/test/integration/suite_test.go b/test/integration/suite_test.go index b935ff1e2..1943a3d02 100644 --- a/test/integration/suite_test.go +++ b/test/integration/suite_test.go @@ -30,12 +30,8 @@ var ( // These images should already be built on the node so they can // be loaded into kind. - bpfmanImage = os.Getenv("BPFMAN_IMG") bpfmanAgentImage = os.Getenv("BPFMAN_AGENT_IMG") bpfmanOperatorImage = os.Getenv("BPFMAN_OPERATOR_IMG") - tcExampleUsImage = "quay.io/bpfman-userspace/go-tc-counter:latest" - xdpExampleUsImage = "quay.io/bpfman-userspace/go-xdp-counter:latest" - tpExampleUsImage = "quay.io/bpfman-userspace/go-tracepoint-counter:latest" existingCluster = os.Getenv("USE_EXISTING_KIND_CLUSTER") keepTestCluster = func() bool { return os.Getenv("TEST_KEEP_CLUSTER") == "true" || existingCluster != "" }() @@ -50,11 +46,11 @@ const ( ) func TestMain(m *testing.M) { - // check that we have the bpfman, bpfman-agent, and bpfman-operator images to use for the tests. + // check that we have the bpfman-agent, and bpfman-operator images to use for the tests. // generally the runner of the tests should have built these from the latest // changes prior to the tests and fed them to the test suite. - if bpfmanImage == "" || bpfmanAgentImage == "" || bpfmanOperatorImage == "" { - exitOnErr(fmt.Errorf("BPFMAN_IMG, BPFMAN_AGENT_IMG, and BPFMAN_OPERATOR_IMG must be provided")) + if bpfmanAgentImage == "" || bpfmanOperatorImage == "" { + exitOnErr(fmt.Errorf("BPFMAN_AGENT_IMG, and BPFMAN_OPERATOR_IMG must be provided")) } ctx, cancel = context.WithCancel(context.Background()) @@ -62,18 +58,10 @@ func TestMain(m *testing.M) { // to use the provided bpfman, bpfman-agent, and bpfman-operator images we will need to add // them as images to load in the test cluster via an addon. - loadImages, err := loadimage.NewBuilder().WithImage(bpfmanImage) - exitOnErr(err) - loadImages, err = loadImages.WithImage(bpfmanAgentImage) + loadImages, err := loadimage.NewBuilder().WithImage(bpfmanAgentImage) exitOnErr(err) loadImages, err = loadImages.WithImage(bpfmanOperatorImage) exitOnErr(err) - loadImages, err = loadImages.WithImage(tcExampleUsImage) - exitOnErr(err) - loadImages, err = loadImages.WithImage(xdpExampleUsImage) - exitOnErr(err) - loadImages, err = loadImages.WithImage(tpExampleUsImage) - exitOnErr(err) if existingCluster != "" { fmt.Printf("INFO: existing kind cluster %s was provided\n", existingCluster)