DBZ-2923 Improving test stability

This commit is contained in:
Gunnar Morling 2021-01-13 17:02:39 +01:00
parent 7144943a8f
commit aa674842a3
2 changed files with 10 additions and 5 deletions

View File

@ -6,8 +6,6 @@
package io.debezium.connector.postgresql;
import static org.junit.Assert.assertFalse;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;
@ -140,10 +138,11 @@ public void shouldStopOnPostgresFastShutdown() throws Exception {
.execInContainer("su", "-", "postgres", "-c", "/usr/lib/postgresql/11/bin/pg_ctl -m fast -D /var/lib/postgresql/data stop");
logger.info(result.toString());
logger.info("Waiting for Postgres to shutdown...");
logger.info("Waiting for Postgres to shut down...");
waitForPostgresShutdown();
assertFalse(isStreamingRunning("postgres", TestHelper.TEST_SERVER));
logger.info("Waiting for connector to shut down...");
waitForConnectorShutdown("postgres", TestHelper.TEST_SERVER);
}
private void waitForPostgresShutdown() {
@ -152,5 +151,4 @@ private void waitForPostgresShutdown() {
.atMost(60 * TestHelper.waitTimeForRecords(), TimeUnit.SECONDS)
.until(() -> !postgresContainer.isRunning());
}
}

View File

@ -1064,6 +1064,13 @@ public static void waitForStreamingRunning(String connector, String server, Stri
.until(() -> isStreamingRunning(connector, server, contextName));
}
public static void waitForConnectorShutdown(String connector, String server) {
Awaitility.await()
.pollInterval(200, TimeUnit.MILLISECONDS)
.atMost(waitTimeForRecords() * 30, TimeUnit.SECONDS)
.until(() -> !isStreamingRunning(connector, server));
}
public static boolean isStreamingRunning(String connector, String server) {
return isStreamingRunning(connector, server, "streaming");
}