-
Notifications
You must be signed in to change notification settings - Fork 20
fix test race condition #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes update tests to handle non-determinism and improve goroutine management. In the search handler test, some mocked storage calls are relaxed to allow for optional invocation. In the reorg handler test, explicit context cancellation and shutdown verification are added to ensure proper goroutine termination. Changes
Sequence Diagram(s)sequenceDiagram
participant Test
participant ReorgHandler
Test->>ReorgHandler: Start with cancelable context (in goroutine)
Note right of ReorgHandler: Handler runs
Test->>ReorgHandler: Sleep briefly, then cancel context
ReorgHandler-->>Test: Signals completion via channel
Test->>Test: Waits for handler to exit (with timeout)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
TL;DR
Fix race conditions in search handler tests and improve reorg handler test cleanup.
What changed?
mockStorage.On(...).Maybe()
instead ofEXPECT()
for calls that might not happen due to race conditionsHow to test?
Why make this change?
The search handler tests were flaky due to race conditions where some mocked calls might not be made depending on timing. By using
.Maybe()
, we allow these calls to be optional, making the tests more reliable.The reorg handler test was improved to properly clean up resources by using a cancelable context and waiting for the handler to stop, preventing potential resource leaks and making the test more deterministic.
Summary by CodeRabbit