Skip to content

[TEST] Testcontainers 기반 CI 테스트 환경 구성#9

Merged
minky5004 merged 3 commits into
devfrom
fix/test-ci
May 7, 2026
Merged

[TEST] Testcontainers 기반 CI 테스트 환경 구성#9
minky5004 merged 3 commits into
devfrom
fix/test-ci

Conversation

@minky5004
Copy link
Copy Markdown
Contributor

@minky5004 minky5004 commented May 7, 2026

📝 작업 내용

  • CI 파이프라인에서 테스트가 실행되지 않던 문제를 해결

🔗 관련 이슈 (Related Issues)

Closes #

✅ 체크리스트 (Checklist)

  • 브랜치 이름 규칙을 준수했나요? (예: feat/login)
  • 코딩 컨벤션을 준수했나요?
  • 기능에 대한 테스트 코드를 작성/수행했나요?
  • 불필요한 주석이나 로그(console.log)를 제거했나요?

💬 기타 사항

Summary by CodeRabbit

테스트

  • CI 파이프라인에서 테스트 실행이 별도 단계로 분리됨
  • PostgreSQL과 Redis 컨테이너를 활용한 통합 테스트 인프라 구축
  • 데이터베이스 및 JWT 인증을 위한 테스트 환경 설정 추가

빌드

  • 테스트 의존성 라이브러리 추가

Chores

  • CI/CD 워크플로우 최적화
  • 설정 파일 업데이트

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@minky5004 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 19 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1f3580df-1086-4925-b563-7a7428842be8

📥 Commits

Reviewing files that changed from the base of the PR and between 0be3d7a and ee6b048.

📒 Files selected for processing (3)
  • build.gradle
  • src/test/java/com/example/auctionnotification/testutils/BaseIntegrationTest.java
  • src/test/resources/application-test.yml

Walkthrough

Testcontainers를 이용한 통합 테스트 인프라를 구축합니다. PostgreSQL과 Redis 컨테이너를 자동으로 시작하는 추상 기본 테스트 클래스를 추가하고, 기존 테스트 클래스들을 이를 상속하도록 리팩토링했습니다. CI 워크플로우는 테스트 실행 단계를 분리했습니다.

Changes

Test Infrastructure Setup with Testcontainers

Layer / File(s) Summary
Build Dependencies
build.gradle
Testcontainers PostgreSQL 및 JUnit Jupiter 테스트 의존성을 추가합니다.
Test Configuration
src/main/resources/application-test.yml
test 프로필에 대한 Spring/JPA 설정을 추가합니다. DDL auto 생성-삭제, PostgreSQL 방언, 지연된 datasource 초기화 및 JWT 테스트 비밀키를 설정합니다.
Container Infrastructure
src/test/java/com/example/auctionnotification/testutils/BaseIntegrationTest.java
PostgreSQL(v16-alpine)과 Redis(v7-alpine) 컨테이너를 정적 초기화자에서 시작하고 DynamicPropertySource를 통해 Spring에 연결 속성을 등록하는 추상 기본 클래스를 생성합니다.
Test Class Integration
src/test/java/com/example/auctionnotification/AuctionNotificationApplicationTests.java, src/test/java/com/example/auctionnotification/notification/NotificationIntegrationTest.java
기존 테스트 클래스를 BaseIntegrationTest를 상속하도록 리팩토링합니다.
CI Workflow
.github/workflows/ci.yml
테스트 실행 단계를 별도로 분리하고(./gradlew test), 빌드 단계에서 테스트와 asciidoctor를 제외합니다.
Ignore Rules
.gitignore
application-local.yml을 무시 목록에 추가하고 src/test/resources/application-test.yml 규칙을 제거합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • GigaMak2/auction-notification#5: CI 워크플로우를 수정하는 점에서 관련이 있습니다. 해당 PR은 테스트를 건너뛰는 방식이었으나, 이 PR은 테스트 단계를 명시적으로 분리합니다.
  • GigaMak2/auction-notification#8: 통합 테스트 클래스(AuctionNotificationApplicationTests, NotificationIntegrationTest)를 수정하는 점에서 관련이 있습니다.

Suggested reviewers

  • soomin0209
  • imprity
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 PR의 주요 변경 사항인 Testcontainers 기반 테스트 환경 구성을 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명은 필수 템플릿 항목들을 포함하고 있으나, 관련 이슈 번호가 명시되지 않았습니다.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-ci

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/java/com/example/auctionnotification/testutils/BaseIntegrationTest.java (1)

11-17: ⚡ Quick win

컨테이너 필드를 final로 선언하세요

postgresredis 필드가 static이지만 final로 선언되지 않아, 하위 클래스에서 재할당이 가능합니다. 정적 초기화 블록에서 시작되는 공유 컨테이너는 불변으로 선언하는 것이 안전합니다.

🛡️ 제안 수정
-    static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>(
+    static final PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>(
             DockerImageName.parse("postgres:16-alpine")
     );

-    static GenericContainer<?> redis = new GenericContainer<>(
+    static final GenericContainer<?> redis = new GenericContainer<>(
             DockerImageName.parse("redis:7-alpine")
     ).withExposedPorts(6379);
🤖 Prompt for 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.

In
`@src/test/java/com/example/auctionnotification/testutils/BaseIntegrationTest.java`
around lines 11 - 17, Make the shared container fields immutable by declaring
the static fields `postgres` and `redis` in `BaseIntegrationTest` as `static
final`; update their declarations so they are initialized once (as they already
are) and cannot be reassigned by subclasses, e.g., change `static
PostgreSQLContainer<?> postgres = ...` and `static GenericContainer<?> redis =
...` to `static final PostgreSQLContainer<?> postgres = ...` and `static final
GenericContainer<?> redis = ...`.
🤖 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 `@src/main/resources/application-test.yml`:
- Around line 1-12: application-test.yml is currently under src/main/resources
and will be packaged into production JAR exposing test secrets and test DB
settings; move the file to src/test/resources so it is only on the test
classpath, and verify the test YAML entries (jwt.secret.key and
spring.jpa.hibernate.ddl-auto) remain identical after the move; update any
build/test configs if they reference the old path.

---

Nitpick comments:
In
`@src/test/java/com/example/auctionnotification/testutils/BaseIntegrationTest.java`:
- Around line 11-17: Make the shared container fields immutable by declaring the
static fields `postgres` and `redis` in `BaseIntegrationTest` as `static final`;
update their declarations so they are initialized once (as they already are) and
cannot be reassigned by subclasses, e.g., change `static PostgreSQLContainer<?>
postgres = ...` and `static GenericContainer<?> redis = ...` to `static final
PostgreSQLContainer<?> postgres = ...` and `static final GenericContainer<?>
redis = ...`.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b5c9c54b-6c77-4bdd-8b8f-331d7f311dd8

📥 Commits

Reviewing files that changed from the base of the PR and between a8c7d50 and 0be3d7a.

📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • .gitignore
  • build.gradle
  • src/main/resources/application-test.yml
  • src/test/java/com/example/auctionnotification/AuctionNotificationApplicationTests.java
  • src/test/java/com/example/auctionnotification/notification/NotificationIntegrationTest.java
  • src/test/java/com/example/auctionnotification/testutils/BaseIntegrationTest.java
💤 Files with no reviewable changes (1)
  • .gitignore

Comment thread src/test/resources/application-test.yml
Copy link
Copy Markdown
Collaborator

@soomin0209 soomin0209 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@minky5004 minky5004 merged commit 0dfb5fd into dev May 7, 2026
2 of 3 checks passed
@minky5004 minky5004 added BugFix 버그를 고쳤습니다 Setting 개발환경 설정 labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugFix 버그를 고쳤습니다 Setting 개발환경 설정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants