Skip to content

tests: four independent waitFor helpers, no shared poll-until helper #1023

Description

@Vasanthdev2004

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersissue-approvedReviewed and approved by the core team; community PRs may implement this issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions