This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 65b77304e6df CAMEL-27547: camel-zookeeper-master - fix flaky
MasterRoutePolicyRouteLifecycleTest (#31114)
65b77304e6df is described below
commit 65b77304e6df0e55e9556aca49630d288b2a7ba2
Author: Aurélien Pupier <[email protected]>
AuthorDate: Mon Nov 30 15:07:09 2026 +0100
CAMEL-27547: camel-zookeeper-master - fix flaky
MasterRoutePolicyRouteLifecycleTest (#31114)
awaitConsuming() waited with ServiceHelper.isStarted(), which also returns
true while the consumer is still starting. The test then sent a message to
seda:in while SedaConsumer.doStart() was still running; that start replaces a
stale queue reference (registerQueueIfStale), so the exchange already added
went to the replaced queue and was never consumed, and assertConsumes timed out.
awaitConsuming() now waits for a fully started consumer
(StatefulService.isStarted(), not starting). Only the test changes; no
assertion is modified.
Co-authored-by: IBM Bob 2.2.1
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../policy/MasterRoutePolicyRouteLifecycleTest.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git
a/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/policy/MasterRoutePolicyRouteLifecycleTest.java
b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/policy/MasterRoutePolicyRouteLifecycleTest.java
index 372743d8d645..8bd7a90b4574 100644
---
a/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/policy/MasterRoutePolicyRouteLifecycleTest.java
+++
b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/policy/MasterRoutePolicyRouteLifecycleTest.java
@@ -30,6 +30,7 @@ import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.ProducerTemplate;
+import org.apache.camel.StatefulService;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.zookeepermaster.ZookeeperGroupSupport;
@@ -390,9 +391,15 @@ class MasterRoutePolicyRouteLifecycleTest {
return ServiceHelper.isStarted(consumer);
}
+ // a consumer that is starting (ServiceHelper.isStarted) may not be ready
yet: the seda consumer replaces the stale
+ // queue of its endpoint when it starts, so a message sent before it has
started may be lost
+ private static boolean isConsumerFullyStarted(CamelContext context) {
+ return context.getRoute(ROUTE).getConsumer() instanceof
StatefulService consumer && consumer.isStarted();
+ }
+
private static void awaitConsuming(CamelContext context) {
await().atMost(30, TimeUnit.SECONDS).untilAsserted(
- () -> assertTrue(policyOf(context).isMaster() &&
isConsumerStarted(context),
+ () -> assertTrue(policyOf(context).isMaster() &&
isConsumerFullyStarted(context),
"The node must become the master and start its
consumer"));
}