You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "orpiske (via GitHub)" <gi...@apache.org> on 2023/08/10 12:20:36 UTC

[GitHub] [camel] orpiske commented on a diff in pull request #11060: CAMEL-19516: replaced Thread.sleep() in camel-consul tests

orpiske commented on code in PR #11060:
URL: https://github.com/apache/camel/pull/11060#discussion_r1290037992


##########
components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyFactoryIT.java:
##########
@@ -94,7 +95,7 @@ public void configure() {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            Awaitility.await().atMost(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS);

Review Comment:
   This is missing the terminal operation. You need to add something like `untilAsserted`, `until` or similar.
   
   I believe we need something similar to this:
   
   
   ```
   Awaitility.await().pollDelay(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS).untilAsserted(() -> Assertions.assertDoesNotThrow(context::start));
   ```
   
   



##########
components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulMasterIT.java:
##########
@@ -92,7 +93,7 @@ public void configure() {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            Awaitility.await().atMost(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS);

Review Comment:
   Same as above.



##########
components/camel-consul/src/test/java/org/apache/camel/component/consul/cluster/ConsulClusteredRoutePolicyIT.java:
##########
@@ -94,7 +95,7 @@ public void configure() throws Exception {
 
             // Start the context after some random time so the startup order
             // changes for each test.
-            Thread.sleep(ThreadLocalRandom.current().nextInt(500));
+            Awaitility.await().atMost(ThreadLocalRandom.current().nextInt(500), TimeUnit.MILLISECONDS);

Review Comment:
   Same as above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org