Skip to content

Commit debb7e5

Browse files
committed
Upgrade dependencies.
[resolves #628]
1 parent 70c32c4 commit debb7e5

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/test/java/io/r2dbc/postgresql/util/PostgresqlHighAvailabilityClusterExtension.java

+16-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
import org.junit.jupiter.api.extension.AfterAllCallback;
2222
import org.junit.jupiter.api.extension.BeforeAllCallback;
2323
import org.junit.jupiter.api.extension.ExtensionContext;
24+
import org.slf4j.LoggerFactory;
2425
import org.springframework.jdbc.core.JdbcTemplate;
2526
import org.testcontainers.containers.Network;
2627
import org.testcontainers.containers.PostgreSQLContainer;
28+
import org.testcontainers.containers.output.Slf4jLogConsumer;
2729
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
30+
import org.testcontainers.utility.DockerImageName;
2831
import org.testcontainers.utility.MountableFile;
2932

3033
import java.net.URISyntaxException;
@@ -118,18 +121,14 @@ private void startPrimary(Network network) {
118121
}
119122

120123
private void startStandby(Network network) {
121-
this.standby = new PostgreSQLContainer<>(PostgresqlServerExtension.IMAGE_NAME)
124+
this.standby = new CustomPostgreSQLContainer(PostgresqlServerExtension.IMAGE_NAME)
122125
.withNetwork(network)
123126
.withCopyFileToContainer(getHostPath("setup-standby.sh", 0755), "/setup-standby.sh")
124127
.withCommand("/setup-standby.sh")
125128
.withEnv("PG_REP_USER", "replication")
126129
.withEnv("PG_REP_PASSWORD", "replication_password")
127130
.withEnv("PG_MASTER_HOST", "postgres-primary")
128131
.withEnv("PG_MASTER_PORT", "5432");
129-
this.standby.setWaitStrategy(new LogMessageWaitStrategy()
130-
.withRegEx(".*database system is ready to accept .* connections.*\\s")
131-
.withTimes(1)
132-
.withStartupTimeout(Duration.of(60L, ChronoUnit.SECONDS)));
133132
this.standby.start();
134133
HikariConfig standbyConfig = new HikariConfig();
135134
standbyConfig.setJdbcUrl(this.standby.getJdbcUrl());
@@ -138,4 +137,16 @@ private void startStandby(Network network) {
138137
this.standbyDataSource = new HikariDataSource(standbyConfig);
139138
}
140139

140+
// setWaitStrategy() doesn't seem to work, only inside constructor
141+
static class CustomPostgreSQLContainer extends PostgreSQLContainer<CustomPostgreSQLContainer> {
142+
public CustomPostgreSQLContainer(String dockerImageName) {
143+
super(DockerImageName.parse(dockerImageName));
144+
this.waitStrategy =
145+
new LogMessageWaitStrategy()
146+
.withRegEx(".*database system is ready to accept .*connections.*\\s")
147+
.withTimes(1)
148+
.withStartupTimeout(Duration.of(60L, ChronoUnit.SECONDS));
149+
}
150+
}
151+
141152
}

0 commit comments

Comments
 (0)