Skip to content

Commit

Permalink
[chore] Run integration tests without coverage (open-telemetry#22808)
Browse files Browse the repository at this point in the history
The previous target still exists, but a more intuitive target is added
and used by CI. Also switches integration targets to the same iteration
pattern used for other groups of modules.
  • Loading branch information
djaglowski committed Jun 22, 2023
1 parent bab80bf commit 03b375e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ jobs:
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Run Integration Tests
run: make integration-tests-with-cover
run: make integration-test

correctness-traces:
runs-on: ubuntu-latest
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ all-common:
e2e-test: otelcontribcol oteltestbedcol
$(MAKE) -C testbed run-tests

TARGET="do-integration-tests-with-cover"
.PHONY: integration-test
integration-test:
@$(MAKE) for-integration-target TARGET="mod-integration-test"

.PHONY: integration-tests-with-cover
integration-tests-with-cover: $(INTEGRATION_MODS)
integration-tests-with-cover:
@$(MAKE) for-integration-target TARGET="do-integration-tests-with-cover"

# Long-running e2e tests
.PHONY: stability-tests
Expand Down Expand Up @@ -205,6 +209,9 @@ for-pkg-target: $(PKG_MODS)
.PHONY: for-other-target
for-other-target: $(OTHER_MODS)

.PHONY: for-integration-target
for-integration-target: $(INTEGRATION_MODS)

# Debugging target, which helps to quickly determine whether for-all-target is working or not.
.PHONY: all-pwd
all-pwd:
Expand Down
17 changes: 13 additions & 4 deletions Makefile.Common
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# In order to ensure make instructions fail if there is command that fails a pipe (ie: `go test ... | tee -a ./test_results.txt`)
# the value `-o pipefail` (or `set -o pipefail`) is added to each shell command that make runs
# otherwise in the example command pipe, only the exit code of `tee` is recorded instead of `go test` which can cause
# otherwise in the example command pipe, only the exit code of `tee` is recorded instead of `go test` which can cause
# test to pass in CI when they should not.
SHELL = /bin/bash
ifeq ($(shell uname -s),Windows)
.SHELLFLAGS = /o pipefile /c
else
else
.SHELLFLAGS = -o pipefail -c
endif

Expand All @@ -17,7 +17,8 @@ GO_BUILD_TAGS=""
GOTEST_OPT?= -race -timeout 300s -parallel 4 --tags=$(GO_BUILD_TAGS)
GOTEST_INTEGRATION_OPT?= -race -timeout 360s -parallel 4
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration -coverprofile=integration-coverage.txt -covermode=atomic
GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration
GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic
GOCMD?= go
GOTEST=$(GOCMD) test
GOOS=$(shell $(GOCMD) env GOOS)
Expand Down Expand Up @@ -108,10 +109,18 @@ do-unit-tests-with-cover:
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) ./...
$(GOCMD) tool cover -html=coverage.txt -o coverage.html

.PHONY: mod-integration-test
mod-integration-test:
@echo "running $(GOCMD) integration test ./... in `pwd`"
$(GOTEST) $(GOTEST_OPT_WITH_INTEGRATION) ./...
@if [ -e integration-coverage.txt ]; then \
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
fi

.PHONY: do-integration-tests-with-cover
do-integration-tests-with-cover:
@echo "running $(GOCMD) integration test ./... + coverage in `pwd`"
$(GOTEST) $(GOTEST_OPT_WITH_INTEGRATION) ./...
$(GOTEST) $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE) ./...
@if [ -e integration-coverage.txt ]; then \
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
fi
Expand Down

0 comments on commit 03b375e

Please sign in to comment.