test: a refilled token-bucket burst after idle is admitted in full - #2
Merged
Merged
Conversation
Real-Redis regression test for the refilled-burst path (token bucket 1/s, burst 2, local_allowance 0.8) across 0/2/4 ms store latency. Passes locally; written while chasing an intermittent under-admission of one request seen on a live gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… window Token bucket 1/s burst 2 plus a non-binding per-minute window, with the requests of each burst arriving 0-8 ms apart: 2.6 s after a drain, the refilled burst admits exactly 2 of 3, every round. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Two real-Redis regression tests for the token bucket's refilled burst after a drain: a limit of 1/s with burst 2 must admit exactly 2 once the bucket has refilled.
a_concurrent_burst_after_idle_gets_the_whole_burst: one replica,local_allowance0.8, a 10 ms Redis timeout, store latency of 0, 2 and 4 ms, 6 rounds. A burst of 5 drains the bucket; 2.6 s later a burst of 3 must get exactly 2.a_staggered_burst_after_idle_gets_the_whole_burst_with_a_second_window: the same bucket plus a per-minute window that never binds (1000, 3000 or 6000/min). A token bucket gives every window the burst. Requests arrive 0, 1, 3 or 8 ms apart, the way traffic does through a load balancer. The second window must not cost the refilled burst a token.These tests were written while chasing an apparent under-admission on a live gateway. That turned out to be a timing artifact in the calling test: a response cache answered the repeated request in about 0.5 s, so the measured gap from the drain was shorter than intended. The limiter admitted correctly. These tests pin that behaviour down. No library code changes.
Test plan
cargo fmt --checkcargo clippy --all-targets --features redis-0-31 -- -D warnings, and the same withredis-0-27RESIL_TEST_REDIS_URL=redis://127.0.0.1:6390 cargo test --release --features redis-0-31: 54 + 5 + 4 + 17 passedNote: the staggered test sleeps 2.6 s per round over 12 configurations, which adds about 2 minutes to the Redis test job.
🤖 Generated with Claude Code