Skip to content

CAMEL-22524: Add HazelcastRoutePolicy integration test#22106

Merged
gnodet merged 6 commits intomainfrom
CAMEL-22524-hazelcast-route-policy-it
Apr 8, 2026
Merged

CAMEL-22524: Add HazelcastRoutePolicy integration test#22106
gnodet merged 6 commits intomainfrom
CAMEL-22524-hazelcast-route-policy-it

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Mar 19, 2026

JIRA: CAMEL-22524

Summary

  • Add automated IT for HazelcastRoutePolicy that tests leader election using embedded Hazelcast
  • 3 concurrent nodes with deterministic staggered startup, each with its own HazelcastInstance and route policy
  • Verifies distributed lock-based leader election works correctly and all nodes eventually execute their routes
  • Based on the scenario from the original HazelcastRoutePolicyMain manual test class

Details

  • Uses CopyOnWriteArrayList and local variables (no static mutable state) for thread safety
  • Try-with-resources for CamelContext cleanup; manual finally for HazelcastInstance (not AutoCloseable)
  • @Timeout(2 minutes) on the test method to prevent CI hangs
  • Consistent use of AssertJ assertions with descriptive messages
  • Deterministic staggered startup delays based on node index
  • Added assertj-core test-scoped dependency to camel-hazelcast

Test plan

  • IT passes locally (mvn test -pl components/camel-hazelcast -Dtest=HazelcastRoutePolicyIT)
  • CI passes

Create automated IT that tests HazelcastRoutePolicy leader election
using embedded Hazelcast. The test runs 3 concurrent nodes with
staggered startup, each with its own HazelcastInstance and route
policy, verifying that distributed lock-based leader election works
correctly and all nodes eventually execute their routes.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

🧪 CI tested the following changed modules:

  • components/camel-hazelcast
All tested modules (72 modules)
  • Camel :: All Components Sync point
  • Camel :: All Components Sync point [pom]
  • Camel :: Assembly
  • Camel :: Assembly [pom]
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated) [maven-plugin]
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated) SUCCESS [ 1.518 s]
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Catalog [jar]
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Report Maven Plugin [maven-plugin]
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Camel Route Parser [jar]
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Console [jar]
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Dummy Component [jar]
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Lucene (deprecated) [jar]
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Maven [jar]
  • Camel :: Catalog :: Suggest
  • Camel :: Catalog :: Suggest [jar]
  • Camel :: Component DSL
  • Camel :: Component DSL [jar]
  • Camel :: Coverage
  • Camel :: Coverage [pom]
  • Camel :: Docs
  • Camel :: Docs [pom]
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL [jar]
  • Camel :: Endpoint DSL :: Support
  • Camel :: Endpoint DSL :: Support [jar]
  • Camel :: HazelCast
  • Camel :: HazelCast [jar]
  • Camel :: Integration Tests
  • Camel :: Integration Tests [jar]
  • Camel :: JBang :: Core
  • Camel :: JBang :: Core [jar]
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: Integration tests [jar]
  • Camel :: JBang :: MCP
  • Camel :: JBang :: MCP [jar]
  • Camel :: JBang :: Main
  • Camel :: JBang :: Main [jar]
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Edit [jar]
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Generate [jar]
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: Kubernetes [jar]
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: Route Parser [jar]
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Testing [jar]
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JBang :: Plugin :: Validate [jar]
  • Camel :: Kamelet Main
  • Camel :: Kamelet Main [jar]
  • Camel :: Launcher
  • Camel :: Launcher [jar]
  • Camel :: Launcher :: Container
  • Camel :: Launcher :: Container [pom]
  • Camel :: YAML DSL
  • Camel :: YAML DSL [jar]
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Deserializers [jar]
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Maven Plugins [maven-plugin]
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator [jar]
  • Camel :: YAML DSL :: Validator Maven Plugin
  • Camel :: YAML DSL :: Validator Maven Plugin [maven-plugin]

gnodet and others added 4 commits March 23, 2026 22:25
- Simplify CLIENTS list to List.of() instead of IntStream
- Use AssertJ containsExactlyInAnyOrderElementsOf for better error messages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…PolicyIT

- Use CopyOnWriteArrayList instead of ArrayList for thread-safe results collection
- Move mutable state from static fields to local test method variables
- Move latch.countDown() to finally block so it always fires (even on failure)
- Add proper cleanup in finally block for context and hazelcast instance
- Check latch.await() return value to fail fast on timeout
- Use executor.awaitTermination() to ensure clean shutdown before assertions
- Use newFixedThreadPool instead of newScheduledThreadPool (no scheduling needed)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add assertj-core test dependency (fixes compilation)
- Check contextLatch.await return value to verify leader election
- Rename test to testLeaderElectionWithMultipleNodes
- Add @timeout annotation as CI safety net

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-route-policy-it

# Conflicts:
#	components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/policy/HazelcastRoutePolicyIT.java
@apupier
Copy link
Copy Markdown
Contributor

apupier commented Apr 2, 2026

What's the status? is it ready for another review?

@gnodet gnodet requested a review from apupier April 2, 2026 11:50
- Use AssertJ consistently instead of mixing JUnit assertTrue
- Use try-with-resources for CamelContext cleanup
- Use deterministic staggered startup delays
- Include event count in timeout log messages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented Apr 2, 2026

@apupier Yes, this PR is ready for another review. The latest commit addresses your earlier feedback and adds a few more improvements:

  • Consistent use of AssertJ assertions (removed mixed JUnit assertTrue)
  • Try-with-resources for CamelContext cleanup
  • Deterministic staggered startup delays (instead of random)
  • More informative timeout log messages (includes expected event count)

Note: while testing locally, we noticed that HazelcastService extends ContainerTestService, which silently skips the test when Docker is unavailable — even though this test only uses embedded Hazelcast. PR #22409 fixes that for Hazelcast, Ignite, and FTP services.

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet requested a review from oscerd April 2, 2026 12:33
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented Apr 2, 2026

CI build log confirms the test ran successfully (JDK 21):

[camel-hazelcast] [INFO] Running org.apache.camel.component.hazelcast.policy.HazelcastRoutePolicyIT
[camel-hazelcast] [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.568 s -- in org.apache.camel.component.hazelcast.policy.HazelcastRoutePolicyIT

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet merged commit 06bfff6 into main Apr 8, 2026
5 checks passed
@gnodet gnodet deleted the CAMEL-22524-hazelcast-route-policy-it branch April 8, 2026 21:56
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.

3 participants