배포 컨테이너 self-test API — CI 통과 != 배포 환경 정상 #73
Labels
No labels
api
bug
chore
collector
decision-needed
docs
enhancement
feature
feedback-loop
frontend
infra
skill
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
xhh/financial-data-platform#73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
동기
현재 CI 는 PR / push 시점에 Forgejo Runner 위에서
pytest를 돌려 코드의정합성을 검증한다. 그러나 실제 배포된 컨테이너가 동일한 환경에서 통과
상태인지 는 별도로 보장되지 않는다.
차이가 생길 수 있는 지점:
uv sync --frozen)PYTHONPATH=/app/src,HOME=/home/app,chmod -R a+rX등)Base.metadata.create_alllifespan 훅) 의 실제 거동가설: PR CI 가 초록불이어도 같은 코드를 배포 환경에서 다시 돌렸을 때
실패할 수 있는 케이스가 존재. 이 격차를 운영 도구에서 즉시 감지·검증할
수단이 필요.
제안
1. 배포 컨테이너 안에서 self-test 를 돌리는 API
pytest -m smoke(또는 별도 작은 마커) 를subprocess 로 실행하고 결과를 메모리/DB 에 저장
exit_code,passed,failed,duration_ms,started_at,commit)2. 실행 모드
POST /api/system/selftest(write + private origin 게이트)deploy.yml워크플로 마지막 단계에서 컨테이너 안의selftest 를 호출하고 실패 시 deploy 실패 처리.
/api/version검증 다음단계로 추가
3. 보안·자원 고려
(lock 파일 또는 in-memory flag)
data/financial_data.db를 건드리지 않도록 in-memory SQLite +API_AUTH_DISABLED강제. 운영 DB 격리 필수-m smoke). 외부 fetch/write 는 별도/api/system/selftest/integration로 분리하고 그건 사용 안 함이 기본require_private_origin+require_scope("write")— 공개 인터넷차단
4. 마커 정의
pyproject.toml[tool.pytest.ini_options]에markers = ["smoke: 빠른 self-test, 외부 I/O 없음"]. 기존 122 case 중 외부 I/O 없는 것 전부 또는대표 핵심 (api 라우터 happy path + post_then_get 회귀) 만 선택. 1초 이내
완료 목표.
5. 선택지
pytest 의존성 + 테스트 코드 동봉이 필요 (이미지 크기 ↑)
운영 이미지 가벼움 유지. compose 복잡도 ↑
주요 라우트 200 OK). pytest 미실행 → 진짜 회귀 누수 가능
추천: A 부터 — 이미지 크기는 #13 에서 별도 다룸. self-test 코드와 운영
코드의 거리가 0 이라 가장 정직.
관련
/api/version과 동일 카테고리 — 배포 정합성 검증의 다음 단계우선순위
낮음 — Phase 1 게이트(#7) 통과 후 운영 안정화 단계에서 검토.