Skip to content

chore: fix NATS JetStream IT tests sharing a stream/durable name - #25630

Merged
davsclaus merged 1 commit into
mainfrom
quick-fix/nats-jetstream-it-stream-collision
Aug 24, 2026
Merged

chore: fix NATS JetStream IT tests sharing a stream/durable name#25630
davsclaus merged 1 commit into
mainfrom
quick-fix/nats-jetstream-it-stream-collision

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

  • NatsJetstreamConsumerAckPolicyNoneIT, NatsJetstreamConsumerMaxDeliverIT, and NatsJetstreamConsumerRedeliveryIT all used the identical JetStream stream name (mystream2), subject (mytopic2), and durable consumer name (camel2).
  • NatsITSupport doesn't tear down streams/consumers between IT classes, and NatsConsumer.setupJetStreamConsumer() never reconciles an already-existing durable consumer's config with a new subscribe request. Whichever of these three tests ran first bound its own ackPolicy/maxDeliver config to the shared durable consumer server-side; the next test(s) in the suite then silently bound to that stale, mismatched consumer and received zero messages.
  • This is why NatsJetstreamConsumerMaxDeliverIT and NatsJetstreamConsumerRedeliveryIT were previously guarded with @DisabledIfSystemProperty(named = "ci.env.name", ..., "Flaky on GitHub Actions"). That guard was removed in a prior "fix flaky tests" pass without addressing the underlying collision — most likely because it was verified by running each test class individually rather than as part of the full suite, which is the exact condition that triggers it.
  • Fix: give each test its own unique stream/subject/durable name (-ackpolicynone, -maxdeliver, -redelivery suffixes), matching the convention already used correctly by the other JetStream IT tests in this package (-manualack, -manualack-nak, -pull, etc). Test-only change, no production code touched.

Test plan

  • mvn verify -Ddevelocity.cache.local.enabled=false in components/camel-nats — all 28 IT tests pass, including the previously-failing two running immediately after NatsJetstreamConsumerAckPolicyNoneIT in the same suite (the exact ordering that used to trigger the failure).
  • Confirmed via minimal repro (-Dit.test=NatsJetstreamConsumerAckPolicyNoneIT,NatsJetstreamConsumerMaxDeliverIT) that the failure reproduced before the fix and is gone after.

Claude Code on behalf of davsclaus

… name

NatsJetstreamConsumerAckPolicyNoneIT, NatsJetstreamConsumerMaxDeliverIT,
and NatsJetstreamConsumerRedeliveryIT all used the identical JetStream
stream name (mystream2), subject (mytopic2), and durable consumer name
(camel2). NatsITSupport does not tear down streams/consumers between IT
classes, and NatsConsumer.setupJetStreamConsumer() never reconciles an
already-existing durable consumer's config with a new subscribe request,
so whichever of these three tests ran first bound its own ackPolicy/
maxDeliver config to the shared durable consumer server-side. The next
test(s) in the suite then silently bound to that stale, mismatched
consumer and received zero messages.

This is why NatsJetstreamConsumerMaxDeliverIT and
NatsJetstreamConsumerRedeliveryIT were previously guarded with
@DisabledIfSystemProperty(named = "ci.env.name", ..., "Flaky on GitHub
Actions"). That guard was removed without addressing the underlying
collision, most likely because it was verified by running each test
class individually rather than as part of the full suite.

Give each test its own unique stream/subject/durable name, matching the
convention already used by the other JetStream IT tests in this package
(-manualack, -manualack-nak, -pull, etc). Test-only change, no
production code touched.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.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 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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, minimal test-only fix that correctly resolves the NATS JetStream IT stream/durable name collision.

The root-cause analysis in the PR description is thorough: CAMEL-22539 (685e1a4) removed @DisabledIfSystemProperty from these three tests without addressing the shared mystream2/camel2 names, so whichever test ran first owned the durable consumer config and the others silently received zero messages.

The new -ackpolicynone/-maxdeliver/-redelivery suffixes follow the same pattern already used by the other JetStream ITs (-manualack, -pull, etc.), and no remaining collisions exist across the package.

📋 PR Metadata

Aspect Current Suggested
Labels components test (test-only change, not a component change)
Milestone (none) 4.22.0

Backport: not needed — on camel-4.18.x these tests still carry @DisabledIfSystemProperty, so the collision is masked there.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of @gnodet

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-nats

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

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

Modules only in current approach (8)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin

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

ℹ️ 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 :: Nats
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.23.0 milestone Aug 24, 2026
@davsclaus davsclaus added test and removed components labels Aug 24, 2026
@davsclaus davsclaus self-assigned this Aug 24, 2026
@davsclaus
davsclaus merged commit cb57e9c into main Aug 24, 2026
5 checks passed
@davsclaus
davsclaus deleted the quick-fix/nats-jetstream-it-stream-collision branch August 24, 2026 17:04
davsclaus added a commit that referenced this pull request Aug 24, 2026
Backport of #25630 to camel-4.22.x. NatsJetstreamConsumerAckPolicyNoneIT,
NatsJetstreamConsumerMaxDeliverIT, and NatsJetstreamConsumerRedeliveryIT used
identical JetStream stream, subject, and durable consumer names. Since
NatsITSupport doesn't tear down streams/consumers between IT classes, and
NatsConsumer.setupJetStreamConsumer() never reconciles an existing durable
consumer's config with a new subscribe request, whichever test ran first
bound its config to the shared durable consumer server-side, causing
subsequent tests to silently receive zero messages from a stale, mismatched
consumer.

Gives each test its own unique stream/subject/durable name, matching the
convention already used by the other JetStream IT tests in this package.
Test-only change, no production code touched.

Closes #25632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants