Files
moby/hack/make/test-integration-flaky
Paweł Gronowski 64ea51f2fb test-integration-flaky: Add /flaky-check=Test1,Test2 PR body directive
Allows PR authors to stress-test specific integration tests for
flakiness even when the diff doesn't touch them.

Add a /flaky-check directive on its own line in the PR body:

/flaky-check=TestFoo,TestBar

The GHA integration-flaky job parses the directive from the PR body and
exports the names as FLAKY_EXTRA_TESTS, which the script appends to the
diff-detected set before running the stress loop.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-07-03 22:42:12 +02:00

61 lines
1.6 KiB
Bash

#!/usr/bin/env bash
set -e -o pipefail
source hack/validate/.validate
added_tests() {
validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' \
| grep -E '^(\+func Test)(.*)(\*testing\.T\))' \
| sed -E 's/^\+func (Test[A-Za-z0-9_]*).*/\1/' \
|| true
}
changed_tests() {
validate_diff --diff-filter=ACMR --function-context -- 'integration/*_test.go' \
| grep -E '^ func Test[A-Za-z0-9_]*\(.*\*testing\.T\)' \
| sed -E 's/^ func (Test[A-Za-z0-9_]*).*/\1/' \
|| true
}
# explicit_tests emits extra test names appended via the /flaky-check=TestA,TestB
# directive in the PR body. The workflow extracts that directive and passes it
# here as the FLAKY_EXTRA_TESTS variable.
explicit_tests() {
if [ -n "${FLAKY_EXTRA_TESTS-}" ]; then
echo "$FLAKY_EXTRA_TESTS" | tr ',' '\n'
fi
}
run_integration_flaky() {
tests=$(
{
added_tests
changed_tests
explicit_tests
} | sort -u
)
if [ -z "$tests" ]; then
echo 'No new or modified tests found in integration.'
return
fi
echo
echo "Found new or modified integration tests:"
echo "$tests"
echo "Running stress test for them."
(
TESTARRAY=$(echo "$tests" | tr '\n' '|')
# Note: TEST_REPEAT will make the test suite run 10 times, restarting the daemon
# and each test will run 10 times in a row under the same daemon.
# This will make a total of 100 runs for each test in TESTARRAY.
export TEST_REPEAT=10
export TESTFLAGS="-test.count ${TEST_REPEAT} -test.run ${TESTARRAY%?}"
echo "Using test flags: $TESTFLAGS"
source hack/make/test-integration
)
}
run_integration_flaky