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

apupier 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 cc5df805db08 CAMEL-25640: Fix flaky MasterQuartzEndpointIT
cc5df805db08 is described below

commit cc5df805db08f282a6a1c2b0baff4ef26506c547
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Oct 19 14:26:18 2026 +0200

    CAMEL-25640: Fix flaky MasterQuartzEndpointIT
    
    Two bugs combined to cause intermittent failures when
    MasterEndpointIT ran before MasterQuartzEndpointIT in the same JVM.
    
    1. Both Spring context XMLs started their own ZooKeeperContainer bean,
       completely ignoring the @RegisterExtension ZooKeeperService. That
       service's container was never used. The Spring-owned container also
       configured CuratorFactoryBean with a 3000ms connection timeout, too
       short under CI load.
    
       Fix: remove the zkContainer/zkConnectString beans from both XMLs,
       add PropertySourcesPlaceholderConfigurer, and read the connection
       string from the ${zookeeper.connection.string} system property that
       ZooKeeperLocalContainerInfraService.registerProperties() already
       sets when the @RegisterExtension service starts. Raise the curator
       connection timeout to 30000ms.
    
    2. Both context XMLs used the same ZooKeeper election path
       (zookeeper-master:master-000:...). Because @CamelSpringTest caches
       Spring contexts, the first test kept its CamelContext alive while the
       second test ran. The cached context held the master-000 lease, so the
       second test could never win the election within the 30s Awaitility
       window.
    
       Fix: give each test a distinct group name (master-endpoint-it and
       master-quartz-it) so they never compete for the same ZK path.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../zookeepermaster/MasterEndpointIT-context.xml   | 26 ++++++++--------------
 .../MasterQuartzEndpointIT-context.xml             | 26 ++++++++--------------
 2 files changed, 18 insertions(+), 34 deletions(-)

diff --git 
a/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointIT-context.xml
 
b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointIT-context.xml
index ea7d4a6f34c7..5c2a90061eae 100644
--- 
a/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointIT-context.xml
+++ 
b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointIT-context.xml
@@ -21,27 +21,19 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>
 
-  <!-- Since this is a test case lets run a local ZK server -->
-  <bean id="zkContainer" 
class="org.apache.camel.test.infra.zookeeper.services.ZooKeeperContainer" 
init-method="start" destroy-method="stop">
-    <constructor-arg>
-      <value>zookeeper</value>
-    </constructor-arg>
-  </bean>
-
-  <bean id="zkConnectString" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-    <property name="targetObject" ref="zkContainer"/>
-    <property name="targetMethod" value="getConnectionString">
-    </property>
-  </bean>
-
-  <bean id="curator" 
class="org.apache.camel.component.zookeepermaster.CuratorFactoryBean" 
depends-on="zkContainer">
-    <property name="timeout" value="3000"/>
-    <property name="connectString" ref="zkConnectString"/>
+  <!-- Resolve system properties set by the @RegisterExtension 
ZooKeeperService -->
+  <bean 
class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
+
+  <!-- Use the ZooKeeper started by the @RegisterExtension ZooKeeperService in 
the test class.
+       The connection string is published via the system property 
zookeeper.connection.string. -->
+  <bean id="curator" 
class="org.apache.camel.component.zookeepermaster.CuratorFactoryBean">
+    <property name="timeout" value="30000"/>
+    <property name="connectString" value="${zookeeper.connection.string}"/>
   </bean>
 
   <camelContext xmlns="http://camel.apache.org/schema/spring"; 
depends-on="curator">
     <route id="zookeeper-master-to-direct">
-      <from uri="zookeeper-master:master-000:direct:bar"/>
+      <from uri="zookeeper-master:master-endpoint-it:direct:bar"/>
       <to uri="mock:results"/>
     </route>
 
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 d618cdfc1498..63aa0ec83482 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
@@ -21,27 +21,19 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>
 
-  <!-- Since this is a test case lets run a local ZK server -->
-  <bean id="zkContainer" 
class="org.apache.camel.test.infra.zookeeper.services.ZooKeeperContainer" 
init-method="start" destroy-method="stop">
-    <constructor-arg>
-      <value>zookeeper</value>
-    </constructor-arg>
-  </bean>
-
-  <bean id="zkConnectString" 
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-    <property name="targetObject" ref="zkContainer"/>
-    <property name="targetMethod" value="getConnectionString">
-    </property>
-  </bean>
-
-  <bean id="curator" 
class="org.apache.camel.component.zookeepermaster.CuratorFactoryBean" 
depends-on="zkContainer">
-    <property name="timeout" value="3000"/>
-    <property name="connectString" ref="zkConnectString"/>
+  <!-- Resolve system properties set by the @RegisterExtension 
ZooKeeperService -->
+  <bean 
class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
+
+  <!-- Use the ZooKeeper started by the @RegisterExtension ZooKeeperService in 
the test class.
+       The connection string is published via the system property 
zookeeper.connection.string. -->
+  <bean id="curator" 
class="org.apache.camel.component.zookeepermaster.CuratorFactoryBean">
+    <property name="timeout" value="30000"/>
+    <property name="connectString" value="${zookeeper.connection.string}"/>
   </bean>
 
   <camelContext xmlns="http://camel.apache.org/schema/spring"; 
depends-on="curator">
     <route id="zookeeper-master-quartz">
-      <from 
uri="zookeeper-master:master-000:quartz://masterTest?cron=0/2+0/1+*+1/1+*+?+*"/>
+      <from 
uri="zookeeper-master:master-quartz-it:quartz://masterTest?cron=0/2+0/1+*+1/1+*+?+*"/>
       <to uri="mock:results"/>
     </route>
 

Reply via email to