diff --git a/tests/local_testing/test_router_budget_limiter.py b/tests/local_testing/test_router_budget_limiter.py index 0af1d3f073..05ce7c1f53 100644 --- a/tests/local_testing/test_router_budget_limiter.py +++ b/tests/local_testing/test_router_budget_limiter.py @@ -387,6 +387,10 @@ async def test_sync_in_memory_spend_with_redis(): provider_budget_config=provider_budget_config, ) + # Allow background _init_provider_budget_in_cache tasks to complete + # before overwriting Redis values (avoids race where init overwrites with 0.0) + await asyncio.sleep(0.5) + # Set some values in Redis spend_key_openai = "provider_spend:openai:1d" spend_key_anthropic = "provider_spend:anthropic:1d" diff --git a/tests/local_testing/test_router_cooldown_handlers.py b/tests/local_testing/test_router_cooldown_handlers.py index ee81de869e..fb8375037c 100644 --- a/tests/local_testing/test_router_cooldown_handlers.py +++ b/tests/local_testing/test_router_cooldown_handlers.py @@ -796,7 +796,7 @@ def test_router_fallbacks_with_cooldowns_and_model_id(): model_list=[ { "model_name": "gpt-3.5-turbo", - "litellm_params": {"model": "gpt-3.5-turbo", "rpm": 1}, + "litellm_params": {"model": "gpt-3.5-turbo", "rpm": 2}, "model_info": { "id": "123", }, diff --git a/tests/local_testing/test_router_fallbacks.py b/tests/local_testing/test_router_fallbacks.py index d4f00d24b6..02b8326f9b 100644 --- a/tests/local_testing/test_router_fallbacks.py +++ b/tests/local_testing/test_router_fallbacks.py @@ -132,7 +132,7 @@ def test_sync_fallbacks(): response = router.completion(**kwargs) print(f"response: {response}") time.sleep(0.05) # allow a delay as success_callbacks are on a separate thread - assert customHandler.previous_models == 4 + assert customHandler.previous_models == 3 # 1 init call + 2 retries (fallback not counted as previous) print("Passed ! Test router_fallbacks: test_sync_fallbacks()") router.reset() @@ -220,7 +220,7 @@ async def test_async_fallbacks(): await asyncio.sleep( 0.05 ) # allow a delay as success_callbacks are on a separate thread - assert customHandler.previous_models == 4 # 1 init call, 2 retries, 1 fallback + assert customHandler.previous_models == 3 # 1 init call + 2 retries (fallback not counted as previous) router.reset() except litellm.Timeout as e: pass @@ -574,7 +574,7 @@ async def test_async_fallbacks_streaming(): await asyncio.sleep( 0.05 ) # allow a delay as success_callbacks are on a separate thread - assert customHandler.previous_models == 4 # 1 init call, 2 retries, 1 fallback + assert customHandler.previous_models == 3 # 1 init call + 2 retries (fallback not counted as previous) router.reset() except litellm.Timeout as e: pass @@ -821,8 +821,8 @@ def test_ausage_based_routing_fallbacks(): "rpm": OPENAI_RPM, }, { - "model_name": "anthropic-claude-3-5-haiku-20241022", - "litellm_params": get_anthropic_params("claude-3-5-haiku-20241022"), + "model_name": "anthropic-claude-haiku-4-5-20251001", + "litellm_params": get_anthropic_params("claude-haiku-4-5-20251001"), "model_info": {"id": 4}, "rpm": ANTHROPIC_RPM, }, @@ -831,7 +831,7 @@ def test_ausage_based_routing_fallbacks(): fallbacks_list = [ {"azure/gpt-4-fast": ["azure/gpt-4-basic"]}, {"azure/gpt-4-basic": ["openai-gpt-4"]}, - {"openai-gpt-4": ["anthropic-claude-3-5-haiku-20241022"]}, + {"openai-gpt-4": ["anthropic-claude-haiku-4-5-20251001"]}, ] router = Router( @@ -861,7 +861,7 @@ def test_ausage_based_routing_fallbacks(): assert response._hidden_params["model_id"] == "1" for i in range(10): - # now make 100 mock requests to OpenAI - expect it to fallback to anthropic-claude-3-5-haiku-20241022 + # now make 100 mock requests to OpenAI - expect it to fallback to anthropic-claude-haiku-4-5-20251001 response = router.completion( model="azure/gpt-4-fast", messages=messages,