From 6a29a13fe3e7ad63fbc8d54783f2fdd85bca92e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 17 Mar 2021 08:08:53 +0100 Subject: [PATCH 1/2] fix: generate a jUnit file per test suite --- .ci/scripts/build-test.sh | 7 ++----- cli/Makefile | 9 +++++++-- e2e/Makefile | 19 ++++++++++++++++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.ci/scripts/build-test.sh b/.ci/scripts/build-test.sh index 8e66dc27a5..fe2d03157b 100755 --- a/.ci/scripts/build-test.sh +++ b/.ci/scripts/build-test.sh @@ -14,8 +14,5 @@ mkdir -p $(pwd)/outputs go get -v -u gotest.tools/gotestsum -# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output -GOTESTSUM_JUNITFILE="$(pwd)/outputs/TEST-unit-cli.xml" make -C cli install test - -# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output -GOTESTSUM_JUNITFILE="$(pwd)/outputs/TEST-unit-e2e.xml" make -C e2e unit-test +make -C cli install test +make -C e2e unit-test diff --git a/cli/Makefile b/cli/Makefile index 3a6459d56c..c26d063f8d 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -40,6 +40,11 @@ notice: sync-integrations: OP_LOG_LEVEL=${LOG_LEVEL} go run main.go sync integrations --delete +# Prepare junit build context +.PHONY: test-report-setup +test-report-setup: + mkdir -p $(PWD)/outputs + .PHONY: test -test: - gotestsum --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... +test: test-report-setup + gotestsum --junitfile "$(PWD)/outputs/TEST-unit-cli.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... diff --git a/e2e/Makefile b/e2e/Makefile index 8c8ef53bb3..d3333a1e08 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -101,9 +101,22 @@ notice: -depsOut "" .PHONY: unit-test -unit-test: - gotestsum --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... - cd _suites && gotestsum --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... +unit-test: unit-test-report-setup unit-test-e2e unit-test-suite-fleet unit-test-suite-helm unit-test-suite-metricbeat + +# Prepare junit build context +.PHONY: unit-test-report-setup +unit-test-report-setup: + mkdir -p $(PWD)/outputs + +# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output +.PHONY: unit-test-e2e +unit-test-e2e: + gotestsum --junitfile "$(PWD)/outputs/TEST-unit-e2e.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... + +# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output +.PHONY: unit-test-suite-% +unit-test-suite-%: + cd _suites/$* && gotestsum --junitfile "$(PWD)/outputs/TEST-unit-e2e-$*.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... ## Test examples From 6df47ecf36b0b94c4788037cf41ff52f530882c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 17 Mar 2021 09:47:45 +0100 Subject: [PATCH 2/2] chore: move reports setup goal to a common Makefile --- cli/Makefile | 7 ++----- commons.mk | 4 ++++ e2e/Makefile | 9 +++------ 3 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 commons.mk diff --git a/cli/Makefile b/cli/Makefile index c26d063f8d..dfdb5eab0f 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -1,6 +1,8 @@ # Get current directory of a Makefile: https://stackoverflow.com/a/23324703 ROOT_DIR:=$(CURDIR) +include ../commons.mk + TEST_TIMEOUT?=5m GO_IMAGE?='golang' @@ -40,11 +42,6 @@ notice: sync-integrations: OP_LOG_LEVEL=${LOG_LEVEL} go run main.go sync integrations --delete -# Prepare junit build context -.PHONY: test-report-setup -test-report-setup: - mkdir -p $(PWD)/outputs - .PHONY: test test: test-report-setup gotestsum --junitfile "$(PWD)/outputs/TEST-unit-cli.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./... diff --git a/commons.mk b/commons.mk new file mode 100644 index 0000000000..80667e0a93 --- /dev/null +++ b/commons.mk @@ -0,0 +1,4 @@ +# Prepare junit build context +.PHONY: test-report-setup +test-report-setup: + mkdir -p $(PWD)/outputs diff --git a/e2e/Makefile b/e2e/Makefile index d3333a1e08..8b1762cc01 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -1,3 +1,5 @@ +include ../commons.mk + SUITE?=metricbeat TAGS?= DEVELOPER_MODE?=false @@ -101,12 +103,7 @@ notice: -depsOut "" .PHONY: unit-test -unit-test: unit-test-report-setup unit-test-e2e unit-test-suite-fleet unit-test-suite-helm unit-test-suite-metricbeat - -# Prepare junit build context -.PHONY: unit-test-report-setup -unit-test-report-setup: - mkdir -p $(PWD)/outputs +unit-test: test-report-setup unit-test-e2e unit-test-suite-fleet unit-test-suite-helm unit-test-suite-metricbeat # See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output .PHONY: unit-test-e2e