You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/10/07 13:16:13 UTC

[PR] CAMEL-25342: Fix flaky test NatsConsumerIT [camel]

gnodet opened a new pull request, #27505:
URL: https://github.com/apache/camel/pull/27505

   ## Description
   
   Fixes a classic publish-before-subscribe race condition in `NatsConsumerIT.testConsumer()`.
   
   ### Root Cause
   
   `NatsConsumer.doStart()` submits the NATS subscription asynchronously via `executor.submit(new NatsConsumingTask(...))`. The `doStart()` method returns before the subscription is established on the NATS server. Since standard NATS has no message persistence, the test's `template.sendBody()` call could race ahead of `dispatcher.subscribe()` completing in the background thread, causing the message to be silently dropped.
   
   The previous `setAssertPeriod(5000)` workaround (commit 685e1a4) addressed false positives (spurious passes) but not the fundamental race — a message dropped before subscription is established can never be received regardless of how long we wait.
   
   ### Fix
   
   Add an Awaitility wait on `NatsConsumer.isActive()` before sending the message. `NatsConsumer.setActive(true)` is called at the end of `setupStandardNatsConsumer()` (after `dispatcher.subscribe()` completes), making `isActive()` the correct readiness signal.
   
   This mirrors the identical pattern already established in `NatsConsumerWithRedeliveryIT`.
   
   ### Changes
   
   - `NatsConsumerIT`: add `await().atMost(10, TimeUnit.SECONDS).until(...)` guard before `template.sendBody()`; drop the now-unnecessary `setAssertPeriod(5000)`.
   
   Fixes https://issues.apache.org/jira/browse/CAMEL-25342


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25342: Fix flaky test NatsConsumerIT [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #27505:
URL: https://github.com/apache/camel/pull/27505


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25342: Fix flaky test NatsConsumerIT [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27505:
URL: https://github.com/apache/camel/pull/27505#issuecomment-6038764020

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: 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](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25342: Fix flaky test NatsConsumerIT [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27505:
URL: https://github.com/apache/camel/pull/27505#issuecomment-6039095716

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-nats`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 1 of 699 tested, 0 compile-only — current: 9 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **1 affected modules** (current approach: 9).
   
   **Skip-tests mode would test 1 modules** (1 direct + 0 downstream), **skip tests for 0** (generated code, meta-modules)
   
   <details><summary>Modules only in current approach (8)</summary>
   
   - `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`
   
   </details>
   
   
   <details><summary>Modules Scalpel would test (1)</summary>
   
   - `camel-nats` ← components/camel-nats/src/test/java/org/apache/camel/component/nats/integration/NatsConsumerIT.java
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   <details><summary>All tested modules (9 modules, 1m 34s total)</summary>
   
   **Total reactor time:** 1m 34s
   
   | Module | Duration | Status |
   | --- | --- | --- |
   | Camel :: JBang :: MCP | 40.0s | SUCCESS |
   | Camel :: JBang :: Plugin :: Validate | 26.0s | SUCCESS |
   | Camel :: YAML DSL :: Validator | 20.1s | SUCCESS |
   | Camel :: YAML DSL :: Validator Maven Plugin | 3.2s | SUCCESS |
   | Camel :: Launcher :: Container | 2.5s | SUCCESS |
   | Camel :: JBang :: Plugin :: MCP | 1.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: Route Parser | 1.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: TUI | n/a |  |
   | Camel :: Nats | n/a |  |
   
   **Top 20 slowest modules:**
   - `Camel :: JBang :: MCP` (40.0s)
   - `Camel :: JBang :: Plugin :: Validate` (26.0s)
   - `Camel :: YAML DSL :: Validator` (20.1s)
   - `Camel :: YAML DSL :: Validator Maven Plugin` (3.2s)
   - `Camel :: Launcher :: Container` (2.5s)
   - `Camel :: JBang :: Plugin :: MCP` (1.2s)
   - `Camel :: JBang :: Plugin :: Route Parser` (1.2s)
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/37627173542)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org