Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CI: configure gotestsum for flaky test retries and early failure#52069

Open
veeceey wants to merge 2 commits intomoby:masterfrom
veeceey:fix/issue-50732-gotestsum-retry-flaky
Open

CI: configure gotestsum for flaky test retries and early failure#52069
veeceey wants to merge 2 commits intomoby:masterfrom
veeceey:fix/issue-50732-gotestsum-retry-flaky

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 20, 2026

Summary

Addresses #50732 by configuring gotestsum flags across all test scripts to automatically retry flaky tests and fail early when too many tests fail.

Changes

  • hack/test/unit: Added --rerun-fails=2, --rerun-fails-max-failures=10, --rerun-fails-abort-on-data-race, --rerun-fails-report, and --max-fails=20 to all gotestsum invocations (api, client, main packages, and libnetwork). Packages are now passed via --packages= instead of positional args, which is required for --rerun-fails to correctly rerun only the specific failed tests. The existing libnetwork flaky tests retain their --rerun-fails=4 setting and also gain the new safety flags.

  • hack/make/.integration-test-helpers: Added --max-fails=20 only, since --rerun-fails is not compatible with --raw-command mode (used for pre-compiled test binaries).

  • hack/make.ps1 (Windows): Added the same flags to all gotestsum invocations for unit, integration, and integration-cli tests.

  • .github/workflows/buildkit.yml: Added the full set of flags to the BuildKit test step.

Flag rationale

Flag Value Purpose
--rerun-fails 2 (4 for libnetwork flaky) Retry failed tests up to N times before reporting failure
--rerun-fails-max-failures 10 Skip retries if initial run has >10 failures (real breakage, not flakiness)
--rerun-fails-abort-on-data-race - Never mask data race failures with retries
--rerun-fails-report bundles/*-rerun-report.txt Write a report of retried tests for post-analysis
--max-fails 20 Abort the test run early after 20 failures (fail fast)

Test plan

  • Verify CI passes on Linux unit tests
  • Verify CI passes on Windows unit and integration tests
  • Verify BuildKit CI tests pass
  • Check that rerun reports are generated in the bundles directory when flaky tests occur
  • Confirm --max-fails causes early abort when many tests fail simultaneously

Closes #50732

🤖 Generated with Claude Code

@veeceey veeceey requested a review from tianon as a code owner February 20, 2026 08:16
Add gotestsum flags across all test scripts (unit, integration, and
Windows) to automatically retry flaky tests and fail early when too
many tests fail:

- --rerun-fails=2: retry failed tests up to 2 times before reporting
  failure (existing libnetwork flaky tests keep --rerun-fails=4)
- --rerun-fails-max-failures=10: skip retries if initial run has more
  than 10 failures (indicates a real problem, not flakiness)
- --rerun-fails-abort-on-data-race: never mask data race failures
  with retries
- --rerun-fails-report: write a report of retried tests for
  post-analysis
- --max-fails=20: abort the test run early after 20 failures to avoid
  waiting for long CI runs that will never pass

For unit tests, packages are now passed via --packages= instead of as
positional arguments, which is required for --rerun-fails to correctly
identify and rerun only the specific failed tests rather than the
entire suite.

For integration tests using --raw-command (pre-compiled test binaries),
only --max-fails is added since --rerun-fails is not compatible with
--raw-command mode.

Closes moby#50732

Signed-off-by: Varun Chawla <[email protected]>
@veeceey veeceey force-pushed the fix/issue-50732-gotestsum-retry-flaky branch from 3439182 to 320f133 Compare February 23, 2026 01:59
gotestsum requires packages to be specified via --packages= when
--rerun-fails is used with go test args. Fix the unit test invocation
to use --packages= instead of positional args, and add --packages=./...
to the integration test invocation.

Signed-off-by: Varun Chawla <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: explore gotestsum options for retrying flaky tests, and failing early

1 participant