2026-11-10 23:56:50 +08:00
|
|
|
async def test_readiness_distinguishes_protocol_and_drain_from_gpu_capacity(system):
|
2026-11-14 14:07:26 +08:00
|
|
|
assert (await system.client.get("/api/live")).status_code == 200
|
|
|
|
|
|
|
|
|
|
async def capabilities():
|
|
|
|
|
return {"protocol_version": 2, "admission_policy": True}
|
|
|
|
|
|
|
|
|
|
system.provider.upstream_capabilities = capabilities
|
|
|
|
|
response = await system.client.get("/api/ready")
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|
|
async def old_protocol():
|
|
|
|
|
return {"protocol_version": 1}
|
|
|
|
|
|
|
|
|
|
system.provider.upstream_capabilities = old_protocol
|
|
|
|
|
assert (await system.client.get("/api/ready")).status_code == 503
|
|
|
|
|
assert (await system.client.get("/api/live")).status_code == 200
|
|
|
|
|
system.provider.upstream_capabilities = capabilities
|
|
|
|
|
system.app.state.draining = True
|
|
|
|
|
assert (await system.client.get("/api/ready")).status_code == 503
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_editor_capability_explicitly_advertises_compatible_schema(system):
|
|
|
|
|
value = (await system.client.get("/api/capabilities")).json()
|
2026-11-26 21:06:27 +08:00
|
|
|
assert value["editable_production"]["schema_version"] == 1
|
2026-11-30 09:12:58 +08:00
|
|
|
assert value["editable_production"]["supported_schema_versions"] == [1, 2, 3]
|
|
|
|
|
assert value["editable_production"]["story_schema_versions"] == [3, 4, 5]
|
2026-11-10 23:56:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_maintenance_keeps_reads_and_login_but_blocks_draft_writes(system):
|
2026-11-14 14:07:26 +08:00
|
|
|
marker = system.settings.state_root / "maintenance"
|
|
|
|
|
marker.write_text("upgrade")
|
|
|
|
|
assert (await system.client.get("/api/auth/me")).status_code == 200
|
|
|
|
|
response = await system.client.post("/api/workflows", json={})
|
|
|
|
|
assert response.status_code == 503 and response.json()["detail"]["code"] == "maintenance"
|
|
|
|
|
assert (await system.client.get("/api/live")).status_code == 200
|