Travis: Reduce footprint of unit tests - so hopefully flakiness (#12350)

* ./tests: Remove legacy coverage collection code

The legacy tests/cover.test.bash script was not ./test script
compatible for a long time.

The following method of coverage collection works (also across
packages) and does not make all the test execution slower.

```
COVERDIR=coverage PASSES="build build_cov cov" ./test
go tool cover -html ./coverage/cover.out
```

* CI: Reduce duplicated coverage between different variants on Travis

We used to execute unit tests in 3 different jobs,
every time with --race detection and every time in 3 variants:1,2,4
CPUS.

The proposed change makes each of the jobs use different variant of
CPUS, and only 4-cpu variant is running with --race detection
(as the more-parallel variant is more likely to experience races),
This commit is contained in:
Piotr Tabor
2020-09-30 04:47:05 +02:00
committed by GitHub
parent b47cd2f470
commit a6b0375b7b
3 changed files with 19 additions and 57 deletions

12
test
View File

@@ -29,7 +29,8 @@
#
# Run code coverage
# COVERDIR must either be a absolute path or a relative path to the etcd root
# $ COVERDIR=coverage PASSES="build_cov cov" ./test
# $ COVERDIR=coverage PASSES="build build_cov cov" ./test
# $ go tool cover -html ./coverage/cover.out
set -e
# The test script is not supposed to make any changes to the files
@@ -43,16 +44,12 @@ source ./scripts/test_lib.sh
PASSES=${PASSES:-"fmt bom dep build unit"}
PKG=${PKG:-}
# Invoke ./tests/cover.test.bash for HTML output
COVER="--cover=${COVER:-true}"
if [ -z "$GOARCH" ]; then
GOARCH=$(go env GOARCH);
fi
# determine the number of CPUs to use for Go tests
CPU=${CPU:-"1,2,4"}
echo "Running with CPU:" "${CPU}"
CPU=${CPU:-"4"}
# determine whether target supports race detection
if [ -z "${RACE}" ] ; then
@@ -66,7 +63,8 @@ else
fi
# This options make sense for cases where SUT (System Under Test) is compiled by test.
COMMON_TEST_FLAGS=("-cpu=${CPU}" "${RACE}" "${COVER}")
COMMON_TEST_FLAGS=("-cpu=${CPU}" "${RACE}")
log_callout "Running with ${COMMON_TEST_FLAGS[*]}"
RUN_ARG=()
if [ -n "${TESTCASE}" ]; then