Skip to content

Add createSingletonService() and migrate all tests to singletons#22294

Draft
gnodet wants to merge 2 commits intoapache:mainfrom
gnodet:mesquite-planet
Draft

Add createSingletonService() and migrate all tests to singletons#22294
gnodet wants to merge 2 commits intoapache:mainfrom
gnodet:mesquite-planet

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Mar 27, 2026

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

  • Add a createSingletonService() method to all test-infra service factories, returning a JVM-wide singleton backed by SingletonService with lazy initialization (holder idiom) and JVM shutdown hook cleanup
  • Each factory's singleton wrapper delegates all service-specific interface methods to the underlying instance
  • Change SingletonService.shutdown() from throwing IllegalArgumentException to a debug-level no-op, since JUnit's @RegisterExtension lifecycle calls shutdown() after each test class

Commit 2: Migrate all test classes from createService() to createSingletonService()

  • Switch all integration test classes to use the new singleton service factories
  • Test isolation fixes for shared singleton instances:
    • ZooKeeper ConsumeDataIT: use deleteAll() instead of delete() to handle nodes with children
    • Google PubSub: catch AlreadyExistsException for topics/subscriptions in shared emulator
    • Hashicorp Vault: use per-class secretPath() to avoid data collisions
    • Consul ConsulHealthIT: use @RegisterExtension instead of manual lifecycle
    • Google PubSub ITs: use unique topic/subscription names per test class

Test plan

  • CI passes with all tests using singleton services
  • Verify no test isolation issues in parallel execution (mvnd)

@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 build-all, build-dependents, 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.

@gnodet gnodet changed the title Add createSingletonService() to all test-infra service factories Add createSingletonService() to test-infra factories and migrate tests Mar 27, 2026
@gnodet gnodet changed the title Add createSingletonService() to test-infra factories and migrate tests Add createSingletonService() to test-infra service factories Mar 27, 2026
@gnodet gnodet changed the title Add createSingletonService() to test-infra service factories Add createSingletonService() to test-infra factories and migrate tests Mar 27, 2026
@gnodet gnodet force-pushed the mesquite-planet branch 5 times, most recently from 4061f61 to 36d7b4f Compare March 27, 2026 15:22
@orpiske
Copy link
Copy Markdown
Contributor

orpiske commented Mar 27, 2026

LGTM, but this one likely needs a full CI test to make sure it runs fine.

@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented Mar 27, 2026

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.
The one that don't work will have a comment:
https://github.com/apache/camel/pull/22294/changes#diff-4677c71b137d3f514242cb2407edc44042f5f8068594d75177c07522fb0de878R48

It's not completely done yet...

@gnodet gnodet force-pushed the mesquite-planet branch 3 times, most recently from 3f7fe53 to d68f67d Compare March 27, 2026 20:40
@gnodet gnodet changed the title Add createSingletonService() to test-infra factories and migrate tests Add createSingletonService() to all test-infra factories and migrate all tests Mar 27, 2026
@gnodet gnodet force-pushed the mesquite-planet branch 3 times, most recently from 16de556 to fdb9557 Compare March 27, 2026 21:45
@gnodet gnodet changed the title Add createSingletonService() to all test-infra factories and migrate all tests Make container names unique and migrate all tests to singletons Mar 27, 2026
@gnodet gnodet force-pushed the mesquite-planet branch 5 times, most recently from 7ced72a to 633b0ae Compare April 2, 2026 15:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

🧪 CI tested the following changed modules:

  • components/camel-ai/camel-chatscript
  • components/camel-ai/camel-docling
  • components/camel-ai/camel-kserve
  • components/camel-ai/camel-langchain4j-agent
  • components/camel-ai/camel-openai
  • components/camel-ai/camel-tensorflow-serving
  • components/camel-arangodb
  • components/camel-azure/camel-azure-storage-blob
  • components/camel-azure/camel-azure-storage-datalake
  • components/camel-azure/camel-azure-storage-queue
  • components/camel-consul
  • components/camel-google/camel-google-pubsub
  • components/camel-hashicorp-vault
  • components/camel-hazelcast
  • components/camel-iggy
  • components/camel-jms
  • components/camel-kafka
  • components/camel-keycloak
  • components/camel-ldif
  • components/camel-minio
  • components/camel-mongodb-gridfs
  • components/camel-nats
  • components/camel-paho-mqtt5
  • components/camel-pqc
  • components/camel-redis
  • components/camel-solr
  • components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat
  • components/camel-spring-parent/camel-spring-rabbitmq
  • components/camel-spring-parent/camel-spring-redis
  • components/camel-xmpp
  • components/camel-zookeeper-master
  • components/camel-zookeeper
  • dsl/camel-jbang/camel-jbang-it
  • test-infra/camel-test-infra-azure-storage-blob
  • test-infra/camel-test-infra-azure-storage-datalake
  • test-infra/camel-test-infra-azure-storage-queue
  • test-infra/camel-test-infra-cassandra
  • test-infra/camel-test-infra-chatscript
  • test-infra/camel-test-infra-cli
  • test-infra/camel-test-infra-common
  • test-infra/camel-test-infra-consul
  • test-infra/camel-test-infra-docling
  • test-infra/camel-test-infra-google-pubsub
  • test-infra/camel-test-infra-hashicorp-vault
  • test-infra/camel-test-infra-hazelcast
  • test-infra/camel-test-infra-ibmmq
  • test-infra/camel-test-infra-iggy
  • test-infra/camel-test-infra-ignite
  • test-infra/camel-test-infra-keycloak
  • test-infra/camel-test-infra-mcp-everything
  • test-infra/camel-test-infra-microprofile-lra
  • test-infra/camel-test-infra-minio
  • test-infra/camel-test-infra-mosquitto
  • test-infra/camel-test-infra-nats
  • test-infra/camel-test-infra-openldap
  • test-infra/camel-test-infra-postgres
  • test-infra/camel-test-infra-rabbitmq
  • test-infra/camel-test-infra-redis
  • test-infra/camel-test-infra-solr
  • test-infra/camel-test-infra-tensorflow-serving
  • test-infra/camel-test-infra-triton
  • test-infra/camel-test-infra-xmpp
  • test-infra/camel-test-infra-zookeeper

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • components/camel-ai/camel-docling: 6 test(s) disabled on GitHub Actions
  • components/camel-ai/camel-kserve: 1 test(s) disabled on GitHub Actions
  • components/camel-ai/camel-langchain4j-agent: 14 test(s) disabled on GitHub Actions
  • components/camel-ai/camel-openai: 6 test(s) disabled on GitHub Actions
  • components/camel-arangodb: 9 test(s) disabled on GitHub Actions
  • components/camel-iggy: 4 test(s) disabled on GitHub Actions
  • components/camel-jms: 8 test(s) disabled on GitHub Actions
  • components/camel-kafka: 3 test(s) disabled on GitHub Actions
  • components/camel-nats: 9 test(s) disabled on GitHub Actions
  • components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat: 21 test(s) disabled on GitHub Actions
  • components/camel-xmpp: 6 test(s) disabled on GitHub Actions
  • dsl/camel-jbang/camel-jbang-it: 1 test(s) disabled on GitHub Actions
Build reactor — dependencies compiled but only changed modules were tested (63 modules)
  • Camel :: AI :: ChatScript
  • Camel :: AI :: Docling
  • Camel :: AI :: KServe
  • Camel :: AI :: LangChain4j :: Agent
  • Camel :: AI :: OpenAI
  • Camel :: AI :: TensorFlow Serving
  • Camel :: ArangoDB
  • Camel :: Azure :: Storage Blob
  • Camel :: Azure :: Storage Datalake
  • Camel :: Azure :: Storage Queue
  • Camel :: Consul
  • Camel :: Google :: PubSub
  • Camel :: Hashicorp :: Key Vault
  • Camel :: HazelCast
  • Camel :: Iggy
  • Camel :: JBang :: Integration tests
  • Camel :: JMS
  • Camel :: Kafka
  • Camel :: Keycloak
  • Camel :: LDIF
  • Camel :: MinIO
  • Camel :: MongoDB GridFS
  • Camel :: Nats
  • Camel :: PQC
  • Camel :: Paho MQTT 5
  • Camel :: Redis
  • Camel :: Solr
  • Camel :: Spring AI :: Chat
  • Camel :: Spring RabbitMQ
  • Camel :: Spring Redis
  • Camel :: Test Infra :: Azure Storage Blob
  • Camel :: Test Infra :: Azure Storage Datalake
  • Camel :: Test Infra :: Azure Storage Queue
  • Camel :: Test Infra :: Cassandra
  • Camel :: Test Infra :: ChatScript
  • Camel :: Test Infra :: Cli (Camel JBang)
  • Camel :: Test Infra :: Common
  • Camel :: Test Infra :: Consul
  • Camel :: Test Infra :: Docling
  • Camel :: Test Infra :: Google Pub/Sub
  • Camel :: Test Infra :: Hashicorp Vault
  • Camel :: Test Infra :: Hazelcast
  • Camel :: Test Infra :: IBM MQ
  • Camel :: Test Infra :: Iggy
  • Camel :: Test Infra :: Ignite
  • Camel :: Test Infra :: Keycloak
  • Camel :: Test Infra :: MCP Everything
  • Camel :: Test Infra :: Microprofile LRA
  • Camel :: Test Infra :: Minio
  • Camel :: Test Infra :: Mosquitto
  • Camel :: Test Infra :: Nats
  • Camel :: Test Infra :: Openladp
  • Camel :: Test Infra :: Postgres
  • Camel :: Test Infra :: RabbitMQ
  • Camel :: Test Infra :: Redis
  • Camel :: Test Infra :: Solr
  • Camel :: Test Infra :: TensorFlow Serving
  • Camel :: Test Infra :: Triton Inference Server
  • Camel :: Test Infra :: Xmpp
  • Camel :: Test Infra :: ZooKeeper
  • Camel :: XMPP
  • Camel :: Zookeeper
  • Camel :: Zookeeper Master

⚙️ View full build and test results

gnodet and others added 2 commits April 30, 2026 18:04
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>
@gnodet gnodet changed the title Make container names unique and migrate all tests to singletons Add createSingletonService() and migrate all tests to singletons Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants