This is an automated email from the ASF dual-hosted git repository.
gnodet 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 bf91f215a6c5 CAMEL-24640: Fix flaky MasterQuartzEndpointIT (#26182)
bf91f215a6c5 is described below
commit bf91f215a6c543b8c6a3f5b3760fc44f84ba30cc
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Sep 8 20:08:51 2026 +0200
CAMEL-24640: Fix flaky MasterQuartzEndpointIT (#26182)
Wait for master election (isMaster + isConnected) using Awaitility
before asserting on mock results, consistent with MasterEndpointIT.
Also increase resultWaitTime to 30s and add a route id for clean
consumer access.
Signed-off-by: Guillaume Nodet <[email protected]>
---
.../component/zookeepermaster/MasterQuartzEndpointIT.java | 11 +++++++++++
.../zookeepermaster/MasterQuartzEndpointIT-context.xml | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git
a/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT.java
b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT.java
index 3e10a87c1d4d..61b1ea996755 100644
---
a/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT.java
+++
b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT.java
@@ -16,12 +16,15 @@
*/
package org.apache.camel.component.zookeepermaster;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.CamelContext;
import org.apache.camel.EndpointInject;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.infra.zookeeper.services.ZooKeeperService;
import org.apache.camel.test.infra.zookeeper.services.ZooKeeperServiceFactory;
import org.apache.camel.test.spring.junit6.CamelSpringTest;
+import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,7 +44,15 @@ public class MasterQuartzEndpointIT {
@Test
public void testEndpoint() throws Exception {
+ // Wait for the master election to complete before expecting messages
+ MasterConsumer masterConsumer
+ = (MasterConsumer)
camelContext.getRoute("zookeeper-master-quartz").getConsumer();
+ Awaitility.await().atMost(30, TimeUnit.SECONDS)
+ .until(() -> masterConsumer.isMaster() &&
masterConsumer.isConnected());
+
resultEndpoint.expectedMinimumMessageCount(2);
+ // Allow enough time for at least 2 quartz cron fires (every 2 seconds)
+ resultEndpoint.setResultWaitTime(TimeUnit.SECONDS.toMillis(30));
MockEndpoint.assertIsSatisfied(camelContext);
}
diff --git
a/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT-context.xml
b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT-context.xml
index 52a8a5a8923e..d618cdfc1498 100644
---
a/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT-context.xml
+++
b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartzEndpointIT-context.xml
@@ -40,7 +40,7 @@
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring"
depends-on="curator">
- <route>
+ <route id="zookeeper-master-quartz">
<from
uri="zookeeper-master:master-000:quartz://masterTest?cron=0/2+0/1+*+1/1+*+?+*"/>
<to uri="mock:results"/>
</route>