From 8cc66949420a36939882484b5f2071a643759e14 Mon Sep 17 00:00:00 2001 From: Mario Macias Date: Tue, 21 May 2024 12:43:47 +0200 Subject: [PATCH] Split integration tests (#848) * Split integration tests * fix makefile * rename uploaded logs * fix codecov token --- .github/workflows/pull_request.yml | 3 +- .../pull_request_integration_tests.yml | 3 +- .../pull_request_k8s_integration_tests.yml | 43 +++++++++++++++++++ .github/workflows/pull_request_oats_test.yml | 3 +- Makefile | 12 ++++++ .../k8s/common/k8s_metrics_testfuncs.go | 2 +- .../k8s/daemonset/k8s_daemonset_main_test.go | 2 +- .../daemonset/k8s_daemonset_traces_test.go | 2 +- .../k8s_daemonset_main_test.go | 2 +- .../k8s_daemonset_traces_test.go | 2 +- .../k8s/netolly/k8s_netolly_main_test.go | 2 +- .../netolly/k8s_netolly_network_metrics.go | 2 +- .../k8s_netolly_dropexternal_test.go | 2 +- .../k8s_netolly_prom_main_test.go | 2 +- .../k8s_netolly_prom_main_test.go | 2 +- test/integration/k8s/otel/k8s_main_test.go | 2 +- .../k8s/otel/k8s_otel_metrics_test.go | 2 +- .../k8s/otel/k8s_otel_traces_test.go | 2 +- .../k8s/owners/k8s_daemonset_metadata_test.go | 2 +- .../k8s/owners/k8s_owners_main_test.go | 2 +- .../owners/k8s_statefulset_metadata_test.go | 2 +- .../k8s/prom/k8s_prom_main_test.go | 2 +- test/integration/k8s/prom/k8s_prom_test.go | 2 +- 23 files changed, 79 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/pull_request_k8s_integration_tests.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 541b7bf29..13fdcd9bc 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -32,7 +32,8 @@ jobs: run: make verify cov-exclude-generated - name: Report coverage uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: file: ./testoutput/cover.txt flags: unittests - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pull_request_integration_tests.yml b/.github/workflows/pull_request_integration_tests.yml index bf69f2b8c..9af623dc9 100644 --- a/.github/workflows/pull_request_integration_tests.yml +++ b/.github/workflows/pull_request_integration_tests.yml @@ -36,7 +36,8 @@ jobs: testoutput/kind - name: Report coverage uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: file: ./testoutput/itest-covdata.txt flags: integration-test - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pull_request_k8s_integration_tests.yml b/.github/workflows/pull_request_k8s_integration_tests.yml new file mode 100644 index 000000000..45667e8a6 --- /dev/null +++ b/.github/workflows/pull_request_k8s_integration_tests.yml @@ -0,0 +1,43 @@ +name: Pull request K8s integration tests + +on: + push: + branches: [ 'main', 'release-*' ] + pull_request: + branches: [ 'main', 'release-*' ] + +jobs: + test: + name: test + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.22' ] + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: Clean up disk space + run: | + docker system prune -af + docker volume prune -f + - name: Run integration tests + run: make integration-test-k8s + timeout-minutes: 60 + - name: Upload integration test logs + uses: actions/upload-artifact@v3 + if: always() + with: + name: K8s test Logs + path: | + testoutput/*.log + testoutput/kind + - name: Report coverage + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + file: ./testoutput/itest-covdata.txt + flags: k8s-integration-test diff --git a/.github/workflows/pull_request_oats_test.yml b/.github/workflows/pull_request_oats_test.yml index 4647451dd..a18d92e50 100644 --- a/.github/workflows/pull_request_oats_test.yml +++ b/.github/workflows/pull_request_oats_test.yml @@ -33,7 +33,8 @@ jobs: path: test/oats/*/build/* - name: Report coverage uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: file: ./testoutput/itest-covdata.txt flags: oats-test - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index b2c8d9657..ebbdcc827 100644 --- a/Makefile +++ b/Makefile @@ -231,12 +231,24 @@ run-integration-test: go clean -testcache go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./test/integration/... --tags=integration +.PHONY: run-integration-test-k8s +run-integration-test-k8s: + @echo "### Running integration tests" + go clean -testcache + go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./test/integration/... --tags=integration_k8s + .PHONY: integration-test integration-test: prereqs prepare-integration-test $(MAKE) run-integration-test || (ret=$$?; $(MAKE) cleanup-integration-test && exit $$ret) $(MAKE) itest-coverage-data $(MAKE) cleanup-integration-test +.PHONY: integration-test-k8s +integration-test-k8s: prereqs prepare-integration-test + $(MAKE) run-integration-test-k8s || (ret=$$?; $(MAKE) cleanup-integration-test && exit $$ret) + $(MAKE) itest-coverage-data + $(MAKE) cleanup-integration-test + .PHONY: itest-coverage-data itest-coverage-data: # merge coverage data from all the integration tests diff --git a/test/integration/k8s/common/k8s_metrics_testfuncs.go b/test/integration/k8s/common/k8s_metrics_testfuncs.go index ce40622e2..38400cd17 100644 --- a/test/integration/k8s/common/k8s_metrics_testfuncs.go +++ b/test/integration/k8s/common/k8s_metrics_testfuncs.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package k8s diff --git a/test/integration/k8s/daemonset/k8s_daemonset_main_test.go b/test/integration/k8s/daemonset/k8s_daemonset_main_test.go index 81b249b9d..0328f3f9f 100644 --- a/test/integration/k8s/daemonset/k8s_daemonset_main_test.go +++ b/test/integration/k8s/daemonset/k8s_daemonset_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go b/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go index 08be19f60..ce284be51 100644 --- a/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go +++ b/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/daemonset_python/k8s_daemonset_main_test.go b/test/integration/k8s/daemonset_python/k8s_daemonset_main_test.go index 748403812..bb086cb39 100644 --- a/test/integration/k8s/daemonset_python/k8s_daemonset_main_test.go +++ b/test/integration/k8s/daemonset_python/k8s_daemonset_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/daemonset_python/k8s_daemonset_traces_test.go b/test/integration/k8s/daemonset_python/k8s_daemonset_traces_test.go index 3944ad34d..d0ee6a925 100644 --- a/test/integration/k8s/daemonset_python/k8s_daemonset_traces_test.go +++ b/test/integration/k8s/daemonset_python/k8s_daemonset_traces_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/netolly/k8s_netolly_main_test.go b/test/integration/k8s/netolly/k8s_netolly_main_test.go index d83fcf419..589b632a5 100644 --- a/test/integration/k8s/netolly/k8s_netolly_main_test.go +++ b/test/integration/k8s/netolly/k8s_netolly_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/netolly/k8s_netolly_network_metrics.go b/test/integration/k8s/netolly/k8s_netolly_network_metrics.go index aba33472e..0af0c44d7 100644 --- a/test/integration/k8s/netolly/k8s_netolly_network_metrics.go +++ b/test/integration/k8s/netolly/k8s_netolly_network_metrics.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/netolly_dropexternal/k8s_netolly_dropexternal_test.go b/test/integration/k8s/netolly_dropexternal/k8s_netolly_dropexternal_test.go index 86cb10b54..a959b994b 100644 --- a/test/integration/k8s/netolly_dropexternal/k8s_netolly_dropexternal_test.go +++ b/test/integration/k8s/netolly_dropexternal/k8s_netolly_dropexternal_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/netolly_promexport/k8s_netolly_prom_main_test.go b/test/integration/k8s/netolly_promexport/k8s_netolly_prom_main_test.go index 85edd1438..864e2e782 100644 --- a/test/integration/k8s/netolly_promexport/k8s_netolly_prom_main_test.go +++ b/test/integration/k8s/netolly_promexport/k8s_netolly_prom_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package promtest diff --git a/test/integration/k8s/netolly_sk_promexport/k8s_netolly_prom_main_test.go b/test/integration/k8s/netolly_sk_promexport/k8s_netolly_prom_main_test.go index 719593643..bde8ac22d 100644 --- a/test/integration/k8s/netolly_sk_promexport/k8s_netolly_prom_main_test.go +++ b/test/integration/k8s/netolly_sk_promexport/k8s_netolly_prom_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package promtestsk diff --git a/test/integration/k8s/otel/k8s_main_test.go b/test/integration/k8s/otel/k8s_main_test.go index 7630474e1..a5e01f026 100644 --- a/test/integration/k8s/otel/k8s_main_test.go +++ b/test/integration/k8s/otel/k8s_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/otel/k8s_otel_metrics_test.go b/test/integration/k8s/otel/k8s_otel_metrics_test.go index df3b648c2..7b2f6f1cf 100644 --- a/test/integration/k8s/otel/k8s_otel_metrics_test.go +++ b/test/integration/k8s/otel/k8s_otel_metrics_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/otel/k8s_otel_traces_test.go b/test/integration/k8s/otel/k8s_otel_traces_test.go index 8dbc0f639..8e69519f6 100644 --- a/test/integration/k8s/otel/k8s_otel_traces_test.go +++ b/test/integration/k8s/otel/k8s_otel_traces_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package otel diff --git a/test/integration/k8s/owners/k8s_daemonset_metadata_test.go b/test/integration/k8s/owners/k8s_daemonset_metadata_test.go index c0e81e295..36b10527a 100644 --- a/test/integration/k8s/owners/k8s_daemonset_metadata_test.go +++ b/test/integration/k8s/owners/k8s_daemonset_metadata_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package owners diff --git a/test/integration/k8s/owners/k8s_owners_main_test.go b/test/integration/k8s/owners/k8s_owners_main_test.go index 7689401ea..f783df9c1 100644 --- a/test/integration/k8s/owners/k8s_owners_main_test.go +++ b/test/integration/k8s/owners/k8s_owners_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s // package owners tests the selection and detection of pod ownership metadata, others than deployment: // StatefulSet and DaemonSet diff --git a/test/integration/k8s/owners/k8s_statefulset_metadata_test.go b/test/integration/k8s/owners/k8s_statefulset_metadata_test.go index 3dca3e9dc..1a15502b8 100644 --- a/test/integration/k8s/owners/k8s_statefulset_metadata_test.go +++ b/test/integration/k8s/owners/k8s_statefulset_metadata_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package owners diff --git a/test/integration/k8s/prom/k8s_prom_main_test.go b/test/integration/k8s/prom/k8s_prom_main_test.go index 6d9c5cd36..0ac81dffc 100644 --- a/test/integration/k8s/prom/k8s_prom_main_test.go +++ b/test/integration/k8s/prom/k8s_prom_main_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package prom diff --git a/test/integration/k8s/prom/k8s_prom_test.go b/test/integration/k8s/prom/k8s_prom_test.go index e1c35cda0..aaf87dafb 100644 --- a/test/integration/k8s/prom/k8s_prom_test.go +++ b/test/integration/k8s/prom/k8s_prom_test.go @@ -1,4 +1,4 @@ -//go:build integration +//go:build integration_k8s package prom