mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
test: pin the post-#41289 cooldown contract and scroll the auto-router select spec
test_router_fallbacks_with_cooldowns_and_dynamic_credentials expected a caller-supplied credential to register its own deployment and cool it down. #41289 stopped registering it, so cooldown logic skips that id and the assertion can never hold. The test now asserts what the router guarantees today: a 429 to a forwarded credential cools down none of the shared deployments, the next credential is still served, and a 429 owned by a shared deployment still cools it down. The final live OpenAI call becomes a mock The auto-router template spec assumed the Add Auto Router form left room below the Template select at 1280x900. #41315 added classifier fields above it, so the options opened upward. The spec now scrolls the trigger to the top of the dialog and asserts it sits in the upper half before checking placement
This commit is contained in:
parent
02ced74540
commit
c6023b4eec
2 changed files with 23 additions and 28 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue