refactor: audit log to Postgres + split /healthz liveness from Pulp status
- 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>
This commit is contained in:
@@ -16,20 +16,27 @@ class _FakeDown:
|
||||
raise httpx.ConnectError("connection refused")
|
||||
|
||||
|
||||
def test_healthz_online():
|
||||
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("/healthz")
|
||||
resp = client.get("/pulp-status")
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
assert resp.status_code == 200
|
||||
assert "연결됨" in resp.text
|
||||
|
||||
|
||||
def test_healthz_offline_when_pulp_down():
|
||||
def test_pulp_status_offline_returns_503():
|
||||
app.dependency_overrides[get_pulp_client] = lambda: _FakeDown()
|
||||
try:
|
||||
resp = client.get("/healthz")
|
||||
resp = client.get("/pulp-status")
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
assert resp.status_code == 503
|
||||
|
||||
Reference in New Issue
Block a user