Skip to content

CAMEL-23880: camel-pulsar - fix flaky integration tests#24380

Merged
gnodet merged 1 commit into
apache:mainfrom
gnodet:fix/CAMEL-23880
Jul 3, 2026
Merged

CAMEL-23880: camel-pulsar - fix flaky integration tests#24380
gnodet merged 1 commit into
apache:mainfrom
gnodet:fix/CAMEL-23880

Conversation

@gnodet

@gnodet gnodet commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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:

  • PulsarConsumerNoAcknowledgementIT and PulsarConsumerReadCompactedIT both use persistent://public/default/camel-topic with identical subscription names
  • PulsarConsumerNoAcknowledgementIT has two test methods sharing the same @EndpointInject endpoint — unacknowledged messages from the first test contaminate the second
  • PulsarConsumerNegativeAcknowledgementIT creates additional PulsarClient instances in test methods that are never closed, leaking threads

Fixes applied

File Changes
PulsarConsumerNoAcknowledgementIT Unique topic per test method via static counter; replace @EndpointInject with programmatic endpoint in @BeforeEach; add @AfterEach cleanup (endpoint, producer, route); change expectedMessageCount(3)expectedMinimumMessageCount(3)
PulsarConsumerReadCompactedIT Unique topic per test method via static counter; replace @EndpointInject with programmatic endpoint in @BeforeEach; add @AfterEach cleanup; replace Uninterruptibles.sleepUninterruptibly with Awaitility for compaction polling
PulsarConsumerNegativeAcknowledgementIT Unique topic per test method; replace @EndpointInject with programmatic endpoint in @BeforeEach; add @AfterEach cleanup; change expectedMessageCount(3)expectedMinimumMessageCount(3)

Pattern used

The same pattern already used by PulsarConsumerAcknowledgementIT and PulsarSuspendRouteIT: 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 cleanly
  • mvn formatter:format impsort:sort — passes formatting checks
  • CI integration tests — verify flaky tests now pass reliably

🤖 Generated with Claude Code

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>
@gnodet gnodet requested review from davsclaus and oscerd July 2, 2026 11:21
@github-actions

github-actions Bot commented Jul 2, 2026

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 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

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-pulsar

🔬 Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 38 all tested

Maveniverse Scalpel detected 1 affected modules (current approach: 38).

Modules only current approach found (37) — Scalpel missed these
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-mcp
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-test
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-kamelet-main
  • camel-launcher
  • camel-launcher-container
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 1 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (1)
  • camel-pulsar

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (9 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: Pulsar
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet merged commit a9d4d58 into apache:main Jul 3, 2026
5 checks passed
@gnodet gnodet deleted the fix/CAMEL-23880 branch July 3, 2026 05:52
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