This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 a873d79f0dbd CAMEL-26818: camel-jbang-core - two slow test classes no
longer wait or parse for nothing (#31383)
a873d79f0dbd is described below
commit a873d79f0dbdeda1e0ad45eb481b17d3e197a930
Author: Adriano Machado <[email protected]>
AuthorDate: Sat Dec 5 11:44:07 2026 -0500
CAMEL-26818: camel-jbang-core - two slow test classes no longer wait or
parse for nothing (#31383)
Profiled with JFR, the two classes spent their time on two library defaults:
- SemanticCommandTest (16.3 s -> 2.6 s): the responder that plays the
integration waits three times per request with Awaitility, whose default
fixed poll interval of 100 ms is also its poll delay (4.3.0), so each wait
slept 100 ms before it looked, even when the file was already there. The
waits poll every 10 ms, as in ActionCommandTestSupport and
DebugCommandTest.
- CatalogDocExamplesTest (15.6 s -> about 10 s): new DefaultCamelCatalog()
has
no cache, so every one of the 1700+ examples parsed the JSON of its
components again (92% of the CPU of the test). The catalog of the test is
created with the cache, as CatalogLoader does for the catalogs of the CLI.
The 4 forks of the module are already balanced (54-58 s busy each) and CPU
bound, so the wall time of the module does not change much with 4 forks.
_Claude Code on behalf of Adriano Machado (@ammachado)_
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../dsl/jbang/core/commands/action/SemanticCommandTest.java | 12 +++++++++---
.../dsl/jbang/core/commands/ai/CatalogDocExamplesTest.java | 3 ++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/SemanticCommandTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/SemanticCommandTest.java
index b09bde83d89c..301038113f18 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/SemanticCommandTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/SemanticCommandTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.dsl.jbang.core.commands.action;
import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -900,15 +901,20 @@ class SemanticCommandTest {
var completed = new AtomicBoolean();
var responder = CompletableFuture.runAsync(() -> {
try {
+ // plays the integration, which polls for actions: by default
Awaitility waits 100 millis before it
+ // looks the first time, which three times per request was
most of the time of this test
while (!completed.get()) {
- await().atMost(5, TimeUnit.SECONDS).until(() ->
completed.get() || !actionFiles().isEmpty());
+ await().pollInterval(Duration.ofMillis(10)).atMost(5,
TimeUnit.SECONDS)
+ .until(() -> completed.get() ||
!actionFiles().isEmpty());
if (completed.get()) {
break;
}
Path request = actionFiles().get(0);
- await().atMost(5, TimeUnit.SECONDS).until(() ->
Files.size(request) > 0);
+ await().pollInterval(Duration.ofMillis(10)).atMost(5,
TimeUnit.SECONDS)
+ .until(() -> Files.size(request) > 0);
reply(request,
response.apply(json(Files.readString(request))));
- await().atMost(5, TimeUnit.SECONDS).until(() ->
!Files.exists(request));
+ await().pollInterval(Duration.ofMillis(10)).atMost(5,
TimeUnit.SECONDS)
+ .until(() -> !Files.exists(request));
}
} catch (Exception e) {
throw new RuntimeException(e);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocExamplesTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocExamplesTest.java
index 24e48c9a2e93..ce0865089ff3 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocExamplesTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocExamplesTest.java
@@ -59,7 +59,8 @@ class CatalogDocExamplesTest {
@BeforeAll
static void setup() {
- catalog = new DefaultCamelCatalog();
+ // with the cache, as the catalogs of the CLI: without it each example
parses the JSON of its components again
+ catalog = new DefaultCamelCatalog(true);
}
@Test