Skip to content

test: deflake LocalWorkerServiceTests by polling completion conditions#57

Merged
Theauxm merged 1 commit intomainfrom
test/deflake-localworker-tests
May 6, 2026
Merged

test: deflake LocalWorkerServiceTests by polling completion conditions#57
Theauxm merged 1 commit intomainfrom
test/deflake-localworker-tests

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented May 6, 2026

Summary

Follow-up to PR #56's audit. Replaces fixed Task.Delay(2000) and Task.Delay(3000) waits across 12 worker tests in LocalWorkerServiceTests with WaitUntilAsync / WaitForJobCount / WaitForJobAbsent helpers that synchronise on the actual completion signal (queue drained, specific job deleted, or metadata advanced past Pending).

The 15-second timeout is a safety ceiling, not a sleep. Each test finishes as soon as the underlying signal appears.

  • Local fixture run for the affected tests drops from ~60s to ~5s.
  • CI scheduling variance up to 10x historical local timings can no longer flake them.
  • All 16 LocalWorkerServiceTests pass locally.

The two intentional Task.Delay calls in this file are left untouched: the 500ms wait in Worker_DoesNotReclaim_RecentlyClaimedJob is verifying a negative outcome (job should NOT be reclaimed within the visibility timeout), and the 50ms waits in priority/FIFO setup ensure distinct created_at timestamps.

Test plan

  • dotnet build — zero warnings
  • dotnet csharpier check . — clean
  • dotnet test --filter LocalWorkerServiceTests — 16/16 passing in 5s

Replaces fixed Task.Delay(2000) and Task.Delay(3000) waits across 12
worker tests with poll-on-condition helpers (WaitUntilAsync,
WaitForJobCount, WaitForJobAbsent). Each test now synchronises on the
actual completion signal — queue drained, specific job deleted, or
metadata advanced past Pending — and finishes as soon as the signal
appears. The 15-second timeout is a safety ceiling, not a sleep.

Local run drops from ~60s to ~5s for the affected tests, and CI
scheduling variance up to 10x historical local timings can no longer
flake them.

The two intentional Task.Delays in this file are left untouched: the
500ms wait in Worker_DoesNotReclaim_RecentlyClaimedJob is verifying a
negative outcome (job stays claimed within visibility timeout), and
the 50ms waits in priority/FIFO setup ensure distinct created_at
timestamps.
@Theauxm Theauxm merged commit e48b27a into main May 6, 2026
1 check passed
@Theauxm Theauxm deleted the test/deflake-localworker-tests branch May 6, 2026 01:05
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented May 8, 2026

This PR is included in version 1.29.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant