CAMEL-23880: camel-pulsar - fix flaky integration tests#24380
Merged
Conversation
Root cause: multiple test classes shared the same Pulsar topic URI (persistent://public/default/camel-topic) with the same subscription name while running against a singleton Pulsar container. This caused messages and subscription state to leak between tests, producing non-deterministic message counts and spurious CI failures on unrelated PRs. Fixes: - Give each test class a unique topic name prefix and each test method its own topic via a static counter, preventing cross-contamination - Replace @EndpointInject for consumer endpoints with programmatic endpoint creation in @beforeeach, so each test method gets a fresh endpoint bound to its unique topic - Add proper @AfterEach cleanup (close endpoints, producers, routes) - Change expectedMessageCount() to expectedMinimumMessageCount() for redelivery-based assertions whose exact count is timing-dependent - Replace Guava Uninterruptibles.sleepUninterruptibly with Awaitility in PulsarConsumerReadCompactedIT (compaction status polling) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
davsclaus
approved these changes
Jul 2, 2026
Contributor
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 38 all testedMaveniverse Scalpel detected 1 affected modules (current approach: 38). Modules only current approach found (37) — Scalpel missed these
Skip-tests mode would test 1 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules) Modules Scalpel would test (1)
All tested modules (9 modules)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Claude Code on behalf of Guillaume Nodet
Fixes https://issues.apache.org/jira/browse/CAMEL-23880
Several camel-pulsar integration tests are flaky, causing spurious CI failures on unrelated PRs (e.g., the JDK 17 build in PR #24374 / CI run 28577362875).
Root cause
Multiple test classes share the same Pulsar topic URI (
persistent://public/default/camel-topic) with the same subscription name (camel-subscription) while running against a singleton Pulsar container. Messages and subscription state leak between tests, producing non-deterministic message counts.Specifically:
PulsarConsumerNoAcknowledgementITandPulsarConsumerReadCompactedITboth usepersistent://public/default/camel-topicwith identical subscription namesPulsarConsumerNoAcknowledgementIThas two test methods sharing the same@EndpointInjectendpoint — unacknowledged messages from the first test contaminate the secondPulsarConsumerNegativeAcknowledgementITcreates additionalPulsarClientinstances in test methods that are never closed, leaking threadsFixes applied
PulsarConsumerNoAcknowledgementIT@EndpointInjectwith programmatic endpoint in@BeforeEach; add@AfterEachcleanup (endpoint, producer, route); changeexpectedMessageCount(3)→expectedMinimumMessageCount(3)PulsarConsumerReadCompactedIT@EndpointInjectwith programmatic endpoint in@BeforeEach; add@AfterEachcleanup; replaceUninterruptibles.sleepUninterruptiblywith Awaitility for compaction pollingPulsarConsumerNegativeAcknowledgementIT@EndpointInjectwith programmatic endpoint in@BeforeEach; add@AfterEachcleanup; changeexpectedMessageCount(3)→expectedMinimumMessageCount(3)Pattern used
The same pattern already used by
PulsarConsumerAcknowledgementITandPulsarSuspendRouteIT: each test method creates its endpoint programmatically with a unique topic name (prefix + incrementing static counter), avoiding topic and subscription state leakage.Test plan
mvn -DskipTests install— compiles cleanlymvn formatter:format impsort:sort— passes formatting checks🤖 Generated with Claude Code