fix(test): 번역 테스트 설정을 전역 컴포넌트 스캔에서 제외한다
This commit is contained in:
@@ -0,0 +1,124 @@
|
|||||||
|
# 관리자 배너 통합 테스트 컨텍스트 오류 구현 계획
|
||||||
|
|
||||||
|
| 문서 항목 | 내용 |
|
||||||
|
|---|---|
|
||||||
|
| 상태 | 구현 완료 |
|
||||||
|
| 작성일 | 2026-11-18 |
|
||||||
|
| 요구사항 기준 | [prd.md](prd.md) |
|
||||||
|
| API 기준 | 해당 없음 |
|
||||||
|
| 현재 Phase | Phase 1: 테스트 설정 스캔 범위 수정 |
|
||||||
|
| 현재 활성 Goal | 없음 |
|
||||||
|
|
||||||
|
## 목표
|
||||||
|
|
||||||
|
관리자 배너 통합 테스트가 테스트 전용 설정의 전역 스캔으로 인한 보안 advisor 중복 없이 실행되도록 한다.
|
||||||
|
|
||||||
|
## 현재 상태
|
||||||
|
|
||||||
|
| Phase | 상태 | 완료 Task | 활성/다음 Goal | 차단 또는 남은 조건 |
|
||||||
|
|---:|---|---:|---|---|
|
||||||
|
| 1 | 완료 | `1/1` | 없음 | 지정 회귀 테스트 통과 |
|
||||||
|
|
||||||
|
## 범위
|
||||||
|
|
||||||
|
### 포함
|
||||||
|
|
||||||
|
- `SelectionCandidateProviderConfiguration`도 전역 스캔에서 제외하되, `TranslationCandidateTestSupport` 등의 명시적 `@Import`는 유지한다.
|
||||||
|
|
||||||
|
- `TranslationSelectionTestConfiguration`을 컴포넌트 스캔에서 제외되는 테스트 컴포넌트로 표시.
|
||||||
|
- 두 관리자 배너 테스트와 해당 설정을 사용하는 번역 선택 테스트 실행.
|
||||||
|
|
||||||
|
### 제외
|
||||||
|
|
||||||
|
- API 또는 애플리케이션 보안 설정 변경.
|
||||||
|
- 테스트 assertion 변경 및 전체 테스트 실행.
|
||||||
|
|
||||||
|
## 기술적 제약 및 검증
|
||||||
|
|
||||||
|
- Spring Boot 2.7.14 및 기존 Kotlin 테스트 설정 패턴을 따른다.
|
||||||
|
- 명시적으로 `TranslationSelectionTestConfiguration`을 지정하는 테스트의 설정 동작을 유지한다.
|
||||||
|
- 테스트는 `--tests`로 대상 클래스를 지정하며 전체 테스트는 사용자가 실행한다.
|
||||||
|
|
||||||
|
### Phase 1: 테스트 설정 스캔 범위 수정
|
||||||
|
|
||||||
|
**Phase 결과:** 테스트 전용 번역 설정이 전역 스캔에 참여하지 않으며, 배너 및 번역 선택 테스트가 통과한다.
|
||||||
|
|
||||||
|
**선행조건:** 제공된 구현 계획의 원인과 수정 지점을 확인한다.
|
||||||
|
|
||||||
|
**Phase 완료 조건:** `P1-T1` 및 `P1-GATE` 완료, 검증 기록 누적.
|
||||||
|
|
||||||
|
### 구현 항목
|
||||||
|
|
||||||
|
- [x] **Task 1.1: 테스트 설정을 컴포넌트 스캔에서 제외**
|
||||||
|
|
||||||
|
**Goal 실행 `P1-T1`:** 두 테스트 전용 설정을 컴포넌트 스캔에서 제외하면서 명시적 테스트 설정 사용은 유지한다.
|
||||||
|
|
||||||
|
- **시작 조건:** 두 관리자 배너 테스트가 컨텍스트 초기화 오류로 실패함을 확인.
|
||||||
|
- **완료 증거:** 최소 설정 변경 및 배너/번역 선택 테스트 통과.
|
||||||
|
- **범위 밖:** API와 보안 설정 변경, 테스트 assertion 완화.
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
|
||||||
|
- Modify: `src/test/kotlin/kr/co/vividnext/sodalive/v2/contenttranslation/application/TranslationSelectionTestConfiguration.kt`
|
||||||
|
- Modify: `src/test/kotlin/kr/co/vividnext/sodalive/v2/contenttranslation/application/TranslationCandidateTestSupport.kt`
|
||||||
|
- Test: `src/test/kotlin/kr/co/vividnext/sodalive/admin/chat/AdminChatBannerControllerIntegrationTest.kt`
|
||||||
|
- Test: `src/test/kotlin/kr/co/vividnext/sodalive/admin/content/banner/AdminContentBannerControllerIntegrationTest.kt`
|
||||||
|
- Test: `src/test/kotlin/kr/co/vividnext/sodalive/v2/contenttranslation/application/TranslationSelectionRequestIntegrationTest.kt`
|
||||||
|
- Test: `src/test/kotlin/kr/co/vividnext/sodalive/v2/contenttranslation/application/TranslationSelectionWorkerIntegrationTest.kt`
|
||||||
|
- Test: `src/test/kotlin/kr/co/vividnext/sodalive/v2/contenttranslation/application/TranslationSelectionCandidateLifecycleIntegrationTest.kt`
|
||||||
|
- Test: `src/test/kotlin/kr/co/vividnext/sodalive/v2/contenttranslation/adapter/in/web`의 `TranslationSelectionHttpTestSupport` 하위 테스트
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
|
||||||
|
- Consumes: Spring Boot의 `@TestComponent` 스캔 제외 동작.
|
||||||
|
- Produces: 앱 전체 `@SpringBootTest`에는 포함되지 않고 명시적 `classes = [TranslationSelectionTestConfiguration::class]`에서는 계속 로드되는 설정.
|
||||||
|
|
||||||
|
- [x] **RED:** 기존 두 관리자 배너 통합 테스트를 재현 테스트로 사용한다. 추가 테스트 없이 실제 테스트의 컨텍스트 로딩 실패를 확인했다.
|
||||||
|
- [x] **RED 확인:** `./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.admin.chat.AdminChatBannerControllerIntegrationTest' --tests 'kr.co.vividnext.sodalive.admin.content.banner.AdminContentBannerControllerIntegrationTest'` 실행 결과 73개가 `BeanDefinitionOverrideException`을 포함한 컨텍스트 초기화 실패로 종료했다.
|
||||||
|
- [x] **GREEN:** `TranslationSelectionTestConfiguration`에 `@TestComponent`를 추가한다.
|
||||||
|
- [x] **GREEN:** `SelectionCandidateProviderConfiguration`에도 `@TestComponent`를 추가하고, 명시적 `@Import` 사용을 유지한다.
|
||||||
|
- [x] **GREEN 확인:** 위 배너 테스트와 설정을 사용하는 번역 선택 테스트를 실행해 통과를 확인한다.
|
||||||
|
- [x] **REFACTOR:** 변경 범위의 직접 영향 회귀 테스트를 실행하고 결과를 아래 Progress에 기록한다.
|
||||||
|
|
||||||
|
### 완료 조건
|
||||||
|
|
||||||
|
- [x] `P1-T1`의 실행 체크박스와 완료 증거가 충족됐다.
|
||||||
|
- [x] 전역 앱 컨텍스트와 명시적 번역 테스트 컨텍스트의 설정 경계가 검증됐다.
|
||||||
|
|
||||||
|
### 검증 방법
|
||||||
|
|
||||||
|
#### Phase 1 Gate
|
||||||
|
|
||||||
|
**Goal 실행 `P1-GATE`:** 배너 테스트와 테스트 전용 설정을 사용하는 번역 선택 회귀 범위를 검증한다.
|
||||||
|
|
||||||
|
- **Objective:** 전역 스캔 제외 및 명시적 테스트 설정 사용이 모두 확인된 상태로 작업을 마친다.
|
||||||
|
- **시작 조건:** `P1-T1` 완료.
|
||||||
|
- **완료 증거:** 두 배너 테스트와 설정 사용 번역 테스트 통과, 검증 결과 기록.
|
||||||
|
- **범위 밖:** 전체 테스트 실행.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.admin.chat.AdminChatBannerControllerIntegrationTest' --tests 'kr.co.vividnext.sodalive.admin.content.banner.AdminContentBannerControllerIntegrationTest'
|
||||||
|
./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.application.TranslationSelectionRequestIntegrationTest' --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.application.TranslationSelectionWorkerIntegrationTest' --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.adapter.in.web.AdminTranslationSelectionContentsHttpIntegrationTest' --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.adapter.in.web.TranslationSelectionActivationHttpIntegrationTest' --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.adapter.in.web.AdminTranslationSelectionApplyHttpIntegrationTest' --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.adapter.in.web.AdminTranslationSelectionReceiptHttpIntegrationTest'
|
||||||
|
./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.application.TranslationSelectionCandidateLifecycleIntegrationTest'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Expected:** 모든 지정 테스트 성공. 전체 테스트는 사용자가 `./gradlew test`로 실행한다.
|
||||||
|
|
||||||
|
## Progress
|
||||||
|
|
||||||
|
- RED: 배너 테스트 73개가 공통으로 컨텍스트 초기화 실패. 구현 전 재현.
|
||||||
|
- GREEN: `TranslationSelectionTestConfiguration`에 `@TestComponent`를 추가. 실행 후 결과를 이어서 기록한다.
|
||||||
|
|
||||||
|
### `P1-T1` 1차 실행 — 2026-11-18
|
||||||
|
|
||||||
|
- 상태: 완료
|
||||||
|
- 무엇을: 두 테스트 전용 설정(`TranslationSelectionTestConfiguration`, `SelectionCandidateProviderConfiguration`)에 `@TestComponent` 추가.
|
||||||
|
- 왜: 1차 수정 후 재실행 시 `metaDataSourceAdvisor` 충돌은 사라졌지만, 전역 스캔된 `SelectionCandidateProviderConfiguration`의 `SelectionPapagoProvider`가 운영 `PapagoTranslationService`와 `PAPAGO` ID가 겹쳐 `LanguageProviderProperties.kt:18`의 `duplicate registered language provider name` 예외가 발생했다.
|
||||||
|
- 어떻게:
|
||||||
|
- `./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.admin.chat.AdminChatBannerControllerIntegrationTest' --tests 'kr.co.vividnext.sodalive.admin.content.banner.AdminContentBannerControllerIntegrationTest'` (1차 수정만 적용) — 실패, provider ID 중복 예외 및 600초 timeout.
|
||||||
|
- `./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.admin.chat.AdminChatBannerControllerIntegrationTest'` — 성공.
|
||||||
|
- `./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.admin.content.banner.AdminContentBannerControllerIntegrationTest'` — 성공.
|
||||||
|
- Phase 1 Gate의 번역 선택 회귀 6개 클래스 명령 — 성공.
|
||||||
|
- `./gradlew --no-daemon test --tests 'kr.co.vividnext.sodalive.v2.contenttranslation.application.TranslationSelectionCandidateLifecycleIntegrationTest'` — 성공.
|
||||||
|
- `git diff --check` — 공백 오류 없음.
|
||||||
|
- 남은 항목: 전체 테스트는 미실행. 사용자가 `./gradlew test`로 직접 실행한다.
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# 관리자 배너 통합 테스트 컨텍스트 오류 PRD
|
||||||
|
|
||||||
|
## 문서 정보
|
||||||
|
|
||||||
|
| 항목 | 내용 |
|
||||||
|
|---|---|
|
||||||
|
| 문서 상태 | 구현 완료 |
|
||||||
|
| 작성일 | 2026-11-18 |
|
||||||
|
| 최종 수정일 | 2026-11-18 |
|
||||||
|
| 대상 제품 | 관리자 배너 통합 테스트 |
|
||||||
|
| 작성자·결정권자 | 사용자 요청 및 제공된 구현 계획 |
|
||||||
|
| 관련 API Contract | 해당 없음 (공개 API 변경 없음) |
|
||||||
|
| 관련 구현 계획 | [plan-task.md](plan-task.md) |
|
||||||
|
| 관련 review | 없음 |
|
||||||
|
|
||||||
|
### 요구사항 상태
|
||||||
|
|
||||||
|
| ID | 상태 | 요구사항 | 구현 처리 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `REQ-001` | 확정 | 테스트 전용 번역 설정은 앱의 전역 컴포넌트 스캔에서 제외하되, 해당 설정을 지정하는 번역 테스트에서는 계속 사용할 수 있어야 한다. | `plan-task.md`의 `P1-T1` 및 테스트 증거로 추적 |
|
||||||
|
|
||||||
|
## 1. Overview
|
||||||
|
|
||||||
|
관리자 채팅 배너와 콘텐츠 배너 통합 테스트는 테스트 전용 설정들이 전역 컴포넌트 스캔에 참여해 Spring 컨텍스트를 생성하지 못한다. 테스트 전용 설정들을 전역 스캔에서 제외한다.
|
||||||
|
|
||||||
|
## 2. Problem Statement
|
||||||
|
|
||||||
|
- `SelectionCandidateProviderConfiguration`도 테스트 클래스패스에서 전역 스캔되어 `SelectionPapagoProvider`를 등록하고, 운영 `PAPAGO` provider와 ID가 중복된다.
|
||||||
|
|
||||||
|
- 두 배너 통합 테스트는 각 테스트 실행에서 Spring 컨텍스트 초기화 중 `BeanDefinitionOverrideException`으로 실패한다.
|
||||||
|
- 테스트 전용 `TranslationSelectionTestConfiguration`이 앱 패키지 아래의 `@Configuration`으로 탐색되어 애플리케이션 보안 설정과 중복 등록된다.
|
||||||
|
- 해결 여부는 두 배너 테스트와 해당 설정을 명시적으로 사용하는 번역 선택 테스트의 통과로 판단한다.
|
||||||
|
|
||||||
|
## 3. Goals
|
||||||
|
|
||||||
|
- 테스트 전용 설정을 전체 애플리케이션의 컴포넌트 스캔에서 제외한다.
|
||||||
|
- 번역 선택 테스트가 해당 설정을 직접 지정할 때는 기존 테스트 구성을 계속 사용한다.
|
||||||
|
- 관리자 배너 테스트와 영향받는 번역 선택 테스트를 실행해 결과를 확인한다.
|
||||||
|
|
||||||
|
## 4. Non-Goals
|
||||||
|
|
||||||
|
- 공개 API, 보안 정책, 애플리케이션 런타임 설정 변경.
|
||||||
|
- 관리자 배너 테스트의 assertion 또는 테스트 범위 완화.
|
||||||
|
|
||||||
|
## 5. 수용 기준
|
||||||
|
|
||||||
|
- `AdminChatBannerControllerIntegrationTest`와 `AdminContentBannerControllerIntegrationTest`가 통과한다.
|
||||||
|
- `TranslationSelectionTestConfiguration`을 사용하는 지정 테스트가 통과한다.
|
||||||
|
- 수정은 테스트 설정의 스캔 제외에 한정한다.
|
||||||
+2
@@ -8,6 +8,7 @@ import kr.co.vividnext.sodalive.v2.contenttranslation.domain.TranslationCandidat
|
|||||||
import kr.co.vividnext.sodalive.v2.contenttranslation.port.TranslationCandidateStore
|
import kr.co.vividnext.sodalive.v2.contenttranslation.port.TranslationCandidateStore
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
|
import org.springframework.boot.test.context.TestComponent
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
import org.springframework.context.annotation.Import
|
import org.springframework.context.annotation.Import
|
||||||
@@ -47,6 +48,7 @@ abstract class TranslationCandidateTestSupport : TranslationSelectionTestSupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@TestComponent
|
||||||
class SelectionCandidateProviderConfiguration {
|
class SelectionCandidateProviderConfiguration {
|
||||||
@Bean fun selectionPapagoProvider() = SelectionPapagoProvider()
|
@Bean fun selectionPapagoProvider() = SelectionPapagoProvider()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -8,12 +8,14 @@ import kr.co.vividnext.sodalive.v2.contenttranslation.adapter.out.persistence.Jp
|
|||||||
import kr.co.vividnext.sodalive.v2.contenttranslation.adapter.out.persistence.JpaTranslationSelectionStore
|
import kr.co.vividnext.sodalive.v2.contenttranslation.adapter.out.persistence.JpaTranslationSelectionStore
|
||||||
import kr.co.vividnext.sodalive.v2.contenttranslation.adapter.scheduler.TranslationSelectionWorker
|
import kr.co.vividnext.sodalive.v2.contenttranslation.adapter.scheduler.TranslationSelectionWorker
|
||||||
import org.redisson.api.RedissonClient
|
import org.redisson.api.RedissonClient
|
||||||
|
import org.springframework.boot.test.context.TestComponent
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean
|
import org.springframework.boot.test.mock.mockito.MockBean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
import org.springframework.context.annotation.Import
|
import org.springframework.context.annotation.Import
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@TestComponent
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||||
@Import(
|
@Import(
|
||||||
ContentDetailTranslationTestConfiguration::class, SodaExceptionHandler::class,
|
ContentDetailTranslationTestConfiguration::class, SodaExceptionHandler::class,
|
||||||
|
|||||||
Reference in New Issue
Block a user