Skip to content

Comments

refactor: 테스트 환경 db 변경과 설정 및 세팅 수정#20

Merged
hisonghy merged 6 commits intodevelopfrom
refactor/test-db-19
Mar 17, 2025
Merged

refactor: 테스트 환경 db 변경과 설정 및 세팅 수정#20
hisonghy merged 6 commits intodevelopfrom
refactor/test-db-19

Conversation

@hisonghy
Copy link
Member

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 기존 테스트 환경의 H2 인메모리 DB 에서 개발환경과 동일한 postgresql 로 변경했습니다. H2 DB mode를 postgresql 로 설정해도 지원되지 않는 부분(ARRAY[] 타입 지원 등)이 존재하고 테스트도 개발환경과 일관된 환경에서 수행하기 위해 변경했습니다
  • CICD 환경에서 테스트 실행 시 redis, postgres 를 실행하기 위해 docker-compose-test.yml 도커 컴포즈 파일을 작성하고 워크플로에서 실행하도록 작업 구성했습니다 (774eed6, 1ec6df7)
  • CICD 환경에서 스키마, 데이터 sql 파일을 생성해 등록되도록 구성했습니다

🔍 참고사항

  • 테스트 클래스에 @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 어노테이션을 추가했습니다. 이 어노테이션이 없으면, 스프링 부트는 테스트 실행 시 자동으로 내장된 인메모리 DB(H2)를 사용하려고 하기 때문에 application.yml 파일의 spring.datasource.url 및 driver-class-name 을 다른 DB 정보를 설정해도 해당 DB와 연결할 수 없다는 에러가 발생합니다 (H2 등의 인메모리 DB가 아닌 다른 DB 정보를 설정했기 때문에)
    이 어노테이션을 추가해서 테스트 환경에서도 애플리케이션이 실제 사용하는 DB와 연결되도록 설정했습니다.

📚 기타

  • *.sql 파일 .gitignore 적용
  • logback-spring.xml 파일에서 test 환경의 로그 설정에 profile 정보 ocal -> test 로 수정

@hisonghy hisonghy added the 🚀 refactor 기능 개선 label Mar 16, 2025
@hisonghy hisonghy self-assigned this Mar 16, 2025
@hisonghy hisonghy force-pushed the refactor/test-db-19 branch 6 times, most recently from 5964f6c to ebc2ba6 Compare March 16, 2025 13:12
@hisonghy hisonghy force-pushed the refactor/test-db-19 branch from ebc2ba6 to 4cf3253 Compare March 16, 2025 13:14
@hisonghy
Copy link
Member Author

hisonghy commented Mar 16, 2025

CI 워크플로에서 gradlew check step 이후 postgres 컨테이너에 접속해 스키마, 데이터 목록을 조회하는 작업을 추가해 확인하면서 CI 테스트 환경에 잘 적용되는거 확인했습니다.

#22 PR 먼저 머지한 이후에 최신 상태를 병합시킨 뒤 다시 push 하겠습니다.

@hisonghy hisonghy merged commit d5a8bf0 into develop Mar 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 refactor 기능 개선

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀️ 테스팅 환경 DB 변경

2 participants