Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: pin the post-#41289 cooldown contract and scroll the auto-router select spec

Yuneng Jiangc6023b4eec89
diff --git a/tests/e2e/ui/tests/modelsPage/autoRouterTemplateSelect.spec.ts b/tests/e2e/ui/tests/modelsPage/autoRouterTemplateSelect.spec.ts
index 51df50a2e68..d7efd719643 100644
--- a/tests/e2e/ui/tests/modelsPage/autoRouterTemplateSelect.spec.ts
+++ b/tests/e2e/ui/tests/modelsPage/autoRouterTemplateSelect.spec.ts
@@ -47,9 +47,11 @@ test.describe("Auto Router template select anchoring", () => {
test.use({ storageState: ADMIN_STORAGE_PATH });
test("opens the options below the trigger when there is room below it", async ({ page }) => {
- await page.setViewportSize({ width: 1280, height: 900 });
+ const viewport = { width: 1280, height: 900 };
+ await page.setViewportSize(viewport);
const trigger = await openTemplateSelect(page);
- await trigger.scrollIntoViewIfNeeded();
+ await trigger.evaluate((element) => element.scrollIntoView({ block: "start" }));
+ await expect.poll(async () => (await trigger.boundingBox())?.y).toBeLessThan(viewport.height / 2);
await trigger.click();
await expect(page.getByRole("listbox")).toBeVisible();
diff --git a/tests/local_testing/test_router_cooldown_handlers.py b/tests/local_testing/test_router_cooldown_handlers.py
index e1e3df1e4a5..0ec9623538a 100644
--- a/tests/local_testing/test_router_cooldown_handlers.py
+++ b/tests/local_testing/test_router_cooldown_handlers.py
@@ -833,45 +833,38 @@ def test_router_fallbacks_with_cooldowns_and_model_id():
@pytest.mark.asyncio()
async def test_router_fallbacks_with_cooldowns_and_dynamic_credentials():
"""
- Ensure cooldown on credential 1 does not affect credential 2
+ A 429 answered to a caller-supplied credential cools down none of the shared deployments,
+ so the next credential still reaches them, while a 429 owned by a shared deployment does
"""
from litellm.router_utils.cooldown_handlers import _async_get_cooldown_deployments
- litellm._turn_on_debug()
router = Router(
model_list=[
{
"model_name": "gpt-3.5-turbo",
- "litellm_params": {"model": "gpt-3.5-turbo", "rpm": 1},
- "model_info": {
- "id": "123",
- },
+ "litellm_params": {"model": "gpt-3.5-turbo"},
+ "model_info": {"id": deployment_id},
}
- ]
+ for deployment_id in ("123", "456")
+ ],
+ num_retries=0,
)
+ messages = [{"role": "user", "content": "hi"}]
- ## trigger ratelimit
- try:
+ with pytest.raises(litellm.RateLimitError):
await router.acompletion(
- model="gpt-3.5-turbo",
- messages=[{"role": "user", "content": "hi"}],
- api_key="my-bad-key-1",
- mock_response="litellm.RateLimitError",
+ model="gpt-3.5-turbo", messages=messages, api_key="my-bad-key-1", mock_response="litellm.RateLimitError"
)
- pytest.fail("Expected RateLimitError")
- except litellm.RateLimitError:
- pass
-
await asyncio.sleep(1)
+ assert await _async_get_cooldown_deployments(litellm_router_instance=router, parent_otel_span=None) == []
- cooldown_list = await _async_get_cooldown_deployments(
- litellm_router_instance=router, parent_otel_span=None
+ response = await router.acompletion(
+ model="gpt-3.5-turbo", messages=messages, api_key="my-good-key-2", mock_response="served with credential 2"
)
- print("cooldown_list: ", cooldown_list)
- assert len(cooldown_list) == 1
+ assert response.choices[0].message.content == "served with credential 2"
- await router.acompletion(
- model="gpt-3.5-turbo",
- api_key=os.getenv("OPENAI_API_KEY"),
- messages=[{"role": "user", "content": "hi"}],
- )
+ with pytest.raises(litellm.RateLimitError):
+ await router.acompletion(model="gpt-3.5-turbo", messages=messages, mock_response="litellm.RateLimitError")
+ await asyncio.sleep(1)
+ cooled_down = await _async_get_cooldown_deployments(litellm_router_instance=router, parent_otel_span=None)
+ assert len(cooled_down) == 1 and cooled_down[0] in {"123", "456"}