fix(tests): make RPM limit test sequential to fix race condition#21937
Merged
jquinter merged 1 commit intoBerriAI:mainfrom Feb 23, 2026
Merged
fix(tests): make RPM limit test sequential to fix race condition#21937jquinter merged 1 commit intoBerriAI:mainfrom
jquinter merged 1 commit intoBerriAI:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes a flaky test (
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/local_testing/test_pass_through_endpoints.py | Replaced concurrent run_in_executor + asyncio.gather with sequential synchronous client.post calls to eliminate race condition in rate limiter test. No functional issues introduced. |
Sequence Diagram
sequenceDiagram
participant Test as Test Runner
participant Client as TestClient
participant Proxy as Proxy Server
participant RL as Rate Limiter
Note over Test,RL: Before (Concurrent - Race Condition)
Test->>Client: run_in_executor(post /v1/rerank) x N
Client-->>Proxy: Concurrent requests
Proxy->>RL: Check RPM (race: counter not yet updated)
RL-->>Proxy: Allow (stale count)
Note over RL: More requests slip through than expected
Note over Test,RL: After (Sequential - Deterministic)
loop For each request
Test->>Client: client.post(/v1/rerank)
Client->>Proxy: Single request
Proxy->>RL: Check RPM
RL-->>Proxy: Allow or Reject (counter updated)
Proxy-->>Client: 200 or 429
Client-->>Test: Response
end
Note over RL: Rate limiting behaves deterministically
Last reviewed commit: 6794e62
6794e62 to
e0aa384
Compare
Concurrent requests via run_in_executor + asyncio.gather caused a race condition where more requests slipped through the rate limiter than expected, leading to flaky test failures (e.g. 3 successes instead of 2 with rpm_limit=2). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e0aa384 to
bb63de2
Compare
damhau
pushed a commit
to damhau/litellm
that referenced
this pull request
Feb 26, 2026
fix(tests): make RPM limit test sequential to fix race condition
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
test_pass_through_endpoint_rpm_limittest that intermittently fails due to a race conditionrun_in_executor+asyncio.gather, allowing more requests to slip through the rate limiter before the counter was updated (e.g. 3 successes instead of expected 2 withrpm_limit=2)Test plan
auth=Falsetest cases pass locallyauth=Truecases requireLITELLM_LICENSE(CI only)🤖 Generated with Claude Code