apupier opened a new pull request, #29574: URL: https://github.com/apache/camel/pull/29574
# Description JIRA: https://issues.apache.org/jira/browse/CAMEL-26819 The `camel-http` "build and test" step takes ~314s on CI and is on the critical path (and the CPU is close to 100% at that time, because many other modules are built in parallel). Running the module tests sequentially locally took **274s**; profiling the surefire reports showed that **~255s** came from only five OAuth2 test classes, every other class takes less than 1s: | Class | Before | |---|---| | `HttpOAuth2TokenCachingTest` | 135s | | `HttpOAuth2CachedTokensKeyTest` | 65s | | `HttpOAuth2RedirectTokenLeakTest` | 40s | | `HttpOAuth2ResourceIndicatorTest` | 10s | | `HttpOAuth2ScopeTest` | 5s | ## Root cause `HttpServer.close()` (httpcore5) defaults to `CloseMode.GRACEFUL`, which waits up to 5s for the open keep-alive connections to terminate. The tests close one or two embedded servers each, so every test paid 5-10s. ## Changes (test code only) - **OAuth2 tests**: close the embedded servers with `CloseMode.IMMEDIATE` (new `BaseHttpTest#closeImmediately` helper). The tests still close the token endpoint before the second request, so they still verify that a cached token is reused or requested again. - **Fixed waits replaced by conditional waits** (more robust on a loaded CI machine than shorter sleeps): - `HttpSOTimeoutTest`, `HttpPollingConsumerTest`: `DelayValidationHandler` (timed delay, removed) replaced by `BlockingValidationHandler`, which answers only when a `CountDownLatch` is released. Success cases release it before the call; timeout cases never do, so the outcome no longer depends on CPU load. - `HttpConcurrentTest`: handler `Thread.sleep` replaced by a `CountDownLatch(poolSize)` that proves the requests are really concurrent. - `HttpProducerRestartTest`: `Thread.sleep(1000)` replaced by an Awaitility wait (`atMost` 10s) for the route to be stopped. - `HttpsTwoComponentsSslContextParametersGetTest`: `Thread.sleep(500)` removed (`context.start()` is synchronous). ## Results (local, 22 cores, module `mvn clean install -Psourcecheck`) | | Before | After | |---|---|---| | module tests (sequential) | ~274s | ~19s | | `mvn clean install -DskipTests` (compile, codegen, jar...) | 9s | 9s | 299 tests + 9 isolated-JVM tests pass, 0 failures. ## Not retained - JUnit class-level parallelism (`camel.surefire.parallel=true` + `@ResourceLock` on tests touching `javax.net.ssl.*` system properties and the shared `target/camel-cache` directory) was implemented and measured: once the above is fixed it only saves ~6s locally (20s -> 14s) and less on a saturated CI, so it was dropped to avoid the extra risk from shared JVM state. - Trimming test dependencies (Spring, Jetty test-infra, ...) was evaluated: each is used by a single test class, and the gain would be negligible. ## Target - [x] I checked that the commit is targeting the correct branch (`main`) - [x] I have run `mvn clean install -Psourcecheck` locally for the module (formatting, imports, license) and tests pass - [x] Test-only change: no production code, generated files, documentation or upgrade guide impacted --- _Claude-style disclosure: this PR description and the code changes were generated by **IBM Bob 2.2.1** (AI coding assistant) on behalf of @apupier._ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
