[Test] Postgres 체크포인터 통합 테스트 + docker-compose 서비스#69
Conversation
- pyproject: postgres 마커 등록 (Daytona용 integration과 분리) - tests/integration/test_postgres_checkpoint.py: 새 연결로 2턴 호출해 PG 역직렬화(CreditEntry/PlanStep 타입 복원)·멀티턴 누적·턴 단위 정산 검증. DATABASE_URL 없으면 skip - docker-compose.test.yml: 격리된 postgres(healthcheck) + test-pg 러너 추가 → docker compose -f docker-compose.test.yml run --rm --build test-pg 기본 스위트(-m "not integration")는 DB 없이 통과 (postgres 테스트 skip). 로컬 Postgres로 통합 테스트 2개 통과 확인.
Postgres E2E를 Docker에서 돌리는 과정에서 발견된 Dockerfile.test 빌드 실패 수정: - .dockerignore: 호스트 산물 .venv, 중첩 *.egg-info, __pycache__ 제외 (이미지로 복사되면 uv sync editable 빌드가 권한 충돌) - Dockerfile.test: chown을 COPY 이후로 이동 — 복사 파일을 appuser 소유로 만들어 uv sync가 src/*.egg-info를 생성할 수 있게 docker compose -f docker-compose.test.yml run --rm --build test-pg → 2 passed.
|
Warning Review limit reached
More reviews will be available in 50 minutes and 12 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 Walkthrough둘러보기멀티턴 체크포인터의 Postgres 경로를 검증하기 위해 pytest 마커를 등록하고, Docker 빌드 환경을 정리하며, docker-compose에 격리된 Postgres 테스트 인프라를 추가하고, 상태 복원 및 타입 보존을 검증하는 통합 테스트를 구현했다. 변경 사항Postgres 체크포인터 통합 테스트 추가
시퀀스 다이어그램sequenceDiagram
participant Developer
participant docker-compose
participant postgres_service
participant test-pg_service
participant pytest
Developer->>docker-compose: docker-compose -f docker-compose.test.yml up
docker-compose->>postgres_service: 서비스 시작
postgres_service->>postgres_service: pg_isready 상태 확인
docker-compose->>test-pg_service: 서비스 시작 (postgres 의존)
postgres_service-->>test-pg_service: service_healthy 상태 도달
test-pg_service->>test-pg_service: DATABASE_URL, PYTHONPATH 환경 변수 설정
test-pg_service->>pytest: uv run pytest -m postgres 실행
pytest->>postgres_service: 멀티턴 상태 읽기/쓰기
pytest-->>test-pg_service: 테스트 결과
test-pg_service-->>Developer: 테스트 완료 (통과/실패)
예상 코드 리뷰 노력🎯 3 (보통) | ⏱️ ~20분 시
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
요약
Postgres 체크포인터 통합 테스트와 Docker(chown 순서, .dockerignore) 수정 방향은 적절하며, 턴마다 open_checkpointer로 새 연결을 여는 구성이 운영에서의 재연결·역직렬화 시나리오를 InMemory 테스트보다 잘 검증합니다. CreditEntry/PlanStep의 isinstance 검증은 serde allowlist 회귀에 실질적 가치가 있습니다. 다만 프로덕션 체크포인트 키 형식·CI 자동화·일부 assertion 강도에서 보완 여지가 있습니다.
[문제 1]
- 심각도: Medium
- 범주: 유지보수성
- 근거:
postgres마커 테스트는docker compose -f docker-compose.test.yml run test-pg로만 실행되며,.github/workflows/에는 deploy만 있고-m postgres실행 단계가 없습니다. README도uv run pytest만 안내해, 로컬/CI 기본pytest에서는DATABASE_URL없을 때 skip되므로 serde·PG 역직렬화 회귀가 파이프라인에서 잡히지 않을 수 있습니다. - 수정안: (a) PR 또는 후속으로
services: postgres+pytest -m postgres를 돌리는 GitHub Actions job 추가, 또는 (b) 최소한 README/AGENTS.md에docker compose -f docker-compose.test.yml run --rm --build test-pg실행 방법을 명시.
[문제 2]
- 심각도: Low(추가 확인 필요)
- 범주: 정확성
- 근거: 프로덕션
solve.py는configurable.thread_id에f"{user_id}:{thread_id}"를 사용하지만, 통합 테스트는 rawthread_id만 넘깁니다. 멀티턴·정산 로직 검증은tests/graph/test_multiturn.py와 거의 동일하고, 이 PR의 고유 가치(재연결 + PG serde) 와는 별개로, 네임스페이스된 키·콜론 포함 thread_id에서만 발생하는 이슈는 테스트가 커버하지 않을 수 있습니다. - 수정안:
_run_turn의config를{"configurable": {"thread_id": f"u:{thread_id}"}}처럼 프로덕션과 동일하게 맞추거나, 해당 형식 전용 케이스를 하나 추가.
[문제 3]
- 심각도: Low
- 범주: 정확성
- 근거:
tests/graph/test_multiturn.py의test_multiturn_credit_settled_per_turn은len(settler_msgs) == 2로 턴마다 정산 메시지가 하나씩만 쌓이는지 검증하지만, Postgres 테스트는 마지막 메시지 내용만 검사합니다. PG 복원 후 메시지가 중복·누락되는 버그는 놓칠 수 있습니다. - 수정안:
assert len(settler_msgs) == 2를test_postgres_multiturn_restore_and_per_turn_settlement에도 추가.
리스크 참고(이슈로 분류하지 않음): docker-compose.test.yml의 proovy/proovy 자격 증명은 로컬 격리 테스트용으로 적절해 보입니다. tests/ 볼륨 마운트는 .dockerignore와 맞물려 test-pg에서만 테스트 코드를 주입하는 합리적 선택입니다.
Sent by Cursor Automation: Chowon Reviewer
| depends_on: | ||
| postgres: | ||
| condition: service_healthy | ||
| command: uv run pytest -m postgres -v |
There was a problem hiding this comment.
[Medium · 유지보수성] postgres 마커 테스트가 CI/기본 pytest 경로에 없어 serde·PG 역직렬화 회귀가 수동 docker compose ... test-pg에만 의존합니다.
수정안: GitHub Actions에 postgres 서비스 + pytest -m postgres job 추가, 또는 README/AGENTS.md에 실행 명령을 문서화해 주세요.
| graph = _build(saver) | ||
| return await graph.ainvoke( | ||
| ProovyState(user_id="u", thread_id=thread_id), | ||
| config={"configurable": {"thread_id": thread_id}}, |
There was a problem hiding this comment.
[Low · 정확성 · 추가 확인 필요] 프로덕션은 solve.py에서 checkpoint_thread_id = f"{user_id}:{thread_id}"를 쓰는데, 여기서는 raw thread_id만 사용합니다. 멀티턴·serde 검증 자체는 유효하지만, 네임스페이스된 키 형식에서만 나는 이슈는 커버하지 못할 수 있습니다.
수정안: config를 f"u:{thread_id}" 등 프로덕션과 동일한 형식으로 맞추는 것을 권장합니다.
|
|
||
| # 턴 단위 정산 — turn2는 누적(10)이 아닌 이번 턴 비용(5) | ||
| settler_msgs = [m for m in s2["messages"] if "cr 사용" in str(m.content)] | ||
| assert settler_msgs[-1].content == "총 5.0cr 사용" |
There was a problem hiding this comment.
[Low · 정확성] test_multiturn_credit_settled_per_turn은 len(settler_msgs) == 2로 턴당 정산 메시지 개수도 검증합니다. 마지막 content만 보면 PG 복원 후 메시지 중복/누락 회귀를 놓칠 수 있습니다.
수정안: assert len(settler_msgs) == 2 추가.
- 통합 테스트 체크포인트 키를 프로덕션(solve.py)과 동일하게 user_id 네임스페이스
(f"u:{thread_id}")로 — 네임스페이스 키 경로도 검증
- PG 복원 후 정산 메시지 개수 검증(len==2) 추가 — 중복/누락 회귀 가드
- AGENTS.md에 postgres 통합 테스트 실행법 문서화 (docker compose test-pg /
DATABASE_URL 직접 지정)
skip: CI job 추가 — full-suite는 #67(SSE) 머지 전까지 close()-drain로 red라
별도 후속(팀 CI 조율)으로 권장.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docker-compose.test.yml`:
- Line 12: The pdf-test service may fail to import tests.pdf_node.test_pdf_node
because .dockerignore excludes tests/ and pdf-test doesn't mount the host tests
directory; update the pdf-test service definition (referencing the service name
"pdf-test" and its "working_dir" setting) to mount the tests directory into the
container (e.g. add a volume mapping from ./tests to /app/tests) or
alternatively remove tests/ from .dockerignore so the test files are available
at runtime.
In `@tests/integration/test_postgres_checkpoint.py`:
- Around line 40-47: The _build function lacks type hints; annotate its
signature like def _build(checkpointer: Any) -> Any (or use the actual
Checkpointer and compiled graph types if available) and add the necessary import
(e.g., from typing import Any or the concrete Checkpointer/CompiledGraph types),
ensuring the parameter type for checkpointer and the return type for the result
of builder.compile(checkpointer=checkpointer) are declared; keep the function
body unchanged and prefer concrete types if they exist in the codebase (e.g.,
Checkpointer, StateGraphCompiled).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a669b867-b072-4e8d-b33e-ea2e6bce2187
📒 Files selected for processing (6)
.dockerignoreAGENTS.mdDockerfile.testdocker-compose.test.ymlpyproject.tomltests/integration/test_postgres_checkpoint.py
- docker-compose.test.yml: pdf-test에도 ./tests:/app/tests 마운트 추가. tests/가 .dockerignore로 제외돼 런타임에 모듈을 못 찾던 문제 해소 (docker compose run pdf-test → "테스트 성공!" 확인) - test_postgres_checkpoint.py: _build에 BaseCheckpointSaver → CompiledStateGraph 타입힌트 추가
gaeunee2
left a comment
There was a problem hiding this comment.
도커가 핑핑 잘 돌아간다니 너무 다행이다깡총.


📌 관련 이슈
🏷️ PR 타입
📝 작업 내용
pyproject.toml:postgres마커 등록 (Daytona용integration과 분리)tests/integration/test_postgres_checkpoint.py: 실제 Postgres 통합 테스트 추가CreditEntry/PlanStep이 dict 아닌 정상 Pydantic 타입으로 복원 (serde allowlist 실DB 검증)DATABASE_URL없으면 skip (기본 스위트 영향 없음)docker-compose.test.yml: 격리된postgres(healthcheck) +test-pg러너 서비스 추가Dockerfile.test/.dockerignore빌드 수정 (E2E 과정에서 발견):.venv·중첩*.egg-info·__pycache__제외 — 호스트 산물 복사로 인한uv sync권한 충돌 해소Dockerfile.test의chown을COPY이후로 이동 — 복사 파일을 appuser 소유로 만들어 editable 빌드 가능📸 스크린샷
Docker E2E (
docker compose -f docker-compose.test.yml run --rm --build test-pg):✅ 체크리스트
📎 기타 참고사항
docker compose -f docker-compose.test.yml run --rm --build test-pg.Summary by CodeRabbit
릴리스 노트
Documentation
Tests
Chores