The flakestress command stress-tests Go packages to find flaky tests.
It compiles a test binary once and then runs it many times in parallel,
reporting failures. It is similar to golang.org/x/tools/cmd/stress but
with some usability niceties.
go install github.com/bradfitz/flakestress@latest
flakestress [flags] <target> [-- extra-test-args...]
The target can be:
github.com/foo/bar # test the whole package
github.com/foo/bar.TestBlah # test only TestBlah
github.com/foo/bar.TestBlah/sub # test only a subtest
TestBlah # git grep to find the package
TestBlah/sub # git grep, with subtest
If a bare test name is ambiguous (found in multiple packages), flakestress errors and lists the fully qualified options.
Use -run to pass a regex to -test.run, for stress-testing multiple tests:
flakestress -run 'TestLogout|TestControl' ./control/controlclient/
By default it runs NumCPU*2 parallel workers for 1 minute with -failfast
mode enabled. Each worker buffers its output and only failure output is
printed, serialized to avoid interleaving.
-p N number of parallel workers (default NumCPU*2)
-duration d how long to run (default 1m)
-failfast stop on first failure (default true)
-quiet suppress periodic status updates
-run regex pass regex to -test.run (overrides test name in target)
-race build test binary with the race detector
-tags tags build tags to pass to go test -c
-taskset cpus pin test processes to these CPUs via taskset (e.g. "0" or "0-1")
Arguments after -- are passed directly to the test binary:
flakestress ./pkg -- --run-vm-tests --verbose