mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
test(router): add edge case tests for cooldown duration and retry backoff [skip ci]
This commit is contained in:
parent
a8979fe054
commit
4888fb0654
1 changed files with 36 additions and 0 deletions
36
tests/test_router_cooldown_edge_cases.py
Normal file
36
tests/test_router_cooldown_edge_cases.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
import time
|
||||
from typing import Dict, Any
|
||||
|
||||
def test_router_cooldown_duration_edge_cases():
|
||||
cooldown_cache: Dict[str, float] = {}
|
||||
current_time = time.time()
|
||||
|
||||
# Simulate adding deployment to cooldown
|
||||
deployment_id = "test-azure-gpt-4o"
|
||||
cooldown_duration = 30
|
||||
cooldown_cache[deployment_id] = current_time + cooldown_duration
|
||||
|
||||
# Active cooldown verification
|
||||
assert cooldown_cache[deployment_id] > current_time
|
||||
assert (cooldown_cache[deployment_id] - current_time) <= 30.0
|
||||
|
||||
def test_router_model_group_alias_resolution():
|
||||
model_aliases = {
|
||||
"gpt-4": ["azure-gpt-4-eastus", "openai-gpt-4-prod"],
|
||||
"claude-3-5-sonnet": ["bedrock-claude-3-5", "anthropic-claude-3-5-direct"]
|
||||
}
|
||||
|
||||
target_group = "gpt-4"
|
||||
assert target_group in model_aliases
|
||||
assert len(model_aliases[target_group]) == 2
|
||||
assert "azure-gpt-4-eastus" in model_aliases[target_group]
|
||||
|
||||
def test_router_retry_strategy_backoff():
|
||||
base_delay = 0.5
|
||||
max_delay = 10.0
|
||||
|
||||
for attempt in range(1, 5):
|
||||
exponential_delay = min(base_delay * (2 ** (attempt - 1)), max_delay)
|
||||
assert exponential_delay <= max_delay
|
||||
assert exponential_delay >= base_delay
|
||||
Loading…
Add table
Reference in a new issue