Skip to content

Commit

Permalink
DBZ-6133 Wait for test container ready message
Browse files Browse the repository at this point in the history
  • Loading branch information
jpechane committed Jun 20, 2023
1 parent 7f6ed72 commit 2b52048
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions debezium-server-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<version.nats>2.16.3</version.nats>
<version.stan>2.2.3</version.stan>
<version.commons.logging>1.2</version.commons.logging>

<!-- Testing -->
<version.junit.pioneer>2.0.1</version.junit.pioneer>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -256,6 +259,13 @@
<scope>import</scope>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>${version.junit.pioneer}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
5 changes: 5 additions & 0 deletions debezium-server-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-testing-testcontainers</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class RedisSSLTestResourceLifecycleManager implements QuarkusTestResource
private static synchronized void start(boolean ignored) {
if (!running.get()) {
container.start();
TestUtils.waitBoolean(() -> container.getLogs().contains(RedisTestResourceLifecycleManager.READY_MESSAGE));
running.set(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RetryingTest;

import io.debezium.config.Configuration;
import io.debezium.connector.mysql.MySqlConnection;
Expand Down Expand Up @@ -86,7 +87,7 @@ public void shouldRecordChangesAndRecoverToVariousPoints() {
* 2. Create a new table named redis_test in MySQL
* 3. Bring Redis up again and make sure the database schema has been written successfully
*/
@Test
@RetryingTest(3)
@FixFor("DBZ-4509")
public void testRedisConnectionRetry() throws Exception {
Testing.Print.enable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class RedisTestResourceLifecycleManager implements QuarkusTestResourceLifecycleManager {

static final String READY_MESSAGE = "Ready to accept connections";
public static final int REDIS_PORT = 6379;
public static final String REDIS_IMAGE = "redis";

Expand All @@ -27,6 +28,7 @@ public class RedisTestResourceLifecycleManager implements QuarkusTestResourceLif
private static synchronized void start(boolean ignored) {
if (!running.get()) {
container.start();
TestUtils.waitBoolean(() -> container.getLogs().contains(READY_MESSAGE));
running.set(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void awaitHashSizeGte(Jedis jedis, String hashName, int expectedSi
waitBoolean(() -> jedis.hgetAll(hashName).size() >= expectedSize);
}

private static void waitBoolean(Supplier<Boolean> bool) {
public static void waitBoolean(Supplier<Boolean> bool) {
Awaitility.await().atMost(Duration.ofSeconds(TestConfigSource.waitForSeconds())).until(() -> {
return Boolean.TRUE.equals(bool.get());
});
Expand Down

0 comments on commit 2b52048

Please sign in to comment.