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 69b9b21b6db9 CAMEL-23908: Fix flaky BacklogTracerAggregateTest (#24424)
69b9b21b6db9 is described below

commit 69b9b21b6db9b3d885453595c90532ec218cfe38
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sun Jul 5 10:10:20 2026 +0200

    CAMEL-23908: Fix flaky BacklogTracerAggregateTest (#24424)
    
    Use Awaitility to poll for backlog tracer events instead of asserting
    immediately after assertMockEndpointsSatisfied. The aggregate EIP
    processes the completed exchange asynchronously, so tracer events may
    not all be recorded yet when dumpAllTracedMessages is called.
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../camel/management/BacklogTracerAggregateTest.java   | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git 
a/core/camel-management/src/test/java/org/apache/camel/management/BacklogTracerAggregateTest.java
 
b/core/camel-management/src/test/java/org/apache/camel/management/BacklogTracerAggregateTest.java
index 2d08cfc9e058..9cc02a78a4e1 100644
--- 
a/core/camel-management/src/test/java/org/apache/camel/management/BacklogTracerAggregateTest.java
+++ 
b/core/camel-management/src/test/java/org/apache/camel/management/BacklogTracerAggregateTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.management;
 
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
@@ -28,6 +29,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
 
+import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
@@ -56,14 +58,18 @@ public class BacklogTracerAggregateTest extends 
ManagementTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        List<BacklogTracerEventMessage> events
-                = (List<BacklogTracerEventMessage>) mbeanServer.invoke(on, 
"dumpAllTracedMessages", null, null);
+        // the aggregate completion may still be processing traced events 
asynchronously,
+        // so use Awaitility to wait until all backlog tracer events are 
recorded
+        await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+            List<BacklogTracerEventMessage> events
+                    = (List<BacklogTracerEventMessage>) mbeanServer.invoke(on, 
"dumpAllTracedMessages", null, null);
 
-        assertNotNull(events);
+            assertNotNull(events);
 
-        // should be 4 first and 4 last
-        assertEquals(4, 
events.stream().filter(BacklogTracerEventMessage::isFirst).count());
-        assertEquals(4, 
events.stream().filter(BacklogTracerEventMessage::isLast).count());
+            // should be 4 first and 4 last
+            assertEquals(4, 
events.stream().filter(BacklogTracerEventMessage::isFirst).count());
+            assertEquals(4, 
events.stream().filter(BacklogTracerEventMessage::isLast).count());
+        });
     }
 
     @Override

Reply via email to