From bc4917f732373961c007724582b2d3e2bcfb0551 Mon Sep 17 00:00:00 2001 From: Federico Valeri Date: Mon, 4 Mar 2024 15:51:17 +0100 Subject: [PATCH] Fail test when Connect doesn't start in time and increse the wait time Signed-off-by: Federico Valeri --- .../cluster/operator/assembly/ConnectCluster.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/ConnectCluster.java b/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/ConnectCluster.java index 23cfa2064ff..17a37f931a3 100644 --- a/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/ConnectCluster.java +++ b/cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/ConnectCluster.java @@ -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; @@ -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(); @@ -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.")); } }