Refine health checks and add polling animation
This commit is contained in:
@@ -6,25 +6,27 @@ from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_liveness_ok():
|
||||
response = client.get("/healthz")
|
||||
response = client.get("/health/live")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "ok"
|
||||
assert data["service"] == "backend"
|
||||
assert data["environment"]
|
||||
assert response.text == "live"
|
||||
|
||||
|
||||
def test_readiness_ok():
|
||||
response = client.get("/readyz")
|
||||
response = client.get("/health/ready")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "ok"
|
||||
assert response.text == "ready"
|
||||
|
||||
def test_detailed_health_pass():
|
||||
resp = client.get("/health")
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["status"] == "pass"
|
||||
assert isinstance(body["checks"], dict)
|
||||
|
||||
@given(st.text(min_size=0, max_size=16))
|
||||
@settings(max_examples=10)
|
||||
def test_health_resilient_to_query_noise(noise: str):
|
||||
resp = client.get("/healthz", params={"noise": noise})
|
||||
resp = client.get("/health/live", params={"noise": noise})
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "ok"
|
||||
assert resp.text == "live"
|
||||
|
||||
Reference in New Issue
Block a user