Skip to content

Commit

Permalink
Generate xUnit compatible test results for unit and integration tests (
Browse files Browse the repository at this point in the history
…elastic#1724)

* Add xUnit compatible output for unit and integration tests

* Add example of output to test on Jenkins

* Create integration-tests.xml

* Update make target for CI

* Add xUnit compatible test reports to PR job

* Revert "Create integration-tests.xml"

This reverts commit 313d8a6.

* Revert "Add example of output to test on Jenkins"

This reverts commit bdd7664.
  • Loading branch information
artemnikitin authored and pebrc committed Sep 13, 2019
1 parent c97d82c commit 3f55e34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,19 @@ clean:
unit: clean
go test ./pkg/... ./cmd/... -coverprofile cover.out

unit_xml: clean
go test --json ./pkg/... ./cmd/... -coverprofile cover.out > unit-tests.json
gotestsum --junitfile unit-tests.xml --raw-command cat unit-tests.json

integration: GO_TAGS += integration
integration: clean generate
go test -tags='$(GO_TAGS)' ./pkg/... ./cmd/... -coverprofile cover.out

integration_xml: GO_TAGS += integration
integration_xml: clean generate
go test -tags='$(GO_TAGS)' --json ./pkg/... ./cmd/... -coverprofile cover.out > integration-tests.json
gotestsum --junitfile integration-tests.xml --raw-command cat integration-tests.json

check-fmt:
ifneq ($(shell goimports -l pkg cmd),)
$(error Invalid go formatting. Please run `make fmt`)
Expand Down Expand Up @@ -338,7 +347,7 @@ e2e-local:
## -- Continuous integration -- ##
##########################################

ci: dep-vendor-only check-fmt lint generate check-local-changes unit integration e2e-compile docker-build
ci: dep-vendor-only check-fmt lint generate check-local-changes unit_xml integration_xml e2e-compile docker-build

# Run e2e tests in a dedicated cluster.
ci-e2e: dep-vendor-only run-deployer install-crds apply-psp e2e
Expand Down
7 changes: 7 additions & 0 deletions build/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENV GCLOUD_VERSION=232.0.0
ENV KUBECTL_VERSION=1.13.6
ENV DOCKER_VERSION=18.03.1-ce
ENV GOLANGCILINT_VERSION=1.17.1
ENV GOTESTSUM_VERSION=0.3.5

# Download required golang tools
RUN go get github.com/golang/dep/cmd/dep golang.org/x/tools/cmd/goimports
Expand Down Expand Up @@ -50,6 +51,12 @@ RUN apt-get update && apt-get --no-install-recommends -y install \
# Download Azure CLI
RUN curl -sSL https://aka.ms/InstallAzureCLIDeb | bash

# Install gotestsum to generate xUnit compatible XML for tests
RUN curl -fsSLO https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz && \
tar xzf gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz && \
mv gotestsum /usr/local/bin/gotestsum && chmod +x /usr/local/bin/gotestsum && \
rm gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz

# Add Go dependencies to Docker image
WORKDIR /go/src/github.com/elastic/cloud-on-k8s
COPY Gopkg.lock .
Expand Down
2 changes: 2 additions & 0 deletions build/ci/pr/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pipeline {
steps {
createConfig()
sh 'make -C build/ci TARGET=ci ci'
junit "unit-tests.xml"
junit "integration-tests.xml"
}
}
stage("Run smoke E2E tests") {
Expand Down

0 comments on commit 3f55e34

Please sign in to comment.