Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate xUnit compatible test results for unit and integration tests #1724

Merged
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
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