Repository navigation
test(vmpool): make the deferred-reap gate test's select deterministic - #845
Conversation
TestDeferredReapOpensTheGateAtTheBarrierNotAfterTheReap waited on the second Exec with a select over entered and done. The fake Run sends on entered (buffered) and returns at once, so the second Exec can finish and fill done before the test goroutine reaches the select. With both cases ready Go picks one at random, and picking done failed the test with "second Exec returned without entering Run: <nil>" although Run had been entered. Run's send happens before Exec returns, so done with nothing on entered is the only real skipped-Run case. The done case now checks entered without blocking before failing, and carries the Exec's error over to the final check. The code under test is unchanged, and the NOT VACUOUS check (barrier passed, reap outstanding) still pins that the gate opens at the barrier. Closes rossoctl#805 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Test-only fix for the flaky deferred-reap gate test (#805): the waiting select raced two ready channels, so Go could pick done and fail the test even though Run had been entered. The nested non-blocking check of entered inside the done case is the right shape — Run's send on entered is ordered before Exec returns, so done with an empty entered is the only genuine failure — and carrying secondErr to the final check avoids the second read of done. The NOT VACUOUS barrier/reap assertion is untouched, so the property the test pins (the gate opens at the barrier, not after the reap) is preserved. The empirical validation in the PR body (12,000 race-enabled runs under CPU load, 4→0 failures) is exactly the evidence a flake fix should carry. No findings; clean test change.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Go (test)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
The test fix is correct. Run's send on entered happens before Exec returns, and that return happens before the send on done. So if done is ready while entered is empty, Run really was not entered, and checking entered without blocking before failing is enough to remove the random-select false positive from #805. The second Exec's error still reaches the final check, and the NOT VACUOUS barrier/reap assertion is unchanged.
Something I noticed that this PR neither causes nor needs to fix: the NOT VACUOUS check (reaps != 0) still depends on the 250 ms bound in reapingVM.Reap. If the test goroutine stalls for more than 250 ms after the first Exec, the first reap finishes and the test fails for a reason unrelated to the gate. That window is far wider than the select race, and the author's 12,000 runs under load saw no failures, so this is only a pointer in case #805-style reports keep coming.
Author: webchang (MEMBER, maintainer)
Areas reviewed: Go (test only)
Agent/IDE config (.claude/.vscode): none
Commits: 1, signed off
CI status: all 17 checks passing
Assisted-By: Claude Code
clawgenti
left a comment
There was a problem hiding this comment.
Review record for this cycle.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
Brings rossoctl#845 (vmpool: the deferred-reap gate test's select is deterministic) and rossoctl#846 (harness: opt-in SH_PROMPT_CACHE / SH_GATEWAY_CACHE switches turn turn caching off). No conflicts. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #805
What changed and why
remote-worker/internal/vmpool/deferred_reap_test.go,TestDeferredReapOpensTheGateAtTheBarrierNotAfterTheReap: the select that waits on the secondExecraced two channels that can both be ready. The fakeRunsends onentered(buffered) and returns at once, so the secondExeccan finish and filldonebefore the test goroutine reaches the select. With both cases ready Go picks one at random, and pickingdonefailed the test withsecond Exec returned without entering Run: <nil>even thoughRunhad been entered.Run's send onenteredhappens beforeExecreturns, sodonewith nothing onenteredis the only real "returned without entering Run". Thedonecase now checksenteredwithout blocking before failing, and carries theExec's error over to the final check (which used to readdoneagain).Runhad run. TheNOT VACUOUScheck after the select (barrier passed, reap still outstanding) is unchanged and still pins that the gate opens at the barrier, not after the reap.Validation
In
remote-worker, with a race-enabled test binary of./internal/vmpool, run under CPU load (12 busy-loop processes),-test.count=3000 -test.cpu 1,2,4,8 -test.run TestDeferredReapOpensTheGateAtTheBarrierNotAfterTheReap(12,000 runs):deferred_reap_test.go:138: second Exec returned without entering Run: <nil>.PASS.Without load,
go test -race -count=500 -cpu 1,2,4did not reproduce it on main (1,500 runs passed), which matches CI seeing it only now and then.After the change:
go test -race -count=500 -run TestDeferredReapOpensTheGateAtTheBarrierNotAfterTheReap ./internal/vmpool:ok.go test -race ./internal/vmpool:ok.go vet ./...: clean.Every commit is signed off (DCO).
Assisted-By: Claude Code