test(router): add edge case tests for cooldown duration and retry backoff [skip ci]

This commit is contained in:
Kartik Chilkoti 2026-09-16 14:53:59 +05:30
parent a8979fe054
commit 4888fb0654

View 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