- audit.record_deploy 를 JSONL 파일 → Postgres deploy_audit 테이블로 (재배포 휘발 방지)
- psycopg 지연 import, _write 는 테스트에서 monkeypatch 지점, DATABASE_URL 사용
- 감사 기록 실패는 배포 완료를 막지 않고 UI 경고(audit_ok)
- /healthz: Pulp 무관 라이브니스 {"ok":true} (컨테이너 health check),
Pulp 연결 배지는 /pulp-status 로 분리 (대시보드가 폴링)
- config: DATABASE_URL 추가, audit_log_path 제거
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import httpx
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.main import app, get_pulp_client
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
class _FakeOnline:
|
|
def status(self):
|
|
return {"online": True}
|
|
|
|
|
|
class _FakeDown:
|
|
def status(self):
|
|
raise httpx.ConnectError("connection refused")
|
|
|
|
|
|
def test_healthz_is_liveness_always_ok():
|
|
# Pulp 와 무관하게 앱 생존만 본다 → 항상 200 {"ok": true}
|
|
resp = client.get("/healthz")
|
|
assert resp.status_code == 200
|
|
assert resp.json() == {"ok": True}
|
|
|
|
|
|
def test_pulp_status_online():
|
|
app.dependency_overrides[get_pulp_client] = lambda: _FakeOnline()
|
|
try:
|
|
resp = client.get("/pulp-status")
|
|
finally:
|
|
app.dependency_overrides.clear()
|
|
assert resp.status_code == 200
|
|
assert "연결됨" in resp.text
|
|
|
|
|
|
def test_pulp_status_offline_returns_503():
|
|
app.dependency_overrides[get_pulp_client] = lambda: _FakeDown()
|
|
try:
|
|
resp = client.get("/pulp-status")
|
|
finally:
|
|
app.dependency_overrides.clear()
|
|
assert resp.status_code == 503
|
|
assert "연결 실패" in resp.text
|