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
commit d3e1c0db2537875058b676f7fb9edddd4d887779 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Fri Jul 14 08:35:10 2023 +0200 (chores) camel-core: SplitParallelTimeoutTest test fixes and cleanups - adjust timeouts for less flakiness on slower hosts - send the test kick-off message earlier - skip running the test on very slow hosts than take too long to start the context - run in isolation for more stability in hosts with smaller core counts --- .../camel/processor/SplitParallelTimeoutTest.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 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 436df15a7c6..d0adc902fec 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 @@ -24,13 +24,17 @@ 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.Assumptions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.parallel.Isolated; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@Timeout(50) +@Isolated +@Timeout(60) public class SplitParallelTimeoutTest extends ContextTestSupport { private volatile Exchange receivedExchange; @@ -39,14 +43,18 @@ public class SplitParallelTimeoutTest extends ContextTestSupport { private volatile long receivedTimeout; private final Phaser phaser = new Phaser(3); + @BeforeEach + void sendEarly() { + Assumptions.assumeTrue(context.isStarted(), "The test cannot be run because the context is not started"); + template.sendBody("direct:start", "A,B,C"); + } + @RepeatedTest(20) public void testSplitParallelTimeout() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); // A will timeout so we only get B and/or C mock.message(0).body().not(body().contains("A")); - template.sendBody("direct:start", "A,B,C"); - phaser.awaitAdvanceInterruptibly(0, 5000, TimeUnit.SECONDS); assertMockEndpointsSatisfied(); @@ -62,7 +70,8 @@ public class SplitParallelTimeoutTest extends ContextTestSupport { return new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:start").split(body().tokenize(","), new MyAggregationStrategy()).parallelProcessing().timeout(100) + 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")
