You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/10/13 08:52:35 UTC

[camel] branch main updated: CAMEL-18608: fix tests of type ZooKeeperServiceRegistrationITBase

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

nfilotto 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 aca486350f0 CAMEL-18608: fix tests of type ZooKeeperServiceRegistrationITBase
aca486350f0 is described below

commit aca486350f0b7dee45a882edb3c92c3585375cf9
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Thu Oct 13 10:52:16 2022 +0200

    CAMEL-18608: fix tests of type ZooKeeperServiceRegistrationITBase
---
 components/camel-zookeeper/pom.xml                                 | 5 +++++
 .../cloud/integration/ZooKeeperServiceRegistrationITBase.java      | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/components/camel-zookeeper/pom.xml b/components/camel-zookeeper/pom.xml
index 119223f8aa5..2162e674312 100644
--- a/components/camel-zookeeper/pom.xml
+++ b/components/camel-zookeeper/pom.xml
@@ -178,6 +178,11 @@
             <artifactId>log4j-slf4j-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <scope>test</scope>
+        </dependency>
 
         <!-- test infra -->
         <dependency>
diff --git a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cloud/integration/ZooKeeperServiceRegistrationITBase.java b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cloud/integration/ZooKeeperServiceRegistrationITBase.java
index e803beae471..75232769690 100644
--- a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cloud/integration/ZooKeeperServiceRegistrationITBase.java
+++ b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cloud/integration/ZooKeeperServiceRegistrationITBase.java
@@ -20,6 +20,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.cloud.ServiceDefinition;
@@ -38,6 +39,7 @@ import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -123,7 +125,7 @@ public abstract class ZooKeeperServiceRegistrationITBase extends CamelTestSuppor
 
         // check that service has been registered
         Collection<ServiceInstance<ZooKeeperServiceRegistry.MetaData>> services = discovery.queryForInstances(SERVICE_NAME);
-        assertEquals(1, services.size());
+        await().atMost(2, TimeUnit.MINUTES).untilAsserted(() -> assertEquals(1, services.size()));
 
         ServiceInstance<ZooKeeperServiceRegistry.MetaData> instance = services.iterator().next();
         assertEquals(SERVICE_PORT, (int) instance.getPort());
@@ -140,6 +142,7 @@ public abstract class ZooKeeperServiceRegistrationITBase extends CamelTestSuppor
         context().getRouteController().stopRoute(SERVICE_ID);
 
         // the service should be removed once the route is stopped
-        assertTrue(discovery.queryForInstances(SERVICE_NAME).isEmpty());
+        await().atMost(2, TimeUnit.MINUTES)
+                .untilAsserted(() -> assertTrue(discovery.queryForInstances(SERVICE_NAME).isEmpty()));
     }
 }