Skip to content

Commit

Permalink
[test] 테스트용 mysql 분리 (#79)
Browse files Browse the repository at this point in the history
* test: test용 mysql 분리

* refactor: 테스트용 db가 분리됨에 따라 패키지 구조 변경

* refactor: 테스트용 db가 분리됨에 따라 패키지 구조 변경

* refactor: 개발 db와 테스트 db의 mysql관련 파일 패키지 분리
  • Loading branch information
Gyaak authored Sep 30, 2024
1 parent 27381b8 commit 1d1c058
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
26 changes: 0 additions & 26 deletions backend/data/mysql-files/rss_blog.csv

This file was deleted.

24 changes: 22 additions & 2 deletions backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,35 @@ services:
- MYSQL_DATABASE=${DOCKER_MYSQL_DATABASE}
- TZ=Asia/Seoul
volumes:
- ./data/mysql-data:/var/lib/mysql
- ./data/mysql-files:/var/lib/mysql-files
- ./data/develop/mysql-data:/var/lib/mysql
- ./data/develop/mysql-files:/var/lib/mysql-files/develop
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --lower_case_table_names=1
networks:
- techpick-network

techpick-mysql-test:
image: mysql:8.0
container_name: techpick-mysql-test
ports:
- "3307:3306"
env_file:
- .env
environment:
- MYSQL_ROOT_PASSWORD=${DOCKER_MYSQL_TEST_PASSWORD}
- MYSQL_DATABASE=${DOCKER_MYSQL_TEST_DATABASE}
- TZ=Asia/Seoul
volumes:
- ./data/test/mysql-data:/var/lib/mysql
- ./data/test/mysql-files:/var/lib/mysql-files/test
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --lower_case_table_names=1
networks:
- techpick-network
# 로컬 테스트 용 ( 아래 설정은 실제 서버에 올라간 Compose 와 다름 )
# techpick-server:
# build:
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- BULK INSERT (STATIC DATA)

LOAD DATA INFILE '/var/lib/mysql-files/rss_blog.csv'
LOAD DATA INFILE '/var/lib/mysql-files/develop/rss_blog.csv'
INTO TABLE rss_blog
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
Expand Down
16 changes: 16 additions & 0 deletions backend/src/test/resources/application-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
spring:
config:
activate:
on-profile: test
datasource:
url: ${DOCKER_MYSQL_TEST_URL}
username: ${DOCKER_MYSQL_TEST_USERNAME}
password: ${DOCKER_MYSQL_TEST_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
properties:
hibernate:
format_sql: false
show_sql: true
hibernate:
ddl-auto: create-drop # 테스트용 db는 매 실행마다 초기화 되어야함

0 comments on commit 1d1c058

Please sign in to comment.