mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
test(proxy): cross rate limit boundary deterministically
This commit is contained in:
parent
d15740e29b
commit
673e978682
2 changed files with 11 additions and 9 deletions
|
|
@ -1126,9 +1126,13 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger):
|
|||
nx=True,
|
||||
parent_otel_span=parent_otel_span,
|
||||
)
|
||||
current_window_value = legacy_window_value if inserted else await redis_cache.async_get_cache(
|
||||
key=window_key,
|
||||
parent_otel_span=parent_otel_span,
|
||||
current_window_value = (
|
||||
legacy_window_value
|
||||
if inserted
|
||||
else await redis_cache.async_get_cache(
|
||||
key=window_key,
|
||||
parent_otel_span=parent_otel_span,
|
||||
)
|
||||
)
|
||||
if current_window_value is not None:
|
||||
await self.internal_usage_cache.async_set_cache(
|
||||
|
|
@ -1212,9 +1216,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger):
|
|||
|
||||
# Only compute limit_remaining if current_limit is not None
|
||||
limit_remaining = (
|
||||
current_limit - int(effective_counter_value)
|
||||
if effective_counter_value is not None
|
||||
else current_limit
|
||||
current_limit - int(effective_counter_value) if effective_counter_value is not None else current_limit
|
||||
)
|
||||
|
||||
statuses.append(
|
||||
|
|
|
|||
|
|
@ -6359,10 +6359,10 @@ async def test_over_limit_mirror_does_not_reject_after_window_roll(monkeypatch,
|
|||
)
|
||||
assert exc_info.value.status_code == 429
|
||||
|
||||
# After the window boundary (t=59.75, while the stale mirror entry is
|
||||
# still cached) the key must recover immediately instead of being
|
||||
# After the window boundary (strictly past 60s, while the stale mirror
|
||||
# entry is still cached) the key must recover immediately instead of being
|
||||
# rejected from the stale local mirror.
|
||||
time_controller.advance(39.75)
|
||||
time_controller.advance(40.25)
|
||||
await parallel_request_handler.async_pre_call_hook(
|
||||
user_api_key_dict=user_api_key_dict, cache=local_cache, data={}, call_type=""
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue