From 1c270048a1ad8c10b1f32487b2af22cbe0e1dcbe Mon Sep 17 00:00:00 2001 From: Klaus Date: Thu, 19 Nov 2026 14:20:21 +0900 Subject: [PATCH] =?UTF-8?q?fix(test):=20H2=20=EC=88=98=EB=AA=85=EA=B3=BC?= =?UTF-8?q?=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EA=B2=A9=EB=A6=AC?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=95=EB=A6=AC=ED=95=B4=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=9E=90=EC=9B=90=20=EB=88=84=EC=A0=81=EC=9D=84=20?= =?UTF-8?q?=EC=A4=84=EC=9D=B8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/agent-guides/테스트스타일.md | 8 +++ ...dminChatBannerControllerIntegrationTest.kt | 2 +- ...nContentBannerControllerIntegrationTest.kt | 2 +- ...ntSeriesBannerControllerIntegrationTest.kt | 2 +- ...minEventBannerControllerIntegrationTest.kt | 2 +- .../AdminLiveControllerIntegrationTest.kt | 2 +- .../live/AdminLiveServiceIntegrationTest.kt | 2 +- .../charge/ChargeControllerIntegrationTest.kt | 2 +- .../charge/ChargeServiceIntegrationTest.kt | 2 +- .../coupon/CanCouponServiceIntegrationTest.kt | 2 +- ...atCharacterBannerServiceIntegrationTest.kt | 2 +- ...ontentMainTabHomeServiceIntegrationTest.kt | 2 +- ...ntentSeriesBannerServiceIntegrationTest.kt | 14 ++++- ...entEndpointInjectedValueIntegrationTest.kt | 2 +- .../DeploymentEndpointIntegrationTest.kt | 2 +- .../EventBannerLanguageIntegrationTest.kt | 2 +- .../event/EventControllerIntegrationTest.kt | 2 +- .../MetadataReadRetryContextIsolationTest.kt | 41 +++++++++++++ .../MetadataReadRetryTestSupport.kt | 3 +- .../LiveReservationServiceIntegrationTest.kt | 2 +- ...ServiceNoticeConcurrencyIntegrationTest.kt | 2 +- .../ServiceNoticeQueryRepositoryTest.kt | 2 +- .../support/H2DatabaseLifecycleTest.kt | 61 +++++++++++++++++++ .../adapter/in/web/AdminGiftControllerTest.kt | 2 +- .../AdminNoticeControllerIntegrationTest.kt | 2 +- .../in/web/MainContentAllEndToEndTest.kt | 19 +++++- .../in/web/ContentOverviewEndToEndTest.kt | 23 ++++++- .../EventDetailControllerIntegrationTest.kt | 2 +- .../gift/adapter/in/web/GiftControllerTest.kt | 2 +- .../api/home/CreatorRankingControllerTest.kt | 2 +- .../LatestNoticeControllerIntegrationTest.kt | 2 +- ...CreatorRankingAggregationRepositoryTest.kt | 2 +- ...ultCreatorRankingSnapshotRepositoryTest.kt | 2 +- ...AdminSubBannerControllerIntegrationTest.kt | 2 +- .../RecommendationSubBannerIntegrationTest.kt | 2 +- src/test/resources/application.yml | 6 +- 36 files changed, 192 insertions(+), 39 deletions(-) create mode 100644 src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryContextIsolationTest.kt create mode 100644 src/test/kotlin/kr/co/vividnext/sodalive/support/H2DatabaseLifecycleTest.kt diff --git a/docs/agent-guides/테스트스타일.md b/docs/agent-guides/테스트스타일.md index a78bd418..8b829b20 100644 --- a/docs/agent-guides/테스트스타일.md +++ b/docs/agent-guides/테스트스타일.md @@ -19,6 +19,14 @@ - Redis가 필요한 통합 테스트만 `@ContextConfiguration(initializers = [EmbeddedRedisInitializer::class])`로 명시적으로 opt-in 한다. - Redis가 필요 없는 JPA/QueryDSL 슬라이스 테스트는 기존 관례처럼 `@DataJpaTest(properties = ["spring.cache.type=none"])`로 캐시를 끈다. +## 테스트 자원 수명과 context 재사용 +- 같은 종류의 통합 테스트는 기존 properties, profile, initializer, bean override 구성을 우선 재사용한다. 불필요한 클래스별 `@MockBean`/`@SpyBean`·설정 차이는 별도 context를 만든다. 격리를 위한 차이는 유지한다. +- Hikari가 관리하는 테스트 H2는 context별 DB 이름을 유지하고 `DB_CLOSE_DELAY=0`을 사용한다. 마지막 연결 종료 뒤에도 DB를 유지해야 하는 테스트는 그 이유와 명시적인 종료 책임을 증명한다. `create-drop`만으로 DB 엔진 종료를 대신하지 않는다. +- 상속한 test support에서 서로 다른 Spring context를 만들 수 있다면 H2 이름에 `${random.uuid}`처럼 context별 고유 값을 사용한다. 고정 이름을 공유하면 한 context의 `create-drop` 종료가 다른 context의 테이블을 삭제할 수 있다. +- 단순 DB fixture 정리에 `@DirtiesContext`를 추가하지 않는다. rollback 범위 밖의 commit·`REQUIRES_NEW`·비동기 데이터는 테스트가 정리하고, context 상태 복구가 불가능한 경우에만 context를 폐기한다. +- 테스트가 만든 executor, client, 임시 서버와 비동기 작업은 실패 경로에서도 정리한다. latch/Future 대기에 제한을 두고, 작업 해제·취소 후 executor 종료 완료를 확인한다. +- 메모리 부족을 테스트 skip, assertion 완화, 무조건적인 heap 증설로 해결하지 않는다. GC 로그와 실제 보유 객체, context 수명부터 확인한다. worker 교체는 별도 보호 장치이며 누적 원인 수정의 대체물이 아니다. + ## 저장 시각·응답 왕복 검증 규칙 - DB 재조회 시각과 API 응답을 비교하는 테스트는 OS의 현재 시각만 사용하지 않는다. 기존 시각 주입 seam을 재사용해 나노초 `0`, `123456789`, `999999999`와 `23:59:59` 같은 초/날짜 경계 입력을 고정한다. diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/admin/chat/AdminChatBannerControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/admin/chat/AdminChatBannerControllerIntegrationTest.kt index 959a4f2c..b7a1a141 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/admin/chat/AdminChatBannerControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/admin/chat/AdminChatBannerControllerIntegrationTest.kt @@ -25,7 +25,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:admin-chat-banner-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/banner/AdminContentBannerControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/banner/AdminContentBannerControllerIntegrationTest.kt index 2dec81ca..6f1f5738 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/banner/AdminContentBannerControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/banner/AdminContentBannerControllerIntegrationTest.kt @@ -47,7 +47,7 @@ import javax.persistence.EntityManager "cloud.aws.cloud-front.host=https://cdn.test", "cloud.aws.s3.bucket=test-bucket", "spring.datasource.url=jdbc:h2:mem:admin-content-banner-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/series/banner/AdminContentSeriesBannerControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/series/banner/AdminContentSeriesBannerControllerIntegrationTest.kt index 39aebdc7..f38545f2 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/series/banner/AdminContentSeriesBannerControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/admin/content/series/banner/AdminContentSeriesBannerControllerIntegrationTest.kt @@ -26,7 +26,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:admin-series-banner-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/admin/event/banner/AdminEventBannerControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/admin/event/banner/AdminEventBannerControllerIntegrationTest.kt index 00424ca6..3486f881 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/admin/event/banner/AdminEventBannerControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/admin/event/banner/AdminEventBannerControllerIntegrationTest.kt @@ -38,7 +38,7 @@ import java.time.LocalDateTime "cloud.aws.cloud-front.host=https://cdn.test", "cloud.aws.s3.bucket=test-bucket", "spring.datasource.url=jdbc:h2:mem:admin-event-banner-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveControllerIntegrationTest.kt index 1542129c..e7cc0299 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveControllerIntegrationTest.kt @@ -25,7 +25,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:admin-live-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveServiceIntegrationTest.kt index b2be2834..87741c4e 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/admin/live/AdminLiveServiceIntegrationTest.kt @@ -21,7 +21,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:admin-live-service-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeControllerIntegrationTest.kt index 747e6724..fe5f7e36 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeControllerIntegrationTest.kt @@ -58,7 +58,7 @@ import javax.persistence.EntityManager properties = [ "spring.cache.type=none", "spring.datasource.url=jdbc:h2:mem:charge-controller-http;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE", "jwt.secret=MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmMDEyMzQ1Njc4OWFiY2RlZg==", "apple.iap-verify-url=https://apple.invalid/verifyReceipt", "apple.iap-verify-sandbox-url=https://apple-sandbox.invalid/verifyReceipt", diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeServiceIntegrationTest.kt index 66244fa9..191d6803 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeServiceIntegrationTest.kt @@ -58,7 +58,7 @@ import javax.persistence.EntityManager properties = [ "spring.cache.type=none", "spring.datasource.url=jdbc:h2:mem:charge-service-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE", "apple.iap-verify-url=https://apple.invalid/verifyReceipt", "apple.iap-verify-sandbox-url=https://apple-sandbox.invalid/verifyReceipt", "payverse.host=https://payverse.invalid", diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/can/coupon/CanCouponServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/can/coupon/CanCouponServiceIntegrationTest.kt index 814afbb9..59680d7f 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/can/coupon/CanCouponServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/can/coupon/CanCouponServiceIntegrationTest.kt @@ -21,7 +21,7 @@ import javax.persistence.EntityManager properties = [ "spring.cache.type=none", "spring.datasource.url=jdbc:h2:mem:can-coupon-service-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/chat/character/service/ChatCharacterBannerServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/chat/character/service/ChatCharacterBannerServiceIntegrationTest.kt index 34e0bde1..756f359b 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/chat/character/service/ChatCharacterBannerServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/chat/character/service/ChatCharacterBannerServiceIntegrationTest.kt @@ -23,7 +23,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:chat-banner-service-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/content/main/tab/home/AudioContentMainTabHomeServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/content/main/tab/home/AudioContentMainTabHomeServiceIntegrationTest.kt index 14a8b3da..b3b6c362 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/content/main/tab/home/AudioContentMainTabHomeServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/content/main/tab/home/AudioContentMainTabHomeServiceIntegrationTest.kt @@ -31,7 +31,7 @@ import java.time.LocalDateTime webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = [ "spring.datasource.url=jdbc:h2:mem:notice-home-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @Import(AudioContentMainTabHomeServiceIntegrationTest.TimeConfiguration::class) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/content/series/main/banner/ContentSeriesBannerServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/content/series/main/banner/ContentSeriesBannerServiceIntegrationTest.kt index c5650943..24bdcc1d 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/content/series/main/banner/ContentSeriesBannerServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/content/series/main/banner/ContentSeriesBannerServiceIntegrationTest.kt @@ -6,13 +6,13 @@ import kr.co.vividnext.sodalive.i18n.Lang import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.MemberRole import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.data.domain.PageRequest -import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ContextConfiguration import org.springframework.transaction.support.TransactionTemplate import javax.persistence.EntityManager @@ -21,16 +21,24 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:series-banner-service-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class ContentSeriesBannerServiceIntegrationTest @Autowired constructor( private val service: ContentSeriesBannerService, private val entityManager: EntityManager, private val transactionTemplate: TransactionTemplate ) { + @AfterEach + fun removeFixtures() { + transactionTemplate.executeWithoutResult { + listOf("series_banner", "series", "series_genre", "member").forEach { table -> + entityManager.createNativeQuery("delete from $table").executeUpdate() + } + } + } + @Test @DisplayName("OSIV off 환경에서 관리자 시리즈 배너 목록 응답 생성 시 lazy 초기화 예외가 발생하지 않는다") fun shouldCreateAdminSeriesBannerListResponseWhenOpenInViewIsDisabled() { diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointInjectedValueIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointInjectedValueIntegrationTest.kt index 07433b5f..3346c8b2 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointInjectedValueIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointInjectedValueIntegrationTest.kt @@ -19,7 +19,7 @@ import org.springframework.test.context.ContextConfiguration "deployment.artifact-version=1.2.3-20260914", "deployment.config-commit=1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d", "spring.datasource.url=jdbc:h2:mem:deployment-endpoint-injected-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointIntegrationTest.kt index 690c5fb1..2dc81b04 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointIntegrationTest.kt @@ -20,7 +20,7 @@ import org.springframework.test.context.ContextConfiguration properties = [ "management.server.port=0", "spring.datasource.url=jdbc:h2:mem:deployment-endpoint-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/event/EventBannerLanguageIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/event/EventBannerLanguageIntegrationTest.kt index eae032df..9108f27f 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/event/EventBannerLanguageIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/event/EventBannerLanguageIntegrationTest.kt @@ -35,7 +35,7 @@ import java.time.LocalDateTime properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:event-banner-language-http;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/event/EventControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/event/EventControllerIntegrationTest.kt index 79845357..ac30342a 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/event/EventControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/event/EventControllerIntegrationTest.kt @@ -33,7 +33,7 @@ import java.time.LocalDateTime "cloud.aws.cloud-front.host=https://cdn.test", "cloud.aws.s3.bucket=test-bucket", "spring.datasource.url=jdbc:h2:mem:event-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryContextIsolationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryContextIsolationTest.kt new file mode 100644 index 00000000..de41025f --- /dev/null +++ b/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryContextIsolationTest.kt @@ -0,0 +1,41 @@ +package kr.co.vividnext.sodalive.i18n.translation + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.springframework.test.annotation.DirtiesContext.HierarchyMode +import org.springframework.test.context.TestContextManager + +class MetadataReadRetryContextIsolationTest { + @Test + @DisplayName("커뮤니티 테스트 context 생성과 종료는 원작 테스트 DB의 작업을 지우지 않는다") + fun shouldPreserveOriginalWorkJobsWhenCommunityContextCloses() { + val original = TestContextManager(OriginalWorkReadRetryTest::class.java).testContext + val community = TestContextManager(CreatorCommunityReadRetryTest::class.java).testContext + try { + val jobs = original.applicationContext.getBean(TranslationJobRepository::class.java) + val job = jobs.saveAndFlush( + TranslationJob( + resourceType = LanguageTranslationTargetType.ORIGINAL_WORK, + resourceId = 10L, + fieldKey = "title", + sourceHash = SourceTextNormalizer.hash("격리된 원작 제목"), + sourceText = "격리된 원작 제목", + sourceLanguage = "ko", + targetLanguage = "en" + ) + ) + try { + community.applicationContext.getBean(TranslationJobRepository::class.java) + } finally { + community.markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL) + } + + val preserved = jobs.findById(requireNotNull(job.id)).orElseThrow() + assertEquals("격리된 원작 제목", preserved.sourceText) + assertEquals(TranslationJobStatus.PENDING, preserved.status) + } finally { + original.markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL) + } + } +} diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryTestSupport.kt b/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryTestSupport.kt index 8731f48b..24786462 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryTestSupport.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/i18n/translation/MetadataReadRetryTestSupport.kt @@ -23,7 +23,8 @@ import javax.persistence.EntityManager @DataJpaTest( properties = [ "spring.cache.type=none", - "spring.datasource.url=jdbc:h2:mem:metadata-read-retry;MODE=MySQL;NON_KEYWORDS=VALUE;DB_CLOSE_ON_EXIT=FALSE" + "spring.datasource.url=jdbc:h2:mem:metadata-read-retry-\${random.uuid};" + + "MODE=MySQL;NON_KEYWORDS=VALUE;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/live/reservation/LiveReservationServiceIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/live/reservation/LiveReservationServiceIntegrationTest.kt index 93996443..1753b43e 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/live/reservation/LiveReservationServiceIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/live/reservation/LiveReservationServiceIntegrationTest.kt @@ -36,7 +36,7 @@ import javax.persistence.EntityManager properties = [ "spring.cache.type=none", "spring.datasource.url=jdbc:h2:mem:live-reservation-service-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeConcurrencyIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeConcurrencyIntegrationTest.kt index f130d2e2..c1fb4d0e 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeConcurrencyIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeConcurrencyIntegrationTest.kt @@ -36,7 +36,7 @@ import javax.persistence.LockModeType properties = [ "spring.datasource.url=jdbc:h2:mem:notice-concurrency;" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;" + - "DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=15000" + "DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=15000" ] ) @Import(ServiceNoticeConcurrencyIntegrationTest.TimeConfiguration::class) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeQueryRepositoryTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeQueryRepositoryTest.kt index eadabf72..374c1cdb 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeQueryRepositoryTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/notice/ServiceNoticeQueryRepositoryTest.kt @@ -29,7 +29,7 @@ import javax.persistence.EntityManager @SpringBootTest( properties = [ "spring.datasource.url=jdbc:h2:mem:notice-query-repository;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @Import(ServiceNoticeQueryRepositoryTest.TimeConfiguration::class) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/support/H2DatabaseLifecycleTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/support/H2DatabaseLifecycleTest.kt new file mode 100644 index 00000000..ac34844b --- /dev/null +++ b/src/test/kotlin/kr/co/vividnext/sodalive/support/H2DatabaseLifecycleTest.kt @@ -0,0 +1,61 @@ +package kr.co.vividnext.sodalive.support + +import com.zaxxer.hikari.HikariDataSource +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.springframework.boot.autoconfigure.AutoConfigurations +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration +import org.springframework.boot.env.RandomValuePropertySource +import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer +import org.springframework.boot.test.context.runner.ApplicationContextRunner +import java.sql.DriverManager +import java.sql.SQLException + +class H2DatabaseLifecycleTest { + @Test + @DisplayName("공용 테스트 H2는 풀 연결 사이에서 데이터를 공유하고 컨텍스트 종료 시 제거된다") + fun shouldShareDataAcrossPooledConnectionsAndRemoveDatabaseWhenContextCloses() { + lateinit var dataSource: HikariDataSource + ApplicationContextRunner() + .withInitializer { context -> + RandomValuePropertySource.addToEnvironment(context.environment) + ConfigDataApplicationContextInitializer().initialize(context) + } + .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration::class.java)) + .run { context -> + assertNull(context.startupFailure) + dataSource = context.getBean(HikariDataSource::class.java) + dataSource.connection.use { first -> + first.createStatement().use { statement -> + statement.execute("CREATE TABLE lifecycle_marker (id INTEGER PRIMARY KEY)") + statement.executeUpdate("INSERT INTO lifecycle_marker (id) VALUES (1)") + } + dataSource.connection.use { second -> + second.createStatement().use { statement -> + statement.executeQuery("SELECT id FROM lifecycle_marker").use { rows -> + assertTrue(rows.next()) + assertEquals(1, rows.getInt(1)) + } + } + } + } + } + + assertTrue(dataSource.isClosed) + val failure = assertThrows(SQLException::class.java) { + DriverManager.getConnection( + "${dataSource.jdbcUrl};IFEXISTS=TRUE", + dataSource.username, + dataSource.password + ).use { connection -> + // Release a surviving database before the lifecycle assertion fails. + connection.createStatement().use { it.execute("SHUTDOWN") } + } + } + assertEquals(90146, failure.errorCode) + } +} diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/gift/adapter/in/web/AdminGiftControllerTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/gift/adapter/in/web/AdminGiftControllerTest.kt index 6aabf491..37c2b71b 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/gift/adapter/in/web/AdminGiftControllerTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/gift/adapter/in/web/AdminGiftControllerTest.kt @@ -112,7 +112,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:gift-admin-controller;MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;" + - "DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/notice/AdminNoticeControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/notice/AdminNoticeControllerIntegrationTest.kt index 3a4ff2f2..df1750d6 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/notice/AdminNoticeControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/admin/notice/AdminNoticeControllerIntegrationTest.kt @@ -53,7 +53,7 @@ import javax.persistence.EntityManager properties = [ "jwt.secret=MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwMTIzNDU2Nzg5YWJjZGVmMDEyMzQ1Njc4OWFiY2RlZg==", "spring.datasource.url=jdbc:h2:mem:admin-notice-http;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @Import(AdminNoticeControllerIntegrationTest.TimeConfiguration::class) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt index f7a03958..e5c53402 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt @@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.nullValue import org.hibernate.SessionFactory +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test @@ -20,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest import org.springframework.jdbc.core.JdbcTemplate -import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get @@ -40,13 +40,28 @@ import javax.persistence.EntityManager ) @AutoConfigureMockMvc @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class MainContentAllEndToEndTest @Autowired constructor( private val mockMvc: MockMvc, private val entityManager: EntityManager, private val transactionTemplate: TransactionTemplate, private val jdbcTemplate: JdbcTemplate ) { + @AfterEach + fun removeFixtures() { + transactionTemplate.executeWithoutResult { + listOf( + "orders", + "creator_localized_name", + "series_published_days_of_week", + "series", + "content", + "series_genre", + "content_theme", + "member" + ).forEach { table -> jdbcTemplate.update("delete from $table") } + } + } + @Test @DisplayName("전체 콘텐츠 API는 JA 별칭을 우선하고 KO 별칭 미등록 시 일본어 원본을, 별칭 없는 작성자는 현재 원본을 반환한다") fun shouldSelectLocalizedCreatorNamesWithoutChangingAudioTitles() { diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/overview/adapter/in/web/ContentOverviewEndToEndTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/overview/adapter/in/web/ContentOverviewEndToEndTest.kt index 84c0629d..2f71edbf 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/overview/adapter/in/web/ContentOverviewEndToEndTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/overview/adapter/in/web/ContentOverviewEndToEndTest.kt @@ -10,13 +10,13 @@ import kr.co.vividnext.sodalive.member.MemberRole import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer import kr.co.vividnext.sodalive.v2.recommendation.adapter.out.persistence.RecommendationSnapshot import kr.co.vividnext.sodalive.v2.recommendation.domain.RecommendedSectionType +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user -import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get @@ -35,12 +35,27 @@ import javax.persistence.EntityManager ) @AutoConfigureMockMvc @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class ContentOverviewEndToEndTest @Autowired constructor( private val mockMvc: MockMvc, private val entityManager: EntityManager, private val transactionTemplate: TransactionTemplate ) { + @AfterEach + fun removeFixtures() { + transactionTemplate.executeWithoutResult { + listOf( + "content_translation", + "recommendation_snapshot", + "content", + "content_theme", + "member_content_preference", + "member" + ).forEach { table -> + entityManager.createNativeQuery("delete from $table").executeUpdate() + } + } + } + @Test @DisplayName("콘텐츠 전체보기 API는 비회원 요청을 거부한다") fun shouldRejectAnonymousContentOverviewRequest() { @@ -63,6 +78,7 @@ class ContentOverviewEndToEndTest @Autowired constructor( .andExpect(status().isOk) .andExpect(jsonPath("$.success").value(true)) .andExpect(jsonPath("$.data.type").value("NEW_AND_HOT_AUDIO")) + .andExpect(jsonPath("$.data.items.length()").value(1)) .andExpect(jsonPath("$.data.items[0].contentId").value(fixture.audioContentId)) .andExpect(jsonPath("$.data.items[0].title").value("content-overview-new-hot-audio")) .andExpect(jsonPath("$.data.items[0].coverImage").value("https://cdn.test/content-overview-new-hot.png")) @@ -86,6 +102,7 @@ class ContentOverviewEndToEndTest @Autowired constructor( .andExpect(status().isOk) .andExpect(jsonPath("$.success").value(true)) .andExpect(jsonPath("$.data.type").value("FIRST_AUDIO_CONTENT")) + .andExpect(jsonPath("$.data.items.length()").value(1)) .andExpect(jsonPath("$.data.items[0].contentId").value(fixture.audioContentId)) .andExpect(jsonPath("$.data.items[0].title").value("content-overview-first-audio")) .andExpect(jsonPath("$.data.items[0].coverImage").value("https://cdn.test/content-overview-first.png")) @@ -129,6 +146,7 @@ class ContentOverviewEndToEndTest @Autowired constructor( .with(user(MemberAdapter(fixture.viewer))) ) .andExpect(status().isOk) + .andExpect(jsonPath("$.data.items.length()").value(1)) .andExpect(jsonPath("$.data.items[0].contentId").value(fixture.audioContentId)) .andExpect(jsonPath("$.data.items[0].title").value(title)) } @@ -148,6 +166,7 @@ class ContentOverviewEndToEndTest @Autowired constructor( .andExpect(status().isOk) .andExpect(jsonPath("$.success").value(true)) .andExpect(jsonPath("$.data.type").value("NEW_AND_HOT_AUDIO")) + .andExpect(jsonPath("$.data.items.length()").value(1)) .andExpect(jsonPath("$.data.items[0].contentId").value(fixture.audioContentId)) .andExpect(jsonPath("$.data.page").value(0)) .andExpect(jsonPath("$.data.size").value(20)) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/event/EventDetailControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/event/EventDetailControllerIntegrationTest.kt index 11f4cc36..7eebdaed 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/event/EventDetailControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/event/EventDetailControllerIntegrationTest.kt @@ -46,7 +46,7 @@ import java.time.LocalDateTime "cloud.aws.cloud-front.host=https://cdn.test", "cloud.aws.s3.bucket=test-bucket", "spring.datasource.url=jdbc:h2:mem:event-detail-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/gift/adapter/in/web/GiftControllerTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/gift/adapter/in/web/GiftControllerTest.kt index 8c57216e..f24a576f 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/gift/adapter/in/web/GiftControllerTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/gift/adapter/in/web/GiftControllerTest.kt @@ -53,7 +53,7 @@ import java.time.LocalDateTime @SpringBootTest( properties = [ "spring.datasource.url=" + - "jdbc:h2:mem:gift-controller;MODE=MySQL;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", + "jdbc:h2:mem:gift-controller;MODE=MySQL;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE", "cloud.aws.cloud-front.host=https://cdn.test" ] ) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/home/CreatorRankingControllerTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/home/CreatorRankingControllerTest.kt index bb8188b5..f35f5b28 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/home/CreatorRankingControllerTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/home/CreatorRankingControllerTest.kt @@ -30,7 +30,7 @@ import javax.persistence.EntityManager properties = [ "cloud.aws.cloud-front.host=https://cdn.test", "spring.datasource.url=jdbc:h2:mem:creator-ranking-controller;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @AutoConfigureMockMvc diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/notice/LatestNoticeControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/notice/LatestNoticeControllerIntegrationTest.kt index 5ffad992..ff0037ac 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/notice/LatestNoticeControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/notice/LatestNoticeControllerIntegrationTest.kt @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = [ "spring.datasource.url=jdbc:h2:mem:latest-notice-controller-integration;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingAggregationRepositoryTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingAggregationRepositoryTest.kt index fb36d842..52199124 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingAggregationRepositoryTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingAggregationRepositoryTest.kt @@ -31,7 +31,7 @@ import javax.persistence.EntityManager properties = [ "spring.cache.type=none", "spring.datasource.url=jdbc:h2:mem:creator-ranking-aggregation;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @Import(QueryDslConfig::class, DefaultCreatorRankingAggregationRepository::class) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingSnapshotRepositoryTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingSnapshotRepositoryTest.kt index cf36c383..0d4b63fa 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingSnapshotRepositoryTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/ranking/adapter/out/persistence/DefaultCreatorRankingSnapshotRepositoryTest.kt @@ -17,7 +17,7 @@ import java.time.LocalDateTime properties = [ "spring.cache.type=none", "spring.datasource.url=jdbc:h2:mem:creator-ranking-snapshot;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @Import(QueryDslConfig::class, DefaultCreatorRankingSnapshotRepository::class) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/AdminSubBannerControllerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/AdminSubBannerControllerIntegrationTest.kt index 23e6c1ae..a3d3af02 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/AdminSubBannerControllerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/AdminSubBannerControllerIntegrationTest.kt @@ -58,7 +58,7 @@ import javax.persistence.EntityManager "cloud.aws.cloud-front.host=https://cdn.test", "cloud.aws.s3.bucket=test-bucket", "spring.datasource.url=jdbc:h2:mem:admin-sub-banner-http;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/RecommendationSubBannerIntegrationTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/RecommendationSubBannerIntegrationTest.kt index c0971668..27b11204 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/RecommendationSubBannerIntegrationTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/subbanner/adapter/in/web/RecommendationSubBannerIntegrationTest.kt @@ -62,7 +62,7 @@ import javax.persistence.EntityManager "cloud.aws.cloud-front.host=https://cdn.test", "cloud.aws.s3.bucket=test-bucket", "spring.datasource.url=jdbc:h2:mem:public-sub-banner-http;" + - "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + "MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE" ] ) @ContextConfiguration(initializers = [EmbeddedRedisInitializer::class]) diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 8fe31993..1a8a3402 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -109,7 +109,7 @@ spring: datasource: driver-class-name: org.h2.Driver - url: jdbc:h2:mem:sodalive-test-${random.uuid};MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + url: jdbc:h2:mem:sodalive-test-${random.uuid};MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=0;DB_CLOSE_ON_EXIT=FALSE username: sa password: @@ -121,7 +121,7 @@ spring: ddl-auto: create-drop properties: hibernate: - show_sql: true - format_sql: true + show_sql: false + format_sql: false cache: type: redis