Make script/test fail on flaky failures and enable -race (closes #32) #53
Reference in New Issue
Block a user
Delete Branch "fix-script-test-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #32.
What changed
script/testonly. Its last two operative lines were:The verbose rerun was the last command, so its exit status became the script's. A test that failed on the first run and passed on the retry produced exit 0. The
Dockerfilerunsmake testand CI runsscript/cibuildwhich runsdocker build, so that hole made flaky failures invisible across the whole repo.Replaced with the pattern from
REPO_POLICIES.md, verbatim:The trailing
exit 1is the point: the first run already proved the tests are broken, so the rerun is diagnostic only and can never turn a failed run green.go vet ./...still runs first, unchanged. The script stays POSIX sh withset -eu, the existingCGO_ENABLED=1export, and the repo-rootcdidiom. No other script is touched and.golangci.ymlis untouched.TODO.mdgets one additive entry in the same commit.Read this before merging: CI is red, deliberately
Enabling
-raceexposed a real conflict with the policy timing budget.make checkdoes not pass on this branch, and nothing here has been bent to make it pass.Measured in the CI-equivalent container —
script/cibuild, i.e.docker build --ulimit memlock=-1:-1 ., which runsmake testin the builder stage. The host is unusable for this measurement: itsmemlockhard limit is 8192 KB, so the memguard 10MB case aborts long before the suite can be timed.make testlayer, wall clockmaintoday, no-racego vet+ compile)internal/cli9.6s-raceoninternal/clikilled at the 30s timeoutNo data race was found. Every package that ran to completion is clean under the detector. The failure is pure slowness, not a hang and not a deadlock — the stack at the timeout sits in
memguard/core.Wipeundercli.(*Instance).ImportSecret(internal/cli/secrets.go:579), making ordinary forward progress.TestAddSecretVariousSizesalone eats 24.19s of the 30s budget, with99MBat 10.25s and100MB minus 1at 10.19s;TestImportSecretVariousSizesis the same size ladder over the import path, which is where the package runs out of clock.internal/clineeds roughly 55-60s under-raceagainst 9.6s without.Every available lever is one the issue explicitly forbids: raising the timeout papers over it (and the 20s budget would still be missed by 3x),
t.Skipis a skip, and shrinking the sizes deletes boundary coverage for the real 100MB cap atinternal/cli/secrets.go:245and:515. Making the large-secret path genuinely faster is out of scope here. No small in-scope change closes a 6x gap, so this stops and reports rather than forcing one.#52 has the full measurements and four options for a decision. That decision is yours; my read is the build-tag split, since it is the only option that gives up nothing. This PR should land together with whatever #52 concludes, not before it.
Also worth stating plainly: the clean
-raceresult is not evidence that #34's missing file locking is harmless. The suite has no test that touches the vault from two goroutines at once, so there was nothing for the detector to catch. #34 stands entirely on its own.Verification
make lint— clean,0 issues.make fmt-check— clean.make test— fails as described above; the new pattern was confirmed working end to end, printing--- Rerunning with -v for details ---and exiting non-zero after the rerun.script/cibuild— run on bothmainand this branch for the before/after numbers in the table.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.