On main at f30f550 there are four hand-rolled poll-until helpers in test code, each with its own deadline and interval and no shared implementation:
internal/agent/async_diagnostics_test.go:126 waitForIdle 2s / 2ms
internal/daemon/pool_test.go:245 waitFor 2s / 1ms
internal/daemon/server_test.go:34 waitForFile 2s / 2ms
internal/swarm/lifecycle_test.go:83 waitFor 3s / 5ms
Found by the sweep for #1018, which also found that the tests that did NOT have one were the ones racing process startup on CI. A fifth copy is the likely outcome of the next such fix.
Worth one shared helper in a small internal/testutil package: WaitFor(t, what string, cond func() bool) with a generous default deadline, a short interval, and a failure message that names what it was waiting for. The four sites migrate to it. Keep it simple; the value is one place to adjust when a deadline turns out too tight on a loaded runner, rather than four.
Good first issue: mechanical, well bounded, and the existing helpers show exactly what the shared one needs to do.
On
mainat f30f550 there are four hand-rolled poll-until helpers in test code, each with its own deadline and interval and no shared implementation:Found by the sweep for #1018, which also found that the tests that did NOT have one were the ones racing process startup on CI. A fifth copy is the likely outcome of the next such fix.
Worth one shared helper in a small
internal/testutilpackage:WaitFor(t, what string, cond func() bool)with a generous default deadline, a short interval, and a failure message that names what it was waiting for. The four sites migrate to it. Keep it simple; the value is one place to adjust when a deadline turns out too tight on a loaded runner, rather than four.Good first issue: mechanical, well bounded, and the existing helpers show exactly what the shared one needs to do.