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
commit 4ccdf54dbb6ebfff6e1316c614e47205b4134eb0 Author: Aurélien Pupier <[email protected]> AuthorDate: Mon Nov 16 16:08:21 2026 +0100 CAMEL-26818: camel-jbang-core - optimize long test classes - CatalogDocExamplesTest: validate doc page examples in parallel across cores (21s -> 4s) - DependencyUpdateTest: use pre-built fixture project instead of repeated init+export - ExportApiTest: reduce repeated export iterations for GC release test from 20 to 5 (6s -> 3s) - CliRunnerTest: reduce busy command duration and runner timeouts (6s -> 3.4s) Co-authored-by: IBM Bob 2.2.1 Signed-off-by: Aurélien Pupier <[email protected]> --- .../dsl/jbang/core/commands/CliRunnerTest.java | 10 +++++----- .../jbang/core/commands/DependencyUpdateTest.java | 23 +--------------------- .../dsl/jbang/core/commands/ExportApiTest.java | 4 ++-- .../core/commands/ai/CatalogDocExamplesTest.java | 17 ++++++++++------ 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CliRunnerTest.java b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CliRunnerTest.java index cf7beb856358..22da8160b275 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CliRunnerTest.java +++ b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CliRunnerTest.java @@ -106,18 +106,18 @@ class CliRunnerTest { Files.writeString(CommandLineHelper.getCamelDir().resolve(PID + "-status.json"), "{\"context\":{\"name\":\"test\",\"version\":\"4.24.0\",\"phase\":5}}"); - CliRunner.CliResult result = CliRunner.run(List.of("cmd", "gc", Long.toString(PID), "--timeout=2000"), 300); + CliRunner.CliResult result = CliRunner.run(List.of("cmd", "gc", Long.toString(PID), "--timeout=2000"), 100); assertThat(result.timedOut()).isTrue(); assertThat(result.exitCode()).isEqualTo(CliExitCode.TIMEOUT); // after what the interrupted command printed assertThat(result.stderr()) - .endsWith("ERROR: camel cmd gc " + PID + " --timeout=2000 did not finish within 300 millis"); + .endsWith("ERROR: camel cmd gc " + PID + " --timeout=2000 did not finish within 100 millis"); } @Test void commandThatIgnoresTheInterruptIsReported() { - CliRunner.CliResult result = CliRunner.run(List.of("busy"), 300); + CliRunner.CliResult result = CliRunner.run(List.of("busy"), 100); assertThat(result.exitCode()).isEqualTo(CliExitCode.TIMEOUT); assertThat(result.stderr()).endsWith("it has not stopped yet, and the next command waits until it has"); @@ -129,7 +129,7 @@ class CliRunnerTest { CliRunner.CliResult result; // another command runs meanwhile synchronized (CliRunner.LOCK) { - result = CliRunner.run(List.of("config", "set", "foo=bar"), 300); + result = CliRunner.run(List.of("config", "set", "foo=bar"), 100); } assertThat(result.exitCode()).isEqualTo(CliExitCode.TIMEOUT); @@ -214,7 +214,7 @@ class CliRunnerTest { @Override public Integer doCall() { - long end = System.currentTimeMillis() + 3000; + long end = System.currentTimeMillis() + 500; while (System.currentTimeMillis() < end) { try { TimeUnit.MILLISECONDS.sleep(end - System.currentTimeMillis()); diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java index 6a3bbc0881f6..05b64fe43487 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java +++ b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java @@ -61,7 +61,7 @@ class DependencyUpdateTest extends CamelCommandBaseTestSupport { @ParameterizedTest @MethodSource("exportRuntimeProvider") void shouldDependencyUpdate(RuntimeType rt) throws Exception { - prepareMavenProject(rt); + prepareFixtureProject(rt); checkNoUpdateOnFreshlyGeneratedproject(rt); addArangodbToCamelFile(); checkOneDependencyAddedForArangoDb(rt); @@ -114,27 +114,6 @@ class DependencyUpdateTest extends CamelCommandBaseTestSupport { Assertions.assertEquals("No updates to pom.xml", lines.get(0)); } - private void prepareMavenProject(RuntimeType rt) throws Exception { - StringPrinter initCommandPrinter = new StringPrinter(); - Init initCommand = new Init(new CamelJBangMain().withPrinter(initCommandPrinter)); - String camelFilePath = new File(workingDir, "my.camel.yaml").getAbsolutePath(); - CommandLineTestHelper.parse(initCommand, camelFilePath); - Assertions.assertEquals(0, initCommand.doCall(), initCommandPrinter.getLines().toString()); - - StringPrinter exportCommandPrinter = new StringPrinter(); - Export exportCommand = new Export(new CamelJBangMain().withPrinter(exportCommandPrinter)); - CommandLineTestHelper.parse(exportCommand, - "--gav=examples:route:1.0.0", - "--dir=" + workingDir, - // the directory has the route that camel init created, which the export replaces with the project - "--clean-dir", "--yes", - "--camel-version=4.13.0", - "--runtime=" + rt.runtime(), - CamelCommandBaseTestSupport.quarkusExtRegistry(), - camelFilePath); - Assertions.assertEquals(0, exportCommand.doCall(), exportCommandPrinter.getLines().toString()); - } - // ==================== explicit route file as positional argument ==================== @ParameterizedTest diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportApiTest.java b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportApiTest.java index af8c245a952a..d02d062a6812 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportApiTest.java +++ b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportApiTest.java @@ -98,12 +98,12 @@ class ExportApiTest { } }) { tracker.open(); - for (int i = 1; i <= 20; i++) { + for (int i = 1; i <= 5; i++) { export(i); } } - assertThat(contexts).hasSizeGreaterThanOrEqualTo(20); + assertThat(contexts).hasSizeGreaterThanOrEqualTo(5); // nothing holds on to the CamelContext of a silent run once its export is done await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> { System.gc(); 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..d9429a0f9f9c 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 @@ -83,13 +83,13 @@ class CatalogDocExamplesTest { } private static DocExamples validate(List<String> pages) { - int examples = 0; - List<String> failures = new ArrayList<>(); - for (String page : pages) { + return pages.parallelStream().map(page -> { String doc = catalog.asciiDoc(page); if (doc == null) { - continue; + return new DocExamples(0, List.of()); } + int examples = 0; + List<String> failures = new ArrayList<>(); List<String> blocks = DocBlocks.examples(doc); for (int n = 0; n < blocks.size(); n++) { String yaml = blocks.get(n); @@ -102,7 +102,12 @@ class CatalogDocExamplesTest { failures.add(page + " example " + (n + 1) + ": " + msg); } } - } - return new DocExamples(examples, failures); + return new DocExamples(examples, failures); + }).reduce(new DocExamples(0, List.of()), (a, b) -> { + List<String> combined = new ArrayList<>(a.failures().size() + b.failures().size()); + combined.addAll(a.failures()); + combined.addAll(b.failures()); + return new DocExamples(a.examples() + b.examples(), combined); + }); } }
