Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

로컬에서 docker compose 실행안되는현상 수정 #105

Merged
merged 2 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.uniqueauction;

import org.springframework.context.annotation.Profile;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MySQLContainer;

@Profile("test & !localtest")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

localtest에서는 testContainer사용하지않는다.
로컬에서 docker compose 등으로 실행해놓은 인프라를 사용한다.

추가적으로 localtest 로 실행시 repository쪽 테스트 모두 실패하는현상 있음
#106 에서 다룸

public abstract class AbstractContainerBaseTest {
static final String MYSQL_IMAGE = "mysql:8";
static final MySQLContainer<?> MY_SQL_CONTAINER;
Expand Down
7 changes: 1 addition & 6 deletions src/test/resources/application-localtest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/UA?serverTimezone=UTC&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
url: jdbc:mysql://localhost:13309/UA?serverTimezone=UTC&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

docker compose에서는 13309포트를 사용하는데 접속은 3306으로 시도하고있기에 변경함.

https://github.com/f-lab-edu/unique-auction/blob/develop/docker-compose.yml#L12-L13

username: root
password: 12345678

Expand All @@ -11,11 +11,6 @@ spring:
show-sql: true
defer-datasource-initialization: true

sql:
init:
mode: always
schema-locations: classpath:/schema.sql

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

로컬테스트에서는 이미 로컬에 셋팅된 환경을 사용하기에 스키마를 따로 실행해 줄 필요가 없음.

redis:
# host: docker-redis
host: localhost
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
spring:
datasource:
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver
url: jdbc:tc:mysql:8:///UA?TC_INITSCRIPT=file:src/test/resources/schema.sql
url: jdbc:tc:mysql:8:///UA?TC_INITSCRIPT=file:mysql-init-files/schema.sql

redis:
host: 118.67.132.139
Expand Down