Skip to content

Commit 5dc39d1

Browse files
committed
ci[Github-Action]: CI-CD 테스트 환경 설정 코드 수정
1 parent 338e5fe commit 5dc39d1

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

.github/workflows/CI-CD_Pipeline.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
--health-interval 10s
4040
--health-timeout 5s
4141
--health-retries 5
42+
env:
43+
REDIS_PASSWORD: ""
4244

4345
steps:
4446
- uses: actions/checkout@v4
@@ -79,6 +81,9 @@ jobs:
7981
TEST_REDIS_HOST=localhost
8082
TEST_REDIS_PORT=6379
8183
TEST_REDIS_PASSWORD=
84+
85+
# CI/CD 환경에서는 Embedded Redis 끄기
86+
SPRING_DATA_REDIS_EMBEDDED=false
8287
8388
# JWT 설정 (application-test.yml에서 참조)
8489
CUSTOM_JWT_SECRET_KEY=test-secret-key-for-testing-purposes-only-minimum-256-bits
Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
11
package com.ai.lawyer.global.config;
22

33
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
45
import org.springframework.context.annotation.Configuration;
56
import org.springframework.context.event.ContextClosedEvent;
67
import org.springframework.context.event.ContextRefreshedEvent;
78
import org.springframework.context.event.EventListener;
89
import redis.embedded.RedisServer;
910

1011
import jakarta.annotation.PreDestroy;
11-
import java.io.IOException;
1212

1313
@Configuration
14+
@ConditionalOnProperty(name = "spring.data.redis.embedded", havingValue = "true", matchIfMissing = true)
1415
public class EmbeddedRedisConfig {
1516

1617
@Value("${spring.data.redis.port:6379}")
1718
private int redisPort;
1819

19-
@Value("${spring.data.redis.embedded:true}")
20-
private boolean embedded;
21-
2220
private RedisServer redisServer;
2321

2422
@EventListener(ContextRefreshedEvent.class)
2523
public void startRedis() {
26-
if (embedded) {
27-
try {
28-
redisServer = RedisServer.builder()
24+
try {
25+
redisServer = RedisServer.builder()
2926
.port(redisPort)
30-
.setting("maxmemory 128M") // 메모리 제한 설정
27+
.setting("maxmemory 128M")
3128
.build();
32-
33-
if (!redisServer.isActive()) {
34-
redisServer.start();
35-
System.out.println("=== Embedded Redis 서버가 포트 " + redisPort + "에서 시작되었습니다 ===");
36-
}
37-
} catch (Exception e) {
38-
System.err.println("=== Embedded Redis 서버 시작 실패: " + e.getMessage() + " ===");
39-
throw e;
29+
30+
if (!redisServer.isActive()) {
31+
redisServer.start();
32+
System.out.println("=== Embedded Redis 서버가 포트 " + redisPort + "에서 시작되었습니다 ===");
4033
}
34+
} catch (Exception e) {
35+
System.err.println("=== Embedded Redis 서버 시작 실패: " + e.getMessage() + " ===");
4136
}
4237
}
4338

4439
@PreDestroy
4540
@EventListener(ContextClosedEvent.class)
4641
public void stopRedis() {
47-
if (embedded && redisServer != null && redisServer.isActive()) {
42+
if (redisServer != null && redisServer.isActive()) {
4843
redisServer.stop();
4944
System.out.println("=== Embedded Redis 서버가 중지되었습니다 ===");
5045
}
5146
}
52-
}
47+
}

backend/src/test/resources/application-test-ci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ spring:
2424
# CI/CD 환경: 실제 Redis 서비스 사용, Embedded Redis 비활성화
2525
data:
2626
redis:
27-
host: ${TEST_REDIS_HOST}
28-
port: ${TEST_REDIS_PORT}
29-
password: ${TEST_REDIS_PASSWORD}
30-
31-
# Embedded Redis 비활성화
32-
autoconfigure:
33-
exclude:
34-
- org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
27+
host: ${TEST_REDIS_HOST:localhost}
28+
port: ${TEST_REDIS_PORT:6379}
29+
password: ${TEST_REDIS_PASSWORD:}
30+
embedded: false
3531

3632
security:
3733
oauth2:

0 commit comments

Comments
 (0)