Loading src/portal_service/api/health.py +5 −5 Changes for src/portal_service/api/health.py: 5 added lines, 5 removed lines. Original line number Diff line number Diff line """ Health probes. Health probes, on the same paths as OEG and SRM. GET /health/live — process is up (liveness) GET /health/ready — the database answers (readiness) GET /healthz — process is up (liveness) GET /readyz — the database answers (readiness) """ Loading @@ -15,12 +15,12 @@ from portal_service.api.dependencies import get_database_health health_router = APIRouter(tags=["health"]) @health_router.get("/health/live") @health_router.get("/healthz") async def live() -> dict[str, str]: return {"status": "alive"} @health_router.get("/health/ready") @health_router.get("/readyz") async def ready( response: Response, database_is_healthy: Annotated[bool, Depends(get_database_health)], Loading tests/test_misc.py +7 −7 Changes for tests/test_misc.py: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -6,34 +6,34 @@ from fastapi import FastAPI from fastapi.testclient import TestClient def test_health_live(client_none: TestClient) -> None: r = client_none.get("/health/live") def test_healthz(client_none: TestClient) -> None: r = client_none.get("/healthz") assert r.status_code == 200 assert r.json() == {"status": "alive"} def test_health_ready_is_503_when_database_unreachable(app_none: FastAPI) -> None: def test_readyz_is_503_when_database_unreachable(app_none: FastAPI) -> None: # `with` runs the lifespan, which builds the engine (without connecting). with TestClient(app_none) as client: r = client.get("/health/ready") r = client.get("/readyz") assert r.status_code == 503 assert r.json() == {"status": "unavailable"} def test_request_id_generated_when_absent(client_none: TestClient) -> None: r = client_none.get("/health/live") r = client_none.get("/healthz") rid = r.headers["X-Request-ID"] assert UUID(rid).version == 4 def test_request_id_preserved_when_valid(client_none: TestClient) -> None: valid = "12345678-1234-4234-8234-123456789abc" r = client_none.get("/health/live", headers={"X-Request-ID": valid}) r = client_none.get("/healthz", headers={"X-Request-ID": valid}) assert r.headers["X-Request-ID"] == valid def test_request_id_replaced_when_invalid(client_none: TestClient) -> None: r = client_none.get("/health/live", headers={"X-Request-ID": "not-a-uuid"}) r = client_none.get("/healthz", headers={"X-Request-ID": "not-a-uuid"}) rid = r.headers["X-Request-ID"] assert rid != "not-a-uuid" assert UUID(rid).version == 4 Loading
src/portal_service/api/health.py +5 −5 Changes for src/portal_service/api/health.py: 5 added lines, 5 removed lines. Original line number Diff line number Diff line """ Health probes. Health probes, on the same paths as OEG and SRM. GET /health/live — process is up (liveness) GET /health/ready — the database answers (readiness) GET /healthz — process is up (liveness) GET /readyz — the database answers (readiness) """ Loading @@ -15,12 +15,12 @@ from portal_service.api.dependencies import get_database_health health_router = APIRouter(tags=["health"]) @health_router.get("/health/live") @health_router.get("/healthz") async def live() -> dict[str, str]: return {"status": "alive"} @health_router.get("/health/ready") @health_router.get("/readyz") async def ready( response: Response, database_is_healthy: Annotated[bool, Depends(get_database_health)], Loading
tests/test_misc.py +7 −7 Changes for tests/test_misc.py: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -6,34 +6,34 @@ from fastapi import FastAPI from fastapi.testclient import TestClient def test_health_live(client_none: TestClient) -> None: r = client_none.get("/health/live") def test_healthz(client_none: TestClient) -> None: r = client_none.get("/healthz") assert r.status_code == 200 assert r.json() == {"status": "alive"} def test_health_ready_is_503_when_database_unreachable(app_none: FastAPI) -> None: def test_readyz_is_503_when_database_unreachable(app_none: FastAPI) -> None: # `with` runs the lifespan, which builds the engine (without connecting). with TestClient(app_none) as client: r = client.get("/health/ready") r = client.get("/readyz") assert r.status_code == 503 assert r.json() == {"status": "unavailable"} def test_request_id_generated_when_absent(client_none: TestClient) -> None: r = client_none.get("/health/live") r = client_none.get("/healthz") rid = r.headers["X-Request-ID"] assert UUID(rid).version == 4 def test_request_id_preserved_when_valid(client_none: TestClient) -> None: valid = "12345678-1234-4234-8234-123456789abc" r = client_none.get("/health/live", headers={"X-Request-ID": valid}) r = client_none.get("/healthz", headers={"X-Request-ID": valid}) assert r.headers["X-Request-ID"] == valid def test_request_id_replaced_when_invalid(client_none: TestClient) -> None: r = client_none.get("/health/live", headers={"X-Request-ID": "not-a-uuid"}) r = client_none.get("/healthz", headers={"X-Request-ID": "not-a-uuid"}) rid = r.headers["X-Request-ID"] assert rid != "not-a-uuid" assert UUID(rid).version == 4