Skip to content

test: a refilled token-bucket burst after idle is admitted in full - #2

Merged
dittops merged 2 commits into
mainfrom
test/burst-after-idle
Sep 27, 2026
Merged

dittops merged 2 commits into
mainfrom
test/burst-after-idle

Conversation

@dittops

@dittops dittops commented Sep 27, 2026

Copy link
Copy Markdown
Member

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_allowance 0.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 --check
  • cargo clippy --all-targets --features redis-0-31 -- -D warnings, and the same with redis-0-27
  • RESIL_TEST_REDIS_URL=redis://127.0.0.1:6390 cargo test --release --features redis-0-31: 54 + 5 + 4 + 17 passed

Note: 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

dittops and others added 2 commits September 27, 2026 22:46
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>
@dittops
dittops merged commit 2cf6a06 into main Sep 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant