test(service): deterministic sync for health worker tests (#83)#85
Open
ashioyajotham wants to merge 1 commit into
Open
test(service): deterministic sync for health worker tests (#83)#85ashioyajotham wants to merge 1 commit into
ashioyajotham wants to merge 1 commit into
Conversation
…ing (Prescott-Data#83) Remove brittle time.Sleep-based waiting from connection health worker tests. Use channel-based synchronization tied to expected repository update calls so assertions run exactly when the worker completes a check iteration.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR makes the ConnectionHealthWorker tests deterministic by removing fixed sleeps and instead waiting for a mock callback signal when the worker updates connection health.
Changes:
- Added a
runWorkerUntilSignalhelper to start the worker and wait for a completion signal with a timeout. - Updated multiple tests to close a
donechannel fromUpdateHealthStatusmock.Run(...)and wait on it instead oftime.Sleep.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+23
to
+31
| defer cancel() | ||
|
|
||
| go worker.Start(ctx) | ||
|
|
||
| select { | ||
| case <-done: | ||
| case <-time.After(2 * time.Second): | ||
| t.Fatal("timed out waiting for health worker signal") | ||
| } |
Comment on lines
+29
to
+30
| case <-time.After(2 * time.Second): | ||
| t.Fatal("timed out waiting for health worker signal") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unWorkerUntilSignal helper to drive worker execution until a known repository update call occurs.
Why
Issue #83 calls out test instability from fixed sleeps. This refactor makes tests deterministic and faster by synchronizing on actual worker side effects.
Test plan