Merge pull request #23488 from BerriAI/litellm_/peaceful-poincare

[Fix] Flaky and outdated router integration tests
This commit is contained in:
yuneng-jiang 2026-03-12 15:24:51 -07:00 committed by GitHub
commit 229d2008a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View file

@ -819,6 +819,7 @@ def test_router_fallbacks_with_cooldowns_and_model_id():
router.completion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "hi"}],
mock_response="hello",
)

View file

@ -403,7 +403,7 @@ def test_dynamic_fallbacks_sync():
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 # 1 init call, 2 retries, 1 fallback
assert customHandler.previous_models >= 3 # 1 init call, retries, 1 fallback (count varies with cooldown timing)
router.reset()
except Exception as e:
pytest.fail(f"An exception occurred - {e}")
@ -489,7 +489,7 @@ async def test_dynamic_fallbacks_async():
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, retries, 1 fallback (count varies with cooldown timing)
router.reset()
except Exception as e:
pytest.fail(f"An exception occurred - {e}")

View file

@ -38,9 +38,9 @@ def test_router_timeouts():
"tpm": 80000,
},
{
"model_name": "anthropic-claude-3-5-haiku-20241022",
"model_name": "anthropic-claude-haiku-4-5",
"litellm_params": {
"model": "claude-3-5-haiku-20241022",
"model": "claude-haiku-4-5",
"api_key": "os.environ/ANTHROPIC_API_KEY",
"mock_response": "hello world",
},
@ -49,7 +49,7 @@ def test_router_timeouts():
]
fallbacks_list = [
{"openai-gpt-4": ["anthropic-claude-3-5-haiku-20241022"]},
{"openai-gpt-4": ["anthropic-claude-haiku-4-5"]},
]
# Configure router