Files
litellm/tests/basic_proxy_startup_tests/test_basic_proxy_startup.py
T
Andrew Bernat d89990e0c5 Add license metadata to health/readiness endpoint. (#15997)
* health: expose license metadata (available & expiration) in /health/readiness endpoint

* test: add health readiness license metadata coverage

* test: ensure /health/readiness response includes license metadata

* chore: remove standalone license metadata test as requested; existing test covers codepath

---------

Co-authored-by: Plan42.ai <robot@plan42.ai>
2025-10-28 19:21:54 -07:00

56 lines
1.8 KiB
Python

"""
This test ensures that the proxy starts and serves requests even with a bad license.
in ci/cd config.yml, we set the license to "bad-license"
"""
import pytest
import aiohttp
from typing import Optional
@pytest.mark.asyncio
async def test_health_and_chat_completion():
"""
Test health endpoints and chat completion:
1. Check /health/readiness
2. Check /health/liveness
3. Make a chat completion call
"""
async with aiohttp.ClientSession() as session:
# Test readiness endpoint
async with session.get("http://0.0.0.0:4000/health/readiness") as response:
assert response.status == 200
readiness_response = await response.json()
assert readiness_response["status"] == "connected"
# New assertion: license metadata is present
assert "license" in readiness_response
assert "has_license" in readiness_response["license"]
# Test liveness endpoint
async with session.get("http://0.0.0.0:4000/health/liveness") as response:
assert response.status == 200
liveness_response = await response.json()
print("liveness_response", liveness_response)
# Make a chat completion call
url = "http://0.0.0.0:4000/chat/completions"
headers = {
"Authorization": "Bearer sk-1234",
"Content-Type": "application/json",
}
data = {
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
}
async with session.post(url, headers=headers, json=data) as response:
assert response.status == 200
completion_response = await response.json()
assert "choices" in completion_response