Repository navigation
test(cache): pin RetryPolicy jitter band and backoff edge cases (#528) - #538
Merged
Merged
Conversation
Three additional unit tests in `crates/cache/src/retry.rs` covering boundary conditions of `RetryPolicy::delay_for` that the existing tests left open: - `delay_for_jitter_stays_within_equal_jitter_band`: samples each of four non-clamped jitter ratios (0.1, 0.25, 0.5, 1.0) 256 times and pins both bounds of the equal-jitter band. The existing `delay_for_clamps_jitter_above_one` only exercised the clamp at `r > 1.0`; a regression in the formula at typical ratios was previously invisible. - `delay_for_zero_jitter_is_deterministic`: pins the contract that `jitter_ratio = 0.0` collapses the formula to exactly `base`, which tests pinning expected sleep schedules rely on. - `delay_for_zero_initial_backoff_is_zero_regardless_of_jitter`: covers the `initial_backoff_ms = 0` edge case across attempts and a non-zero jitter — both factor paths collapse a 0 base to a 0 delay. The `max_retries = 0` "no sleep / single attempt" path remains covered by `retry_disabled_policy_makes_a_single_attempt` in `crates/cache/tests/pull_through.rs:2065`, which drives the full `retry_fetch` loop. Closes #528. https://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo
Coverage reportTotal: 89.19% (was 89.16%, ▲ +0.02%) — 13632/15285 lines
History
|
|
Warning Gemini is experiencing higher than usual traffic and was unable to create the review. Please try again in a few hours by commenting |
4 tasks done
alpergundogdu
added a commit
that referenced
this pull request
May 14, 2026
…553) Adds `coalesced_concurrent_misses_fire_origin_exactly_once` in `crates/cache/tests/pull_through.rs`. Spawns 10 concurrent `engine.get(hash)` tasks for an uncached blob against a `SlowOnceOrigin` helper (sleeps 25ms before serving) and asserts the origin saw exactly one fetch. The existing `coalesced_owner_retry_unblocks_waiters_on_success` already pins coalescing under retry (`origin.fetches() == 3`); this is the missing happy-path companion that pins `== 1` on the no-failure path so a regression breaking coalescing — duplicate origin charges, duplicate iroh-blobs inserts — shows up without retry noise muddying the count. `SlowOnceOrigin` mirrors the shape of `FailingThenSucceedingOrigin` (atomic fetch counter, `OriginFetch::found_one_shot`) but takes a `Duration` delay instead of a failure count. The delay is load-bearing: an instantaneous fetch can complete before any waiter is scheduled, making a coalescing assertion trivially pass for the wrong reason. Also: backfill `buffered_max_bytes` in the three pre-#519 `RetryPolicy` struct literals introduced by #538, which now don't compile because #519 added the field after #538 landed. Closes #530. https://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo Co-authored-by: Claude <[email protected]>
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
Adds three unit tests to
crates/cache/src/retry.rscoveringRetryPolicy::delay_forboundary conditions the existing tests left uncovered:delay_for_jitter_stays_within_equal_jitter_band— samples four non-clamped ratios (0.1, 0.25, 0.5, 1.0) 256 times each and pins both bounds of the equal-jitter band. The existingdelay_for_clamps_jitter_above_oneonly exercised the clamp atr > 1.0, so a regression in the formula at typical ratios was previously invisible.delay_for_zero_jitter_is_deterministic— pins the contract thatjitter_ratio = 0.0collapses the formula to exactlybase(the property tests pinning expected sleep schedules rely on).delay_for_zero_initial_backoff_is_zero_regardless_of_jitter— covers theinitial_backoff_ms = 0edge case across attempts with a non-zero jitter; both factor paths collapse a zero base to a zero delay.The
max_retries = 0"no sleep / single attempt" path remains covered byretry_disabled_policy_makes_a_single_attemptincrates/cache/tests/pull_through.rs:2065, which drives the fullretry_fetchloop.Closes #528.
Test plan
cargo test -p decdn-cache --lib retry::— 9/9 pass (6 existing + 3 new)cargo clippy -p decdn-cache --all-targets -- -D warnings— cleancargo fmt -- --check— cleanhttps://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo
Generated by Claude Code