Skip to content

test: 통합 테스트를 공용 컨테이너로 통일하고 PR 테스트 CI 추가 - #141

Merged
ff1451 merged 2 commits into
mainfrom
refactor/test-infra
Oct 16, 2026
Merged

ff1451 merged 2 commits into
mainfrom
refactor/test-infra

Conversation

@ff1451

@ff1451 ff1451 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

요약

리팩토링을 시작하기 전에 테스트를 믿을 수 있게 만드는 PR이다. 프로덕션 코드는 바꾸지 않는다.

  1. 예약 테스트 29건 상시 실패 수정: ReservationIntegrationTestSupport가 @Testcontainers/@Container를 써서 테스트 클래스가 끝날 때마다 Postgres 컨테이너를 내렸다. Spring은 같은 설정의 컨텍스트를 다음 클래스에서 재사용하므로, 두 번째 예약 테스트 클래스부터 내려간 컨테이너 포트로 접속하다 Connection refused로 실패했다(전체 실행 시 예약 테스트 6개 클래스 29건 실패).
  2. 컨테이너 통일: 각자 컨테이너를 띄우던 테스트 8개(auth 4, member 3, 컨텍스트 로딩 1)와 예약 기반 클래스가 모두 IntegrationTestSupport(싱글턴 컨테이너)를 상속한다. 테스트 코드 약 180줄 감소.
  3. 테스트 간 격리: 모든 통합 테스트가 같은 DB를 쓰게 되어, 한 테스트가 남긴 행이 다른 테스트의 memberRepository.deleteAll()을 FK로 막았다. IntegrationTestSupport가 테스트마다 기준 데이터(track, position, dues_exemption_reason)와 Flyway 이력을 뺀 전 테이블을 TRUNCATE ... CASCADE한다. ID 시퀀스는 리셋하지 않는다 — 메모리 요청 제한기가 회원 ID를 키로 써서, 리셋하면 테스트 간 429가 난다.
  4. CI 추가: main/develop 대상 PR에서 ./gradlew test를 돌린다. 실패 시 테스트 리포트를 아티팩트로 올린다. 배포 워크플로(deploy.yml)는 건드리지 않았다.

테스트

  • 로컬 전체 ./gradlew test: 532건 중 531 통과, 1 스킵(실제 신한 xlsx가 필요한 인수 테스트). 수정 전에는 29건 실패.

Summary by CodeRabbit

  • CI
    • Added automated test runs for pull requests targeting main or develop. Failed runs retain test reports for seven days.
  • Tests
    • Integration tests now share a common setup that resets test data between runs while preserving migration-seeded data.

- 예약 테스트 기반 클래스가 @container로 클래스마다 컨테이너를 내렸다 올려, 재사용된
  Spring 컨텍스트가 내려간 DB에 접속하면서 예약 테스트 29건이 실패하던 문제를 고친다.
- 각자 컨테이너를 띄우던 테스트 8개도 IntegrationTestSupport를 상속하게 한다.
- 모든 통합 테스트가 같은 DB를 쓰므로, 테스트마다 기준 데이터(track, position,
  dues_exemption_reason)를 뺀 전 테이블을 TRUNCATE해 실행 순서와 무관하게 만든다.
- main/develop 대상 PR에서 ./gradlew test를 돌리는 CI 워크플로를 추가한다.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a89e5292-f37d-48d3-842e-4d10de9716e9
📥 Commits

Reviewing files that changed from the base of the PR and between 2fe4b62 and 4b66fc6.

📒 Files selected for processing: 1
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/IntegrationTestSupport.java

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59e16478-96f0-4869-ba8a-4b781e7af698
📥 Commits

Reviewing files that changed from the base of the PR and between eb99560 and 2fe4b62.

📒 Files selected for processing: 11
  • .github/workflows/ci.yml
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/BcsdInternalApiV2ApplicationTests.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/IntegrationTestSupport.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/auth/InitialSetupIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/auth/LoginIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/auth/PasswordResetIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/auth/RefreshTokenIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/member/AdminMemberIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/member/AdminMemberWelcomeMailIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/member/MemberDirectoryIntegrationTest.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/reservation/ReservationIntegrationTestSupport.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The pull-request workflow runs the Gradle test task. Integration tests now share Spring and PostgreSQL setup, with public application tables reset before each test.

Changes: Test Infrastructure

Layer / File(s) Summary
Shared database reset
src/test/java/com/bcsdlab/bcsdinternalapiv2/IntegrationTestSupport.java
IntegrationTestSupport preserves Flyway history and seeded tables, then truncates other public tables with CASCADE before each test.
Integration test adoption
src/test/java/.../BcsdInternalApiV2ApplicationTests.java, src/test/java/.../auth/*IntegrationTest.java, src/test/java/.../member/*IntegrationTest.java, src/test/java/.../reservation/ReservationIntegrationTestSupport.java
Integration test classes extend IntegrationTestSupport and remove their duplicated local Spring, PostgreSQL Testcontainers, JWT, and MockMvc setup.
Pull-request test workflow
.github/workflows/ci.yml
The workflow runs tests for pull requests targeting main or develop, cancels earlier runs for the same pull request, and uploads test reports on failure.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: kongwoojin

Merge Risk: ⚪ Minimal · up to 2fe4b

No actionable issue remains from this review; the PR is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 10 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes both main changes: standardizing integration tests on a shared container and adding pull request test CI.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 10 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

컨텍스트마다 커넥션 풀을 잡아, 테스트 컨텍스트가 늘면 기본 상한(100)을 넘어
'too many clients already'로 컨텍스트 로딩이 실패한다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant