This is an automated email from the ASF dual-hosted git repository. orpiske 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 3f7a1a7855d (chores) ci: fix flakyness on split test 3f7a1a7855d is described below commit 3f7a1a7855d027f0419ffbb6941893b81a28031c Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Thu Jun 22 10:08:48 2023 +0200 (chores) ci: fix flakyness on split test Originally introduced by 13798aa92b575a2b968ea776974bef1d4bdd76a6 --- .../camel/processor/SplitParallelTimeoutTest.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java index 40fc7ee1a86..990cd6ba5f7 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java @@ -16,26 +16,29 @@ */ package org.apache.camel.processor; +import java.util.concurrent.Phaser; + import org.apache.camel.AggregationStrategy; import org.apache.camel.ContextTestSupport; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.Isolated; +import org.junit.jupiter.api.Timeout; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@Isolated("Short timeouts cause problems with parallel text execution") public class SplitParallelTimeoutTest extends ContextTestSupport { private volatile Exchange receivedExchange; private volatile int receivedIndex; private volatile int receivedTotal; private volatile long receivedTimeout; + private final Phaser phaser = new Phaser(4); @Test + @Timeout(5) public void testSplitParallelTimeout() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); // A will timeout so we only get B and/or C @@ -43,6 +46,8 @@ public class SplitParallelTimeoutTest extends ContextTestSupport { template.sendBody("direct:start", "A,B,C"); + phaser.arriveAndAwaitAdvance(); + assertMockEndpointsSatisfied(); assertNotNull(receivedExchange); @@ -57,17 +62,20 @@ public class SplitParallelTimeoutTest extends ContextTestSupport { @Override public void configure() throws Exception { from("direct:start").split(body().tokenize(","), new MyAggregationStrategy()).parallelProcessing().timeout(100) - .choice().when(body().isEqualTo("A")).to("direct:a") - .when(body().isEqualTo("B")).to("direct:b").when(body().isEqualTo("C")).to("direct:c").end() // end + .choice() + .when(body().isEqualTo("A")).to("direct:a") + .when(body().isEqualTo("B")).to("direct:b") + .when(body().isEqualTo("C")).to("direct:c") + .end() // end // choice .end() // end split .to("mock:result"); - from("direct:a").delay(200).setBody(constant("A")); + from("direct:a").process(e -> phaser.arriveAndAwaitAdvance()).setBody(constant("A")); - from("direct:b").setBody(constant("B")); + from("direct:b").process(e -> phaser.arrive()).setBody(constant("B")); - from("direct:c").delay(10).setBody(constant("C")); + from("direct:c").delay(10).process(e -> phaser.arrive()).setBody(constant("C")); } }; }