1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/make/test-integration-flaky
Tibor Vass 42dcfc894a hack: Have TIMEOUT take -test.count into account when testing for flakiness
Signed-off-by: Tibor Vass <tibor@docker.com>
2019-02-08 18:36:31 +00:00

37 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -e -o pipefail
source hack/validate/.validate
new_tests=$(
validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' |
grep -E '^(\+func )(.*)(\*testing)' || true
)
if [ -z "$new_tests" ]; then
echo 'No new tests added to integration.'
return
fi
echo
echo "Found new integrations tests:"
echo "$new_tests"
echo "Running stress test for them."
(
TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
# Note: TEST_REPEAT will make the test suite run 5 times, restarting the daemon
# whereas testcount will make each test run 5 times in a row under the same daemon.
# This will make a total of 25 runs for each test in TESTARRAY.
export TEST_REPEAT=5
local testcount=5
# However, TIMEOUT needs to take testcount into account, or a premature time out may happen.
# The following ugliness will:
# - remove last character (usually 'm' from '10m')
# - multiply by testcount
# - add last character back
export TIMEOUT=$((${TIMEOUT::-1} * $testcount))${TIMEOUT:$((${#TIMEOUT}-1)):1}
export TESTFLAGS="-test.count $testcount -test.run ${TESTARRAY%?}"
echo "Using test flags: $TESTFLAGS"
source hack/make/test-integration
)