You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/08/14 15:21:21 UTC

[camel] branch main updated: CAMEL-19516: replaced Thread.sleep() in camel-consul tests (#11060)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 3c1980eac07 CAMEL-19516: replaced Thread.sleep() in camel-consul tests (#11060)
3c1980eac07 is described below

commit 3c1980eac07b7204879a27f14fe5e980e60ab0a8
Author: LostArtist <93...@users.noreply.github.com>
AuthorDate: Mon Aug 14 17:21:14 2023 +0200

    CAMEL-19516: replaced Thread.sleep() in camel-consul tests (#11060)
    
    Co-authored-by: Nikita Konovalov <nk...@redhat.com>
---
 .../component/consul/cluster/ConsulClusteredRoutePolicyFactoryIT.java  | 3 ++-
 .../camel/component/consul/cluster/ConsulClusteredRoutePolicyIT.java   | 3 ++-
 .../java/org/apache/camel/component/consul/cluster/ConsulMasterIT.java | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyFactoryIT.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyFactoryIT.java
index 5bdbeaefefd..06c4e3ba45a 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyFactoryIT.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyFactoryIT.java
@@ -36,6 +36,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 public class ConsulClusteredRoutePolicyFactoryIT {
     @RegisterExtension
@@ -94,7 +95,7 @@ public class ConsulClusteredRoutePolicyFactoryIT {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            Awaitility.await().pollDelay(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS).untilAsserted(() -> Assertions.assertDoesNotThrow(context::start));
             LOGGER.info("Starting CamelContext on node: {}", id);
             context.start();
             LOGGER.info("Started CamelContext on node: {}", id);
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyIT.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyIT.java
index 979671f4b06..61cc2c9ddff 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyIT.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyIT.java
@@ -36,6 +36,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 public class ConsulClusteredRoutePolicyIT {
     @RegisterExtension
@@ -94,7 +95,7 @@ public class ConsulClusteredRoutePolicyIT {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            Awaitility.await().pollDelay(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS).untilAsserted(() -> Assertions.assertDoesNotThrow(context::start));
             context.start();
 
             contextLatch.await();
diff --git a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulMasterIT.java b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulMasterIT.java
index 419069d817f..4535ca268ad 100644
--- a/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulMasterIT.java
+++ b/components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulMasterIT.java
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 public class ConsulMasterIT {
     @RegisterExtension
@@ -92,7 +93,7 @@ public class ConsulMasterIT {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            Awaitility.await().pollDelay(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS).untilAsserted(() -> Assertions.assertDoesNotThrow(context::start));
             context.start();
 
             contextLatch.await();