9
async def health(session, call_key):
10
url = "http://0.0.0.0:4000/health"
12
"Authorization": f"Bearer {call_key}",
13
"Content-Type": "application/json",
16
async with session.get(url, headers=headers) as response:
17
status = response.status
18
response_text = await response.text()
20
print(f"Response (Status code: {status}):")
25
raise Exception(f"Request did not return a 200 status code: {status}")
27
return await response.json()
30
async def generate_key(session):
31
url = "http://0.0.0.0:4000/key/generate"
32
headers = {"Authorization": "Bearer sk-1234", "Content-Type": "application/json"}
34
"models": ["gpt-4", "text-embedding-ada-002", "dall-e-2"],
38
async with session.post(url, headers=headers, json=data) as response:
39
status = response.status
40
response_text = await response.text()
46
raise Exception(f"Request did not return a 200 status code: {status}")
47
return await response.json()
51
async def test_health():
55
async with aiohttp.ClientSession() as session:
57
all_healthy_models = await health(session=session, call_key="sk-1234")
59
all_healthy_models["healthy_count"] + all_healthy_models["unhealthy_count"]
61
assert total_model_count > 0
65
async def test_health_readiness():
69
async with aiohttp.ClientSession() as session:
70
url = "http://0.0.0.0:4000/health/readiness"
71
async with session.get(url) as response:
72
status = response.status
73
response_json = await response.json()
76
assert "litellm_version" in response_json
77
assert "status" in response_json
80
raise Exception(f"Request did not return a 200 status code: {status}")
84
async def test_health_liveliness():
88
async with aiohttp.ClientSession() as session:
89
url = "http://0.0.0.0:4000/health/liveliness"
90
async with session.get(url) as response:
91
status = response.status
92
response_text = await response.text()
98
raise Exception(f"Request did not return a 200 status code: {status}")
102
async def test_routes():
106
async with aiohttp.ClientSession() as session:
107
url = "http://0.0.0.0:4000/routes"
108
async with session.get(url) as response:
109
status = response.status
110
response_text = await response.text()
116
raise Exception(f"Request did not return a 200 status code: {status}")