Skip to content

Add createSingletonService() to test-infra factories and migrate tests#22294

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

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

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 27, 2026

Summary

Add createSingletonService() to 27 test-infra service factories and migrate 36 test classes to use them where safe.

Phase 2: Factory methods (commit 1)

  • Added SingletonXxxService inner class, SingletonServiceHolder lazy init, and createSingletonService() factory method to 27 service factories
  • Pattern follows existing KafkaServiceFactory template
  • ZooKeeper excluded (already has singleton support)

Phase 3: Test migrations (commit 2)

  • Migrated 36 test base classes from createService() to createSingletonService()
  • Tests left on createService() are annotated with comments explaining why they cannot share a singleton container:
    • State interference: Hashicorp Vault (secret versions accumulate), LRA (transaction state interference)
    • Conflicting declarations: Spring-RabbitMQ (hardcoded exchange/queue names conflict)
    • Container name collisions: NATS (auth-variant containers share same alias), Consul (ConsulHealthIT creates own container), Paho MQTT5 (reconnect test creates own container)

Motivation

Singleton services allow test classes within a module to share a single container instance, reducing Docker overhead and test execution time. Combined with PR #22287 (unique container naming), this makes the test infrastructure safe for within-JVM parallel execution.

Test plan

  • Phase 2 alone passes CI (factory methods only, no behavioral change)
  • Phase 3 migrations verified against CI — reverted all tests that showed failures
  • Full CI green on final changeset

@github-actions
Copy link
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
Add singleton service support to test-infra service factories that
were missing it. This allows test classes to share a single container
instance per JVM, reducing Docker overhead and preparing the
infrastructure for safe within-JVM parallel test execution.

Each factory now provides:
- A SingletonXxxService inner class extending SingletonService<T>
- A lazy-init SingletonServiceHolder using static initializer
- A createSingletonService() factory method

Factories updated: AzureStorageBlob, AzureStorageQueue, Cassandra,
Consul, Docling, GooglePubSub, Hashicorp, Hazelcast, IbmMQ, Iggy,
Ignite, Keycloak, McpEverything, McpEverythingSse, MicroprofileLRA,
Minio, Mosquitto, Nats, Openldap, Postgres, PostgresVector, RabbitMQ,
Redis, Solr, TensorFlowServing, Triton, Xmpp.

ZooKeeper excluded: requires unique container naming (PR apache#22287)
first, since camel-zookeeper and camel-zookeeper-master both create
containers named "camel-zookeeper" and collide in parallel CI builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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
Contributor

orpiske commented Mar 27, 2026

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

Where safe, migrate test base classes to use createSingletonService()
so tests share a single container instance, reducing Docker overhead.

Tests left on createService() are annotated with comments explaining
why they cannot share a singleton container (state interference,
conflicting declarations, or container name collisions from
auth-variant containers).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
Copy link
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...

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