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 5072493827c1 CAMEL-26375: camel-google-pubsub - Fix flaky
GroupedExchangeRoundtripIT
5072493827c1 is described below
commit 5072493827c1a7f945d0f08cb2dd7eec0f59c496
Author: Aurélien Pupier <[email protected]>
AuthorDate: Wed Oct 28 15:18:21 2026 +0100
CAMEL-26375: camel-google-pubsub - Fix flaky GroupedExchangeRoundtripIT
The test read sendResult.getExchanges() right after the receive-side
mock was satisfied. The send route only reaches mock:sendResult once
the publish to the topic has returned, which is not guaranteed to have
happened yet, so the list could still be empty:
"Received exchanges ==> expected: <1> but was: <0>".
Wait for the aggregated exchange with sendResult.expectedMessageCount(1)
and a single static MockEndpoint.assertIsSatisfied(context), which waits
for all mock endpoints, instead of a fixed 3s wait on receiveResult.
How it was reproduced: the failure does not occur under natural timing
locally (10/10 runs passed both with and without the change). To force
the race, a temporary ".delay(1500).asyncDelayed()" was added between
.to(topic) and .to(sendResult) in the send route:
- original test: fails with the exact error above
(GroupedExchangeRoundtripIT.sendGrouped:114)
- fixed test: passes
The delay was removed and is not part of this commit.
Co-authored-by: IBM Bob 2.2.1
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../pubsub/integration/GroupedExchangeRoundtripIT.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git
a/components/camel-google/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/GroupedExchangeRoundtripIT.java
b/components/camel-google/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/GroupedExchangeRoundtripIT.java
index 4db0a809c1a9..eaaf7ba24c18 100644
---
a/components/camel-google/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/GroupedExchangeRoundtripIT.java
+++
b/components/camel-google/camel-google-pubsub/src/test/java/org/apache/camel/component/google/pubsub/integration/GroupedExchangeRoundtripIT.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.component.google.pubsub.integration;
-import java.util.List;
-
import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
@@ -32,8 +30,6 @@ import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class GroupedExchangeRoundtripIT extends PubsubTestSupport {
private static final Logger LOG =
LoggerFactory.getLogger(GroupedExchangeRoundtripIT.class);
@@ -100,6 +96,7 @@ public class GroupedExchangeRoundtripIT extends
PubsubTestSupport {
receiveResult.expectedMessageCount(2);
receiveResult.expectedBodiesReceivedInAnyOrder(body1, body2);
+ sendResult.expectedMessageCount(1);
exchange1.getIn().setBody(body1);
exchange2.getIn().setBody(body2);
@@ -107,10 +104,8 @@ public class GroupedExchangeRoundtripIT extends
PubsubTestSupport {
producer.send(exchange1);
producer.send(exchange2);
- receiveResult.assertIsSatisfied(3000);
-
- // Send result section
- List<Exchange> results = sendResult.getExchanges();
- assertEquals(1, results.size(), "Received exchanges");
+ // Waits for all mock endpoints: the received messages and the
aggregated send result
+ // (the publish completes asynchronously, so the aggregated exchange
may arrive late)
+ MockEndpoint.assertIsSatisfied(context);
}
}