Skip to content

Commit 7fafce1

Browse files
committed
chore(ci): enhance test workflow and improve Postgres test container config
1 parent 3c50132 commit 7fafce1

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

.github/workflows/run-tests.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,20 @@ jobs:
2121
distribution: 'temurin'
2222
cache: gradle
2323

24+
- name: Check Docker availability
25+
run: |
26+
docker --version
27+
docker info
28+
29+
- name: Make gradlew executable
30+
run: chmod +x ./gradlew
31+
2432
- name: Run memory-api tests with coverage
25-
run: ./gradlew :memory-api:test :memory-api:jacocoTestReport
33+
run: ./gradlew :memory-api:test :memory-api:jacocoTestReport --info --stacktrace
34+
env:
35+
SPRING_PROFILES_ACTIVE: test
36+
TESTCONTAINERS_RYUK_DISABLED: true
37+
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock
2638

2739
- name: Upload coverage reports to Codecov
2840
uses: codecov/codecov-action@v3

memory-api/src/test/java/com/memory/controller/PostgresTC.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.memory.controller;
22

33
import org.testcontainers.containers.PostgreSQLContainer;
4+
import org.testcontainers.containers.wait.strategy.Wait;
45
import org.testcontainers.utility.DockerImageName;
56

7+
import java.time.Duration;
8+
69
public class PostgresTC extends PostgreSQLContainer<PostgresTC> {
710
private static final DockerImageName IMG = DockerImageName.parse("postgis/postgis:15-3.3")
811
.asCompatibleSubstituteFor("postgres");
@@ -13,10 +16,16 @@ private PostgresTC() {
1316
withDatabaseName("memory_test");
1417
withUsername("test");
1518
withPassword("test");
16-
// 필요하면 .waitingFor(Wait.forListeningPort());
19+
withStartupTimeout(Duration.ofMinutes(5));
20+
waitingFor(Wait.forListeningPort())
21+
.withReuse(false);
1722
}
23+
1824
public static synchronized PostgresTC getInstance() {
19-
if (INSTANCE == null) { INSTANCE = new PostgresTC(); INSTANCE.start(); }
25+
if (INSTANCE == null) {
26+
INSTANCE = new PostgresTC();
27+
INSTANCE.start();
28+
}
2029
return INSTANCE;
2130
}
2231
}

0 commit comments

Comments
 (0)