CAMEL-24387: Add createSingletonService() and migrate all tests to singletons - #22294
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
4061f61 to
36d7b4f
Compare
|
LGTM, but this one likely needs a full CI test to make sure it runs fine. |
Yes, I'm running tests locally for each modified factory to make sure it works. It's not completely done yet... |
3f7fe53 to
d68f67d
Compare
16de556 to
fdb9557
Compare
7ced72a to
633b0ae
Compare
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 241 tested, 27 compile-only — current: 239 all testedMaveniverse Scalpel detected 268 affected modules (current approach: 239).
|
Add a createSingletonService() method to all test-infra service factories. These return a JVM-wide singleton instance backed by SingletonService, which prevents duplicate container startups when multiple test classes share the same service (especially useful for parallel test execution via mvnd). Each factory's singleton wrapper delegates all service-specific interface methods to the underlying service instance. Also change SingletonService.shutdown() from throwing IllegalArgumentException to a debug-level no-op, since JUnit's @RegisterExtension lifecycle calls shutdown() after each test class. The actual cleanup happens via JVM shutdown hook. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ce() Switch all integration test classes to use the new singleton service factories. This ensures each Testcontainers service is started only once per JVM, which: - Speeds up test suites by avoiding redundant container startups - Enables parallel test execution (mvnd) without container conflicts - Reduces CI resource consumption Test isolation fixes for shared singleton instances: - ZooKeeper ConsumeDataIT: use deleteAll() instead of delete() to handle nodes with children from shared instances - Google PubSub: catch AlreadyExistsException for topics/subscriptions that may already exist in the shared emulator - Hashicorp Vault: use per-class secretPath() to avoid data collisions between tests sharing the same Vault instance - Consul ConsulHealthIT: use @RegisterExtension instead of manual lifecycle management - Google PubSub ITs: use unique topic/subscription names per test class Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9d607c8 to
840839f
Compare
|
Hi @gnodet, I rebased the branch on latest main (only one conflict in Also created CAMEL-24387 to track this. While rebasing I checked for gaps — there are 9 service factories still missing Existed before the PR (missed):
Added after the PR was created:
Claude Code on behalf of Claus Ibsen |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
I added
The other 6 from my earlier comment don't need it:
Claude Code on behalf of Claus Ibsen |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…leton services Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
⏺ The CI failure is not related to the singleton changes. Here's what happened:
The PR's changes (test-infra singletons) compiled and ran fine — the failure is in an unrelated component (camel-paho-mqtt5) that was included in the CI build matrix but wasn't modified by this PR. |
Summary
Add
createSingletonService()to 32 test-infra service factories and migrate all integration tests to use them. This ensures each Testcontainers service is started only once per JVM, enabling parallel test execution via mvnd without container conflicts.Commit 1: Add createSingletonService() to 32 test-infra service factories
createSingletonService()method to all test-infra service factories, returning a JVM-wide singleton backed bySingletonServicewith lazy initialization (holder idiom) and JVM shutdown hook cleanupSingletonService.shutdown()from throwingIllegalArgumentExceptionto a debug-level no-op, since JUnit's@RegisterExtensionlifecycle callsshutdown()after each test classCommit 2: Migrate all test classes from createService() to createSingletonService()
ConsumeDataIT: usedeleteAll()instead ofdelete()to handle nodes with childrenAlreadyExistsExceptionfor topics/subscriptions in shared emulatorsecretPath()to avoid data collisionsConsulHealthIT: use@RegisterExtensioninstead of manual lifecycleTest plan