Skip to content

CAMEL-27029: camel-launcher - speed up the tests of the module - #30198

Merged
apupier merged 1 commit into
apache:mainfrom
apupier:CAMEL-27029-camel-launcher-test-speedup
Nov 16, 2026
Merged

apupier merged 1 commit into
apache:mainfrom
apupier:CAMEL-27029-camel-launcher-test-speedup

Conversation

@apupier

@apupier apupier commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

JIRA: https://issues.apache.org/jira/browse/CAMEL-27029

Motivation

camel-launcher is a leaf module on the critical path of the build: it cannot start before camel-jbang-core and all the pre-installed plugins are built. Its tests make up most of its build time (about 30s of the 43s of a full mvn install on 22 cores), and almost all of that is spent spawning processes (java, sh, bash), not running launcher code.

Changes (test-only, 2 files)

WebsiteManifestGeneratorTest

  • Every test launched the generator as a source file (java WebsiteManifestGenerator.java), which recompiles it in memory on each call: about 0.45s wall and 1.8s CPU per launch, 51 launches in the class.
  • The generator is now compiled once in a @BeforeAll (JDK in-process compiler) and launched with -cp and -XX:TieredStopAtLevel=1 (about 0.03s per launch).
  • The compile passes -proc:none (review feedback from @davsclaus): the generator only uses JDK classes, so no annotation processor of the test class path must run. The output is identical with and without it.
  • stableWritesVersionAndLatestManifests keeps the source-file launch, since that is how camel-package.sh runs the generator.
  • The class goes from 23.7s to 3.4s when run alone.

WebsiteInstallTest.PosixShell

  • The 86 tests ran one after the other. They already share no state: each has its own @TempDir, HOME and HTTPS server on an ephemeral port, the TLS certificate is created once behind a lock, and no system property is set.
  • The nested class is now @Execution(ExecutionMode.CONCURRENT), on top of the class-level parallelism the module already enables (camel.surefire.parallel=true).
  • 17s to 3s on 22 cores, 15.8s to 5.1s on 4 cores. 4 runs per core count with -Dsurefire.rerunFailingTestsCount=0, no failure.
  • The Windows PowerShell nested class is left as is: its @AfterEach restores the user PATH in the registry, which is shared state, and I could not run it on Linux.

Measurements

mvn install -o on camel-launcher, CPUs selected with taskset, no camel on the PATH, 418 tests (47 skipped on Linux) passing in every run:

Cores Before After
22 38.3-40.7s ~22s
4 53.7-54.1s ~26s

The "after" figures are a single run per core count. Gains on CI will differ, as the module competes for CPU with others.

Not changed on purpose

  • SelfUpdateIntegrationTest sets the JVM-global user.home and camel.launcher.jar system properties.
  • PackagePlanTest shares fixed files under target/ that its @AfterEach deletes.

Neither can run its methods concurrently without a rework (the remaining ~9s and ~6s on 22 cores), so they are left for a possible follow-up.

Notes for reviewers

  • ToolProvider.getSystemJavaCompiler() needs a JDK at test time, which the Camel build already requires.
  • PackageNativeValidationTest looked slow locally only because camel-validate.sh runs the host's real camel when one is on the PATH (about 1.4s per call). It takes 0.6s without one, so it is not touched here.
  • No upgrade guide or generated file is affected. mvn formatter:format impsort:sort produces no further diff.

AI-generated: IBM Bob 2.2.1 on behalf of @apupier.

@apupier
apupier requested review from davsclaus and gnodet November 16, 2026 11:21

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, well-measured speedup. One test keeps the source-file launch (java WebsiteManifestGenerator.java), so the path camel-package.sh uses is still covered. The concurrency analysis for PosixShell also holds up: every test has its own @TempDir, HOME and HTTPS server on an ephemeral port, WebsiteInstallerFixture.sharedTls() is created once under a lock, and no system property is set. The Package-native validation job already ran WebsiteInstallTest concurrently on macOS and passed.

  1. [Nit, optional] WebsiteManifestGeneratorTest.java:90: the in-process javac has no -classpath, so it falls back to java.class.path, the module's full test classpath, and javac still runs any annotation processor it discovers there. The generator only uses JDK classes, so adding "-proc:none" keeps the compile isolated and quiet:
    compiler.run(null, null, null, "-proc:none", "-d", generatorClasses.toString(), GENERATOR.toString())

Thanks for listing the classes left out on purpose (SelfUpdateIntegrationTest, PackagePlanTest) and why.

Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

@github-actions github-actions Bot added the dsl label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@apupier
apupier force-pushed the CAMEL-27029-camel-launcher-test-speedup branch from 559e586 to 2da1243 Compare November 16, 2026 12:20
camel-launcher is a leaf module on the critical path of the build: it
waits for camel-jbang-core and all the pre-installed plugins. Its tests
take about 30s of the 43s of a full `mvn install` on 22 cores (and about
45s of 54s on 4 cores). Almost all of it is spent spawning processes, not
running launcher code. Two test-only changes remove most of it:

WebsiteManifestGeneratorTest

Every test launched the generator as a source file (`java
WebsiteManifestGenerator.java`), which recompiles it in memory each time:
about 0.45s wall and 1.8s CPU per launch, 51 launches in the class. The
generator is now compiled once in a @BeforeAll with the JDK compiler and
launched with -cp and -XX:TieredStopAtLevel=1 (about 0.03s). The
compile uses -proc:none: the generator only uses JDK classes, so no
annotation processor of the test class path (log4j-core registers one)
must run. One test keeps the source-file launch, as it is the way
camel-package.sh runs the generator. The class goes from 23.7s to 3.4s when run alone.

WebsiteInstallTest.PosixShell

The 86 tests ran one after the other, each running install.sh against its
own local HTTPS server. They already share no state: every test has its
own @tempdir, HOME and server on an ephemeral port, the TLS certificate
is created once behind a lock, and nothing sets system properties. The
nested class is now @execution(ExecutionMode.CONCURRENT), on top of the
class-level parallelism the module already enables. It goes from 17s to
3s on 22 cores and from 15.8s to 5.1s on 4 cores, 4 runs per core count
without a failure. The Windows PowerShell nested class is left as is: its
@AfterEach restores the user PATH in the registry, which is shared state.

Measured on the module with `mvn install -o` (22 and 4 cores selected
with taskset, no `camel` on the PATH, 418 tests, 47 skipped on Linux):

  cores   before     after
  22      38.3-40.7s ~22s
  4       53.7-54.1s ~26s

Not changed on purpose: SelfUpdateIntegrationTest sets the user.home and
camel.launcher.jar system properties, and PackagePlanTest shares fixed
files under target/ that its @AfterEach deletes, so neither can run its
tests concurrently without a rework. They are the remaining 9s and 6s.

Co-authored-by: IBM Bob 2.2.1
Signed-off-by: Aurélien Pupier <apupier@ibm.com>
@apupier
apupier force-pushed the CAMEL-27029-camel-launcher-test-speedup branch from 2da1243 to 3725656 Compare November 16, 2026 12:20

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-only speedup. The concurrency analysis holds up: each PosixShell test creates its own @TempDir, its own WebsiteInstallerFixture on a private port, and its own home directory. sharedTls() uses a double-checked locking pattern with a volatile field — thread-safe. Making the nested class @Execution(CONCURRENT) is correct.

compileGenerator() already includes -proc:none (addressing davsclaus's nit). The static @TempDir generatorClasses is written once in @BeforeAll and read-only after — no data race.

One low-severity observation: ToolProvider.getSystemJavaCompiler() returns null when running on a JRE rather than a JDK. The current code calls compiler.run(...) immediately without a null guard, which produces a NullPointerException with no diagnostic message. In practice this is a non-issue (Camel requires JDK 21+ and Maven always runs with the JDK), but an explicit guard would make the failure self-explaining:

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
assumeTrue(compiler != null, "javac not available; run tests with a JDK, not a JRE");

This is optional — the existing behavior is acceptable given the build requirements.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-launcher

🔬 Scalpel shadow comparison — Scalpel: 0 of 726 tested, 0 compile-only — current: 1 all tested

Maveniverse Scalpel detected 0 affected modules (current approach: 1).

Skip-tests mode would test 0 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)

Modules only in current approach (1)
  • camel-launcher-container
Modules Scalpel would test (0)

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-launcher. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (2 modules, 50.8s total)

Total reactor time: 50.8s

Module Duration Status
Camel :: Launcher 49.9s SUCCESS
Camel :: Launcher :: Container 1.0s SUCCESS

Top 20 slowest modules:

  • Camel :: Launcher (49.9s)
  • Camel :: Launcher :: Container (1.0s)

⚙️ View full build and test results

@oscerd oscerd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, targeted test speedup, and it buys the time without giving up coverage.

Both changes go after the two costs you identify, which are process spawning and repeated compilation, not launcher logic:

  • WebsiteInstallTest runs with @Execution(ExecutionMode.CONCURRENT). Since almost all of its wall time is spent waiting on spawned java/sh/bash processes, overlapping them is exactly where the slack is, and each test drives its own process so there is no shared launcher state to collide.
  • WebsiteManifestGeneratorTest compiles the generator once in @BeforeAll and reuses the class, instead of launching it as a source file so javac recompiles it in memory on every call. The ~0.5s wall / ~2s CPU per test against ~0.03s for the compiled class is a real saving on a leaf module that gates the build, and -proc:none is the right touch given the generator only touches JDK classes, so no annotation processor on the test class path should run.

The tests exercise the same behaviour, so this is pure run-time, not a coverage cut. The one thing that makes or breaks the concurrent run is that the install tests stay independent (their own temp dirs and processes, no shared port or file), and the green build says they do. Worth having on the critical path.

Claude Code on behalf of oscerd

@apupier
apupier merged commit 80bc80e into apache:main Nov 16, 2026
16 of 17 checks passed

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR

Approve. The only change since my last review is the -proc:none nit, now in WebsiteManifestGeneratorTest.java:90-94 with a comment saying why. CI is green, including the native and POSIX/Windows validator jobs.

Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants