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 bafb7ff51da9 CAMEL-27026: Speed up camel-chaos tests
bafb7ff51da9 is described below
commit bafb7ff51da9138841fad4cfc2ec52aeb3a23dcd
Author: Aurélien Pupier <[email protected]>
AuthorDate: Mon Nov 16 10:20:37 2026 +0100
CAMEL-27026: Speed up camel-chaos tests
- Reduce SEDA and stub consumer default pollTimeout during tests (from
1000ms to 10ms), avoiding blocking waits on CamelContext shutdown/restart.
- Adjust real-time test rule durations in ChaosLifecycleTest and
ChaosLifecycleStartupTest from 2s/3s to 1s with safe timing margins.
- Enable parallel test execution (camel.surefire.parallel=true) with the
DST simulation suite isolated into a separate serial execution (tagged
not-parallel) to maintain virtual clock isolation.
- Add @Isolated to tests installing FakeClock on TimeSource to ensure
concurrent test safety.
Benchmark results:
- Original execution time: ~2m 14s (134s)
- With optimizations & parallel execution: ~26s-29s
- Performance improvement: ~78-80% test execution time reduction (all 857
tests passing).
Co-authored-by: IBM Bob 2.2.1
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../org/apache/camel/catalog/docs/test-dst.adoc | 17 ++++----
components/camel-chaos/pom.xml | 46 ++++++++++++++++++++++
.../camel/component/chaos/ChaosExperimentTest.java | 6 ++-
.../component/chaos/ChaosExplorationTest.java | 2 +
.../camel/component/chaos/ChaosFeedReachTest.java | 4 +-
.../camel/component/chaos/ChaosFeedTest.java | 1 +
.../camel/component/chaos/ChaosHooksTest.java | 2 +-
.../component/chaos/ChaosLifecycleStartupTest.java | 2 +-
.../camel/component/chaos/ChaosLifecycleTest.java | 25 ++++++------
.../camel/component/chaos/ChaosReplayTest.java | 4 +-
.../component/chaos/ChaosRouteCountsTest.java | 4 +-
.../camel/component/chaos/ChaosStubsTest.java | 1 +
.../component/chaos/dst/ChaosLifecycleDstTest.java | 2 +
.../camel-test-dst/src/main/docs/test-dst.adoc | 17 ++++----
14 files changed, 94 insertions(+), 39 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/test-dst.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/test-dst.adoc
index 3bf2fdf08aeb..0fe66cfbe03a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/test-dst.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/test-dst.adoc
@@ -610,15 +610,14 @@ and `dst.pulsar.subscribeFailRates` (the subscribe
failure rates of the Pulsar w
* Code on its own threads or on a third-party scheduler is outside the
harness; strict mode makes reaching it fail the
seed.
* One run per JVM at a time: the active run, and so the virtual clock, is a
static field, and every rewritten clock read
- in the JVM sees it, as does Camel core through `TimeSource` while the run is
open. A world must therefore not go into
- a module that runs its tests in parallel (`camel.surefire.parallel=true`, as
camel-jms and camel-sql do): the other
- tests in that surefire fork would read the virtual clock while a run is
active. For the same reason, a
- `CamelContext` left running in the same fork by an earlier non-DST test
would read the virtual time too and could
- fail a strict seed; stop it in that test. The harness enforces this: a second
- run while one is open fails, and a DST test refuses to start when JUnit runs
tests in parallel. A local world in
- such a module (camel-sjms, for example) can still be run alone, with
- `-Dtest=<the world> -Dcamel.surefire.parallel=false`, but it cannot be
committed there: the module's own build would
- fail it.
+ in the JVM sees it, as does Camel core through `TimeSource` while the run is
open. A world must therefore not run
+ concurrently with other tests in a module with
`camel.surefire.parallel=true`: the other tests in that surefire fork
+ would read the virtual clock while a run is active. To host a DST test in a
parallel module, tag the test with
+ `@Tag("not-parallel")` and configure Surefire with two executions — a
parallel pass excluding `not-parallel` and a
+ serial pass (`<groups>not-parallel</groups>`) with
`junit.jupiter.execution.parallel.enabled = false` in its
+ `<configurationParameters>`. For the same reason, a `CamelContext` left
running in the same fork by an earlier non-DST
+ test would read the virtual time too and could fail a strict seed; stop it
in that test. The harness enforces this: a second
+ run while one is open fails, and a DST test refuses to start when JUnit runs
tests in parallel.
* Locks do not exclude: every task runs on the test thread, so a
`ReentrantLock` or `synchronized` block held by a
blocked task is entered again by the tasks nested above it. A critical
section is atomic only because the fake does
not block inside it, and races between two code paths that each hold a lock
cannot be explored.
diff --git a/components/camel-chaos/pom.xml b/components/camel-chaos/pom.xml
index e2140b6e9068..c93f70375d1d 100644
--- a/components/camel-chaos/pom.xml
+++ b/components/camel-chaos/pom.xml
@@ -37,6 +37,7 @@
<label>tooling,testing</label>
<title>Chaos</title>
<supportLevel>Preview</supportLevel>
+ <camel.surefire.parallel>true</camel.surefire.parallel>
<!-- the DST test loads the byte code agent of camel-test-dst when the
JVM starts (see test-dst.adoc) -->
<camel.surefire.fork.additional-vmargs>"-javaagent:${net.bytebuddy:byte-buddy-agent:jar}"</camel.surefire.fork.additional-vmargs>
</properties>
@@ -158,4 +159,49 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <property>
+ <name>!quickly</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+
<excludedGroups>not-parallel</excludedGroups>
+ </configuration>
+ </execution>
+ <execution>
+ <id>serials-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <groups>not-parallel</groups>
+ <properties>
+ <configurationParameters>
+
junit.jupiter.execution.parallel.enabled = false
+
junit.jupiter.execution.timeout.default = 10 m
+ </configurationParameters>
+ </properties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExperimentTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExperimentTest.java
index 8cfe9cbe40d6..35837e9e6634 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExperimentTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExperimentTest.java
@@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.util.json.JsonObject;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Isolated;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -30,6 +31,7 @@ import static
org.assertj.core.api.Assertions.assertThatThrownBy;
* The experiments of an exploration (CAMEL-26774): a hypothesis and the rules
that test it, and what came of it in the
* journal: the counts per route while it ran, the faults of each rule, the
expectations and the verdict.
*/
+@Isolated
class ChaosExperimentTest extends ChaosTestSupport {
private FakeClock clock;
@@ -62,8 +64,8 @@ class ChaosExperimentTest extends ChaosTestSupport {
from("direct:refunds").routeId("refunds").to("mock:pay");
from("direct:payment").routeId("payment").to("mock:paid");
from("direct:checkout").routeId("checkout").to("direct:payment");
- from("direct:shop").routeId("shop").to("seda:shipping");
- from("seda:shipping").routeId("shipping").to("mock:sent");
+
from("direct:shop").routeId("shop").to("seda:shipping?pollTimeout=10");
+
from("seda:shipping?pollTimeout=10").routeId("shipping").to("mock:sent");
}
};
}
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExplorationTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExplorationTest.java
index 5a17ba5fe034..bea0297a3c89 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExplorationTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosExplorationTest.java
@@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.util.json.JsonObject;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Isolated;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -30,6 +31,7 @@ import static
org.assertj.core.api.Assertions.assertThatThrownBy;
* The journal of an exploration (CAMEL-26773): the baseline and the rules
tried, and a deadline that camel-chaos
* enforces, on the clock of TimeSource.
*/
+@Isolated
class ChaosExplorationTest extends ChaosTestSupport {
private FakeClock clock;
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedReachTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedReachTest.java
index 15f22c65f906..e687a5113503 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedReachTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedReachTest.java
@@ -41,9 +41,9 @@ class ChaosFeedReachTest extends ChaosTestSupport {
// orders come by themselves, are charged over HTTP at a route
of the same integration, and shipped
from("timer:orders?delay=-1&repeatCount=1").routeId("orders")
.to("netty-http:http://localhost:" + PORT + "/payment")
- .to("seda:shipping");
+ .to("seda:shipping?pollTimeout=10");
from("netty-http:http://0.0.0.0:" + PORT +
"/payment").routeId("payment").setBody(constant("paid"));
- from("seda:shipping").routeId("shipping").to("mock:shipped");
+
from("seda:shipping?pollTimeout=10").routeId("shipping").to("mock:shipped");
// refunds come from outside, and a parked order goes nowhere
else
from("direct:refunds").routeId("refunds").to("direct:payback");
from("direct:payback").routeId("payback").to("mock:paidBack");
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedTest.java
index 98cc30c86992..fab3c27d29a9 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosFeedTest.java
@@ -43,6 +43,7 @@ class ChaosFeedTest extends ChaosTestSupport {
context.addComponent("testpoll", poll);
StubComponent stub = new StubComponent();
stub.setShadow(true);
+ stub.setDefaultPollTimeout(10);
// remotemq is remote by its JSON (in the test resources), served by a
stub as camel run --stub=remote does
context.addComponent("remotemq", stub);
return context;
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosHooksTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosHooksTest.java
index 3f86d835a639..ac7d0d76dbc3 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosHooksTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosHooksTest.java
@@ -45,7 +45,7 @@ class ChaosHooksTest extends ChaosTestSupport {
// a scheduled poll that does not poll during the test, and is
never sent to
from("testpoll:inbox?initialDelay=3600000").routeId("poller").to("mock:out");
// consumed, but neither sent to nor polled on a schedule
- from("seda:in").routeId("in").to("mock:in");
+ from("seda:in?pollTimeout=10").routeId("in").to("mock:in");
// direct:orders is consumed and sent to; mock:kafka sent to;
the toD knows its endpoint when it sends
from("direct:calls").routeId("calls").to("direct:orders");
from("direct:orders").routeId("orders").to("mock:kafka").toD("mock:dyn-${header.n}")
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleStartupTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleStartupTest.java
index 13e95611c00c..90a158876b67 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleStartupTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleStartupTest.java
@@ -129,7 +129,7 @@ class ChaosLifecycleStartupTest {
context.start();
await().atMost(10, TimeUnit.SECONDS).until(() -> status() ==
ServiceStatus.Started);
ChaosManager chaos = ChaosManager.get(context);
- chaos.addRule("route=start lifecycle action=stop duration=3s");
+ chaos.addRule("route=start lifecycle action=stop duration=1s");
await().atMost(10, TimeUnit.SECONDS).until(() ->
"down".equals(lifecycle(chaos).getString("state")));
// a stop through the route controller is a manual stop for the
supervising controller: it releases the route
assertThat(status()).isEqualTo(ServiceStatus.Stopped);
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleTest.java
index 811c79d84756..244394af41f8 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosLifecycleTest.java
@@ -147,7 +147,7 @@ class ChaosLifecycleTest extends ChaosTestSupport {
@Test
void stallSuspendsTheRouteAndResumesItAfterTheDuration() {
- String id = chaos().addRule("route=a stall duration=2s");
+ String id = chaos().addRule("route=a stall duration=1s");
await().atMost(10, TimeUnit.SECONDS).until(() -> status("a") ==
ServiceStatus.Suspended);
assertThat(status("b")).isEqualTo(ServiceStatus.Started);
awaitLifecycle(id, "back");
@@ -161,12 +161,12 @@ class ChaosLifecycleTest extends ChaosTestSupport {
JsonObject l = lifecycle(id);
assertThat(l.getString("action")).isEqualTo("suspend");
assertThat(l.getString("route")).isEqualTo("a");
- assertThat(l.getLong("duration")).isEqualTo(2000L);
- assertThat(l.getLong("backAt") -
l.getLong("downAt")).isGreaterThanOrEqualTo(2000L);
+ assertThat(l.getLong("duration")).isEqualTo(1000L);
+ assertThat(l.getLong("backAt") -
l.getLong("downAt")).isGreaterThanOrEqualTo(1000L);
assertThat(((JsonObject)
rule.get("fired")).getLong("lifecycle")).isEqualTo(1);
assertThat(l.containsKey("reason")).isFalse();
assertThat(chaos().report().toText())
- .contains("r1 ended: route=a stall duration=2s")
+ .contains("r1 ended: route=a stall duration=1s")
.contains("suspended route a at +")
.contains(", resumed at +");
}
@@ -235,12 +235,12 @@ class ChaosLifecycleTest extends ChaosTestSupport {
@Test
void stopStartsTheRouteAgain() {
- String id = chaos().addRule("route=a lifecycle action=stop
duration=2s");
+ String id = chaos().addRule("route=a lifecycle action=stop
duration=1s");
await().atMost(10, TimeUnit.SECONDS).until(() -> status("a") ==
ServiceStatus.Stopped);
awaitLifecycle(id, "back");
assertThat(status("a")).isEqualTo(ServiceStatus.Started);
assertThat(chaos().report().toText()).contains("stopped route a at
+").contains(", started at +")
- .contains(" ago " + id + " stop 2s of route a");
+ .contains(" ago " + id + " stop 1s of route a");
assertThat(ruleReport(id).containsKey("lastFiredAgo")).isTrue();
}
@@ -275,7 +275,7 @@ class ChaosLifecycleTest extends ChaosTestSupport {
RouteDefinition definition = model.getRouteDefinition("a");
long completedBefore = routeCount("a", "completed");
- String id = chaos().addRule("route=a lifecycle action=remove
duration=2s");
+ String id = chaos().addRule("route=a lifecycle action=remove
duration=1s");
await().atMost(10, TimeUnit.SECONDS).until(() -> context.getRoute("a")
== null);
assertThat(model.getRouteDefinition("a")).isNull();
awaitLifecycle(id, "back");
@@ -494,9 +494,10 @@ class ChaosLifecycleTest extends ChaosTestSupport {
assertThat(l.getString("state")).isEqualTo("cancelled");
assertThat(l.getString("reason")).isEqualTo("the context stopped, so
route a was not resumed");
// no thread of chaos is left behind
+ String prefix = "Camel (" + context.getName() + ") ";
await().atMost(10, TimeUnit.SECONDS)
.until(() -> Thread.getAllStackTraces().keySet().stream()
- .noneMatch(t -> t.isAlive() && t.getName().endsWith("
- Chaos")));
+ .noneMatch(t -> t.isAlive() &&
t.getName().startsWith(prefix) && t.getName().endsWith(" - Chaos")));
}
@Test
@@ -505,9 +506,11 @@ class ChaosLifecycleTest extends ChaosTestSupport {
String id = chaos().addRule("route=slow lifecycle action=stop
duration=10m");
// act() is in the stop of the route, which waits for the exchange in
flight
awaitLifecycle(id, "acting");
+ String prefix = "Camel (" + context.getName() + ") ";
await().atMost(10, TimeUnit.SECONDS).until(() ->
Thread.getAllStackTraces().entrySet().stream()
- .anyMatch(e -> e.getKey().getName().endsWith(" - Chaos") &&
Arrays.stream(e.getValue())
- .anyMatch(f ->
f.getClassName().endsWith("DefaultShutdownStrategy"))));
+ .anyMatch(e -> e.getKey().getName().startsWith(prefix) &&
e.getKey().getName().endsWith(" - Chaos")
+ && Arrays.stream(e.getValue())
+ .anyMatch(f ->
f.getClassName().endsWith("DefaultShutdownStrategy"))));
ChaosManager chaos = chaos();
CompletableFuture<Void> stop = CompletableFuture.runAsync(() ->
context.stop());
@@ -523,7 +526,7 @@ class ChaosLifecycleTest extends ChaosTestSupport {
// no thread of chaos is left behind, and the route was not brought
back after the stop
await().atMost(10, TimeUnit.SECONDS)
.until(() -> Thread.getAllStackTraces().keySet().stream()
- .noneMatch(t -> t.isAlive() && t.getName().endsWith("
- Chaos")));
+ .noneMatch(t -> t.isAlive() &&
t.getName().startsWith(prefix) && t.getName().endsWith(" - Chaos")));
assertThat(status("slow")).isNotEqualTo(ServiceStatus.Started);
}
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosReplayTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosReplayTest.java
index 1d0aa41ab001..402fe14cbc8e 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosReplayTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosReplayTest.java
@@ -66,8 +66,8 @@ class ChaosReplayTest extends ChaosTestSupport {
@Override
public void configure() {
from("file:target/chaos-replay/inbox?initialDelay=0&delay=50").routeId("inbox").to("mock:inbox")
- .to("seda:ship");
-
from("seda:ship").routeId("ship").to("file:target/chaos-replay/archive");
+ .to("seda:ship?pollTimeout=10");
+
from("seda:ship?pollTimeout=10").routeId("ship").to("file:target/chaos-replay/archive");
from("file:target/chaos-replay/orders?move=done/${file:name}&initialDelay=0&delay=50").routeId("orders")
.to("mock:orders");
from("file:target/chaos-replay/kept?noop=true&initialDelay=0&delay=50").routeId("kept").to("mock:kept");
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosRouteCountsTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosRouteCountsTest.java
index 45640c5a2052..f9d296bbf2f2 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosRouteCountsTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosRouteCountsTest.java
@@ -39,8 +39,8 @@ class ChaosRouteCountsTest extends ChaosTestSupport {
return new RouteBuilder() {
@Override
public void configure() {
- from("direct:toSeda").routeId("toSeda").to("seda:queue");
- from("seda:queue").routeId("queue").to("mock:queue");
+
from("direct:toSeda").routeId("toSeda").to("seda:queue?pollTimeout=10");
+
from("seda:queue?pollTimeout=10").routeId("queue").to("mock:queue");
from("direct:multicast").routeId("multicast").multicast().to("direct:sub",
"direct:sub").end()
.to("mock:multicast");
from("direct:recipientList").routeId("recipientList").recipientList(constant("direct:sub,mock:rl"));
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosStubsTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosStubsTest.java
index ff8ac835e6ad..7c064ddedeb0 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosStubsTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/ChaosStubsTest.java
@@ -50,6 +50,7 @@ class ChaosStubsTest extends ChaosTestSupport {
private static StubComponent shadow() {
StubComponent stub = new StubComponent();
stub.setShadow(true);
+ stub.setDefaultPollTimeout(10);
return stub;
}
diff --git
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/dst/ChaosLifecycleDstTest.java
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/dst/ChaosLifecycleDstTest.java
index 13a1998e18cd..389714009252 100644
---
a/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/dst/ChaosLifecycleDstTest.java
+++
b/components/camel-chaos/src/test/java/org/apache/camel/component/chaos/dst/ChaosLifecycleDstTest.java
@@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.test.dst.Dst;
import org.apache.camel.test.dst.DstInstrument;
import org.apache.camel.test.dst.DstTest;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
alsoRewrite = {
"org.apache.camel.util.StopWatch",
"org.apache.camel.impl.engine.DefaultShutdownStrategy",
"org.apache.camel.support.task" })
+@Tag("not-parallel")
class ChaosLifecycleDstTest {
@DstTest(seeds = 200)
diff --git a/components/camel-test/camel-test-dst/src/main/docs/test-dst.adoc
b/components/camel-test/camel-test-dst/src/main/docs/test-dst.adoc
index 3bf2fdf08aeb..0fe66cfbe03a 100644
--- a/components/camel-test/camel-test-dst/src/main/docs/test-dst.adoc
+++ b/components/camel-test/camel-test-dst/src/main/docs/test-dst.adoc
@@ -610,15 +610,14 @@ and `dst.pulsar.subscribeFailRates` (the subscribe
failure rates of the Pulsar w
* Code on its own threads or on a third-party scheduler is outside the
harness; strict mode makes reaching it fail the
seed.
* One run per JVM at a time: the active run, and so the virtual clock, is a
static field, and every rewritten clock read
- in the JVM sees it, as does Camel core through `TimeSource` while the run is
open. A world must therefore not go into
- a module that runs its tests in parallel (`camel.surefire.parallel=true`, as
camel-jms and camel-sql do): the other
- tests in that surefire fork would read the virtual clock while a run is
active. For the same reason, a
- `CamelContext` left running in the same fork by an earlier non-DST test
would read the virtual time too and could
- fail a strict seed; stop it in that test. The harness enforces this: a second
- run while one is open fails, and a DST test refuses to start when JUnit runs
tests in parallel. A local world in
- such a module (camel-sjms, for example) can still be run alone, with
- `-Dtest=<the world> -Dcamel.surefire.parallel=false`, but it cannot be
committed there: the module's own build would
- fail it.
+ in the JVM sees it, as does Camel core through `TimeSource` while the run is
open. A world must therefore not run
+ concurrently with other tests in a module with
`camel.surefire.parallel=true`: the other tests in that surefire fork
+ would read the virtual clock while a run is active. To host a DST test in a
parallel module, tag the test with
+ `@Tag("not-parallel")` and configure Surefire with two executions — a
parallel pass excluding `not-parallel` and a
+ serial pass (`<groups>not-parallel</groups>`) with
`junit.jupiter.execution.parallel.enabled = false` in its
+ `<configurationParameters>`. For the same reason, a `CamelContext` left
running in the same fork by an earlier non-DST
+ test would read the virtual time too and could fail a strict seed; stop it
in that test. The harness enforces this: a second
+ run while one is open fails, and a DST test refuses to start when JUnit runs
tests in parallel.
* Locks do not exclude: every task runs on the test thread, so a
`ReentrantLock` or `synchronized` block held by a
blocked task is entered again by the tasks nested above it. A critical
section is atomic only because the fake does
not block inside it, and races between two code paths that each hold a lock
cannot be explored.