Refactor exponential backoff test to remove sleeps#443
Conversation
…g backoff_sequence helper Replaced manual timing and thread sleeps with a utility function `backoff_sequence` to generate expected backoff durations. This change improves test clarity and determinism by removing reliance on actual waiting times in the test `test_accept_exponential_backoff_doubles_and_caps`. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors the exponential backoff configuration test to remove real-time sleeps by introducing a deterministic backoff_sequence helper and asserting exact delay sequences, while cleaning up unused timing imports and using saturating_mul to safely cap delay doubling. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughRefactor the exponential backoff test to remove wall‑clock timing. Replace thread sleeps and Instant measurements with a deterministic Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/server/config/tests.rs`:
- Around line 299-309: The test helper backoff_sequence currently uses backoff =
std::cmp::min(backoff.saturating_mul(2), max) which differs from production's
doubling semantics; update backoff_sequence (function backoff_sequence) to
double using Duration's multiplication (e.g. backoff = (backoff * 2).min(max) or
equivalent std::cmp::min(backoff * 2, max)) so the test mirrors production
behavior and will panic on extreme overflow the same way.
…ting_mul misuse Replaced saturating_mul with direct multiplication in backoff sequence calculation to fix incorrect backoff timing logic in tests. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Changes
Testing
Cleanup
Rationale
Test plan
◳ Generated by DevBoxer ◰
ℹ️ Tag @devboxerhub to ask questions and address PR feedback
📎 Task: https://www.devboxer.com/task/d1f32386-87da-4e75-b33d-90e24e2aa122
📝 Closes #310
Summary by Sourcery
Refactor exponential backoff configuration test to use a deterministic delay sequence instead of real-time sleeping.
Enhancements:
Tests: