Skip to content

Commit

Permalink
Fail test when Connect doesn't start in time and increse the wait time (
Browse files Browse the repository at this point in the history
#9773)

Signed-off-by: Federico Valeri <fedevaleri@gmail.com>
  • Loading branch information
fvaleri committed Mar 4, 2024
1 parent 0c3deb1 commit 534e20e
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static java.lang.String.format;

public class ConnectCluster {
private int numNodes;
private String brokerList;
Expand Down Expand Up @@ -61,7 +63,7 @@ public void startup() throws InterruptedException {
try {
ConnectDistributed connectDistributed = new ConnectDistributed();
Connect connect = connectDistributed.startConnect(workerProps);
waitConnectRunning(connect);
waitForAllServicesToStart(connect, 120);
connectInstances.add(connect);
connectPorts.add(port);
l.countDown();
Expand All @@ -83,17 +85,16 @@ public void startup() throws InterruptedException {
}
}

private static void waitConnectRunning(Connect connect) {
int counter = 30;
while (!connect.isRunning() && counter-- > 0) {
private static void waitForAllServicesToStart(Connect connect, int seconds) {
while (!connect.isRunning() && seconds-- > 0) {
try {
TimeUnit.MILLISECONDS.sleep(100);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
throw new ConnectException(e);
}
}
if (!connect.isRunning()) {
throw new RuntimeException("Connect failed to start after 3 seconds.");
throw new ConnectException(format("Connect failed to start."));
}
}

Expand Down

0 comments on commit 534e20e

Please sign in to comment.