fix(tests): make RPM limit test sequential to avoid race condition
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>
This commit is contained in:
parent
36813199b6
commit
bb63de2f82
@ -223,22 +223,17 @@ async def test_pass_through_endpoint_rpm_limit(
|
||||
],
|
||||
}
|
||||
|
||||
# Make a request to the pass-through endpoint
|
||||
tasks = []
|
||||
# Make requests sequentially to avoid race conditions in rate limiter
|
||||
# Concurrent requests can slip through before the counter is updated
|
||||
responses = []
|
||||
for mock_api_key in mock_api_keys:
|
||||
for _ in range(requests_to_make):
|
||||
task = asyncio.get_running_loop().run_in_executor(
|
||||
None,
|
||||
partial(
|
||||
client.post,
|
||||
"/v1/rerank",
|
||||
json=_json_data,
|
||||
headers={"Authorization": "Bearer {}".format(mock_api_key)},
|
||||
),
|
||||
response = client.post(
|
||||
"/v1/rerank",
|
||||
json=_json_data,
|
||||
headers={"Authorization": "Bearer {}".format(mock_api_key)},
|
||||
)
|
||||
tasks.append(task)
|
||||
|
||||
responses = await asyncio.gather(*tasks)
|
||||
responses.append(response)
|
||||
|
||||
if num_users == 1:
|
||||
status_codes = sorted([response.status_code for response in responses])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user