Add createSingletonService() and migrate all tests to singletons#22294
Add createSingletonService() and migrate all tests to singletons#22294gnodet wants to merge 2 commits intoapache:mainfrom
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:
Build reactor — dependencies compiled but only changed modules were tested (63 modules)
|
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>
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