You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: TestEngineFaultIsolation/check is flaky because the fault handler closes exited before CheckCommits re-panics #703
TestEngineFaultIsolation/check runs the test binary again as a subprocess and expects it to exit with status 2 and panic: injected text fault (internal/engine/fault_test.go:39-46). In the subprocess, runEngineFault waits for e.exited and then calls t.Fatal("CheckCommits swallowed its panic") (fault_test.go:116-118).
The engine's deferred fault handler closes e.exited before it re-panics (internal/engine/engine.go:405-408):
close(e.exited)
if fault != nil && opts.CheckCommits {
panic(fault)
}
So the test goroutine is released before the engine goroutine re-panics. When the test goroutine is scheduled first, t.Fatal ends the subprocess with status 1, and the parent fails with both CheckCommits swallowed its panic and CheckCommits did not re-panic: exit status 1.
Why it matters
The test fails at random under CI load (seen in a test job on an unrelated PR), and the failure message claims CheckCommits swallowed the panic, which is not what happened. go test -count=30 -run TestEngineFaultIsolation ./internal/engine passes 30/30 on an idle Linux machine, so it does not show up locally.
Proposal
When CheckCommits is set and there is a fault, re-panic without closing e.exited first (a re-panic ends the process anyway), or close it only on the paths that do not re-panic. Alternatively have the test's check mode block (for example select {} with a timeout that then fails) after e.exited instead of failing at once, so only the engine's panic can end the process.
Acceptance
go test -count=200 -cpu=1,2,8 -run 'TestEngineFaultIsolation/check' ./internal/engine passes.
The check subtest still fails when CheckCommits does not re-panic.
Activity