Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

fix: generate a jUnit file per test suite (#907) backport for 7.x #908

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .ci/scripts/build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions cli/Makefile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -41,5 +43,5 @@ sync-integrations:
OP_LOG_LEVEL=${LOG_LEVEL} go run main.go sync integrations --delete

.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) ./...
4 changes: 4 additions & 0 deletions commons.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Prepare junit build context
.PHONY: test-report-setup
test-report-setup:
mkdir -p $(PWD)/outputs
16 changes: 13 additions & 3 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../commons.mk

SUITE?=metricbeat
TAGS?=
DEVELOPER_MODE?=false
Expand Down Expand Up @@ -101,9 +103,17 @@ 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: 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
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

Expand Down