test(ws): bound the load test's unregister settle by overallTimeout, not 5s (#1379)

TestTheLoadTest failed on the post-merge main run's windows-latest -race leg
(job 95067154071) with "timed out after 5s waiting for churned clients to
fully unregister" — every worker had finished, the hub was still running,
and the goleak dump that followed was only the anchor drainers the t.Fatal
skipped stopping. The runner was simply slow: the ws package took 276s
against 159s on the identical tree an hour earlier, db and service ran
13-24% slower too, and Unregister drains asynchronously behind the hub
loop's remaining broadcast work.

Bound the settle wait by the test's own overallTimeout (90s), the same
"only a genuine hang takes this long" limit the workers use. waitFor
returns as soon as ClientCount matches, so a healthy run pays nothing —
locally under -race the whole test still finishes in ~9s.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
J3vb
2026-08-15 22:57:01 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent fb04a579c4
commit a366160dc8
+9 -2
View File
@@ -261,8 +261,15 @@ func TestTheLoadTest(t *testing.T) {
}
// Only the anchors should remain registered — every churned client
// unregistered itself at the end of its own round.
waitFor(t, 5*time.Second, func() bool { return hub.ClientCount() == numAnchors },
// unregistered itself at the end of its own round. Those Unregister calls
// are async: they queue behind whatever broadcast work the hub loop still
// holds, and how long that drain takes scales with the runner. A fixed 5s
// budget failed on a slow windows-latest -race runner (the whole package
// ran 74% slower than usual) while the workers themselves had finished
// fine — so bound the settle by the same "only a genuine hang takes this
// long" limit the workers use. waitFor returns the moment the count
// matches, so a healthy run pays nothing extra.
waitFor(t, overallTimeout, func() bool { return hub.ClientCount() == numAnchors },
"churned clients to fully unregister")
if got := hub.ClientCount(); got != numAnchors {
t.Errorf("ClientCount = %d after churn settled, want %d (anchors only)", got, numAnchors)