Repository navigation
CAMEL-27029: camel-launcher - speed up the tests of the module - #30198
Conversation
davsclaus
left a comment
There was a problem hiding this comment.
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.
- [Nit, optional]
WebsiteManifestGeneratorTest.java:90: the in-processjavachas no-classpath, so it falls back tojava.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.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
559e586 to
2da1243
Compare
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>
2da1243 to
3725656
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
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.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 0 of 726 tested, 0 compile-only — current: 1 all testedMaveniverse 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)
Modules Scalpel would test (0)
💡 Manual integration tests recommended:
All tested modules (2 modules, 50.8s total)Total reactor time: 50.8s
Top 20 slowest modules:
|
oscerd
left a comment
There was a problem hiding this comment.
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:
WebsiteInstallTestruns with@Execution(ExecutionMode.CONCURRENT). Since almost all of its wall time is spent waiting on spawnedjava/sh/bashprocesses, overlapping them is exactly where the slack is, and each test drives its own process so there is no shared launcher state to collide.WebsiteManifestGeneratorTestcompiles the generator once in@BeforeAlland 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:noneis 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
davsclaus
left a comment
There was a problem hiding this comment.
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.
JIRA: https://issues.apache.org/jira/browse/CAMEL-27029
Motivation
camel-launcheris a leaf module on the critical path of the build: it cannot start beforecamel-jbang-coreand all the pre-installed plugins are built. Its tests make up most of its build time (about 30s of the 43s of a fullmvn installon 22 cores), and almost all of that is spent spawning processes (java,sh,bash), not running launcher code.Changes (test-only, 2 files)
WebsiteManifestGeneratorTestjava 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.@BeforeAll(JDK in-process compiler) and launched with-cpand-XX:TieredStopAtLevel=1(about 0.03s per launch).-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.stableWritesVersionAndLatestManifestskeeps the source-file launch, since that is howcamel-package.shruns the generator.WebsiteInstallTest.PosixShell@TempDir,HOMEand HTTPS server on an ephemeral port, the TLS certificate is created once behind a lock, and no system property is set.@Execution(ExecutionMode.CONCURRENT), on top of the class-level parallelism the module already enables (camel.surefire.parallel=true).-Dsurefire.rerunFailingTestsCount=0, no failure.@AfterEachrestores the user PATH in the registry, which is shared state, and I could not run it on Linux.Measurements
mvn install -ooncamel-launcher, CPUs selected withtaskset, nocamelon thePATH, 418 tests (47 skipped on Linux) passing in every run: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
SelfUpdateIntegrationTestsets the JVM-globaluser.homeandcamel.launcher.jarsystem properties.PackagePlanTestshares fixed files undertarget/that its@AfterEachdeletes.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.PackageNativeValidationTestlooked slow locally only becausecamel-validate.shruns the host's realcamelwhen one is on thePATH(about 1.4s per call). It takes 0.6s without one, so it is not touched here.mvn formatter:format impsort:sortproduces no further diff.AI-generated: IBM Bob 2.2.1 on behalf of @apupier.