Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
30 changes: 29 additions & 1 deletion .pipelines/templates/run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ stages:
name: "$(BUILD_POOL_NAME_DEFAULT)"
steps:
- script: |
set -e
make tools
# run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml), stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to stdout, pipe to read from stdout then exit with that status code. Read all output from fd 4 (output from tee) and write to top stdout

# run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml),
# stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to stdout, pipe to read from stdout then exit with that status code.
# Read all output from fd 4 (output from tee) and write to top stdout
{ { { {
sudo -E env "PATH=$PATH" make test-all;
echo $? >&3;
Expand All @@ -24,6 +28,30 @@ stages:
retryCountOnTaskFailure: 3
name: "Test"
displayName: "Run Tests"
- bash: |
sudo ln -s $(pwd)/build/tools/bin/gocov /usr/local/bin/gocov
sudo ln -s $(pwd)/build/tools/bin/gocov-xml /usr/local/bin/gocov-xml
gocov convert coverage-all.out > total_ut_coverage.json
gocov-xml < total_ut_coverage.json > total_ut_coverage.xml
name: "Coverage"
displayName: "Generate Coverage Report"
condition: always()
- task: PublishCodeCoverageResults@2
displayName: "Publish Code Coverage Report"
condition: always()
inputs:
summaryFileLocation: total_ut_coverage.xml
- task: BuildQualityChecks@8
displayName: "Check Code Coverage Regression"
condition: always()
inputs:
checkCoverage: true
coverageFailOption: "build"
coverageType: "lines"
fallbackOnPRTargetBranch: false
baseBranchRef: "master"
allowCoverageVariance: true
coverageVariance: 0.25

- stage: test_windows
displayName: Test ACN Windows
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,8 @@ RESTART_CASE ?= false
CNI_TYPE ?= cilium

test-all: ## run all unit tests.
@$(eval COVER_FILTER=`go list $(COVER_PKG)/... | tr '\n' ','`)
@echo Test coverpkg: $(COVER_FILTER)
go test -mod=readonly -buildvcs=false -tags "unit" --skip 'TestE2E*' -coverpkg=$(COVER_FILTER) -race -covermode atomic -coverprofile=coverage.out $(COVER_PKG)/...
-go test -mod=readonly -buildvcs=false -tags "unit" --skip 'TestE2E*' -race -covermode atomic -coverprofile=coverage-all.out $(COVER_PKG)/...
go tool cover -func=coverage-all.out

test-integration: ## run all integration tests.
AZURE_IPAM_VERSION=$(AZURE_IPAM_VERSION) \
Expand Down
Loading