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 105f362b5eba CAMEL-23905: Fix flaky LRAFailuresIT by replacing 
setResultWaitTime with Awaitility (#24418)
105f362b5eba is described below

commit 105f362b5eba44d1ab3cc19b091d34c6bdb1b41b
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sun Jul 5 21:06:52 2026 +0200

    CAMEL-23905: Fix flaky LRAFailuresIT by replacing setResultWaitTime with 
Awaitility (#24418)
    
    * CAMEL-23905: Fix flaky LRAFailuresIT by replacing setResultWaitTime with 
Awaitility
    
    Replace MockEndpoint.setResultWaitTime() + assertIsSatisfied() with
    Awaitility's await().atMost().untilAsserted() pattern. The previous
    approach uses a single check at the deadline, which is timing-sensitive
    for LRA saga callbacks that involve HTTP retries via the coordinator.
    Awaitility polls every 100ms, making the test both faster (passes as
    soon as satisfied) and more reliable under varying JDK timing.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    * CAMEL-23905: Use non-blocking getReceivedCounter() for Awaitility polling
    
    Address Copilot review: MockEndpoint.assertIsSatisfied() blocks up to
    10s on an internal latch when resultWaitTime is not set, defeating
    Awaitility's frequent polling. Switch to polling getReceivedCounter()
    (non-blocking) and only call assertIsSatisfied() once after messages
    have arrived.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../test/java/org/apache/camel/service/lra/LRAFailuresIT.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
 
b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
index d54e663b7300..26ea66c2d65d 100644
--- 
a/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
+++ 
b/components/camel-lra/src/test/java/org/apache/camel/service/lra/LRAFailuresIT.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.service.lra;
 
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.RuntimeCamelException;
@@ -23,6 +24,8 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
+
 public class LRAFailuresIT extends AbstractLRATestSupport {
 
     private AtomicInteger maxFailures;
@@ -33,10 +36,11 @@ public class LRAFailuresIT extends AbstractLRATestSupport {
 
         MockEndpoint compensate = getMockEndpoint("mock:compensate");
         compensate.expectedMessageCount(1);
-        compensate.setResultWaitTime(20000);
 
         sendBody("direct:saga-compensate", "hello");
 
+        await().atMost(20, TimeUnit.SECONDS)
+                .until(() -> compensate.getReceivedCounter() >= 1);
         compensate.assertIsSatisfied();
     }
 
@@ -46,13 +50,15 @@ public class LRAFailuresIT extends AbstractLRATestSupport {
 
         MockEndpoint complete = getMockEndpoint("mock:complete");
         complete.expectedMessageCount(1);
-        complete.setResultWaitTime(20000);
 
         MockEndpoint end = getMockEndpoint("mock:end");
         end.expectedBodiesReceived("hello");
 
         sendBody("direct:saga-complete", "hello");
 
+        await().atMost(20, TimeUnit.SECONDS)
+                .until(() -> complete.getReceivedCounter() >= 1
+                        && end.getReceivedCounter() >= 1);
         complete.assertIsSatisfied();
         end.assertIsSatisfied();
     }

Reply via email to