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

[PR] CAMEL-25666: Stabilize ConsumeChildrenIT - replace fixed delay with [camel]

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

   Awaitility
   
   The test shouldAwaitCreationAndGetDataNotification fires 5 ZooKeeper mutations in sequence and expects the mock endpoint to receive exactly 5 messages (1 NodeCreated + 4 NodeChildrenChanged).
   
   The consumer uses a single-threaded OperationsExecutor: after each ChildrenChangedOperation fires it must synchronously call getChildren() in getResult(), deliver the exchange to the processor, then re-enqueue a copy of itself via createCopy(), and finally call installWatch() on the new copy to re-register the ZooKeeper watcher before the next event can be captured.
   
   The original test relied on a 200 ms pre-delay in TestZookeeperClient (delay(200) fires before the ZooKeeper mutation, not after). On a slow or loaded machine this is not long enough for the consumer to finish processing + re-registering the watch before the next mutation fires, causing a ZooKeeper NodeChildrenChanged event to be silently dropped. The mock then receives 4 instead of 5 messages.
   
   Fix: use Awaitility after each mutation to wait until the mock has actually received the corresponding message before triggering the next one. This guarantees the watch is re-registered before the next event fires, making the sequencing deterministic regardless of machine speed.
   
   Also rename the ZooKeeper node from /grimm to /grimm-ConsumeChildrenIT to isolate this test from any other test that might share the same ZooKeeper server, consistent with the same fix already applied to ConsumeDataIT and the cluster integration tests.
   
   Co-authored-by: IBM Bob 2.2.1
   
   # Description
   
   <!--
   - Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   -->
   
   # Target
   
   - [ ] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
   
   # Tracking
   - [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [ ] I checked that each commit in the pull request has a meaningful subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   -->
   
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
   
   <!--
   You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   # AI-assisted contributions
   
   - [ ] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used.
   
   


-- 
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-25666: Stabilize ConsumeChildrenIT - replace fixed delay with [camel]

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

   <!-- regen-patch -->
   ### :warning: Generated files are out of date
   
   The [CI build](https://github.com/apache/camel/actions/runs/38739693979) regenerated files that are not committed on this PR.
   
   If *Allow edits from maintainers* is enabled, a maintainer bot will automatically
   push a "Regen" commit to this branch shortly.
   
   Otherwise, you can apply the patch manually — the missing changes are available
   as the `regen-patch` artifact of that run:
   
   ```bash
   gh pr checkout 27902 --repo apache/camel
   gh run download 38739693979 --repo apache/camel -n regen-patch
   git apply --index regen.patch && rm regen.patch pr-number
   git commit -m "Regen" && git push
   ```
   
   Alternatively, run `./etc/scripts/regen.sh` locally and commit the resulting changes.
   If the patch does not apply cleanly, update the branch from the base branch first —
   the patch was generated against the merge with the base branch.


-- 
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-25666: Stabilize ConsumeChildrenIT - replace fixed delay with Awaitility [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27902:
URL: https://github.com/apache/camel/pull/27902#discussion_r4291675932


##########
components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/integration/ConsumeChildrenIT.java:
##########
@@ -52,19 +56,38 @@ public void shouldAwaitCreationAndGetDataNotification() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:zookeeper-data");
         mock.expectedMessageCount(5);
 
-        client.createPersistent("/grimm", "parent");
-        client.create("/grimm/hansel", "child");
-        client.create("/grimm/gretel", "child");
-        client.delete("/grimm/hansel");
-        client.delete("/grimm/gretel");
+        client.createPersistent(ZK_NODE, "parent");
+        awaitMockReceivedCount(mock, 1);
+        client.create(ZK_NODE + "/hansel", "child");
+        awaitMockReceivedCount(mock, 2);
+        client.create(ZK_NODE + "/gretel", "child");
+        awaitMockReceivedCount(mock, 3);
+        client.delete(ZK_NODE + "/hansel");
+        awaitMockReceivedCount(mock, 4);
+        client.delete(ZK_NODE + "/gretel");
 
-        MockEndpoint.assertIsSatisfied(context);
+        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
 
         validateExchangesContainListings(mock, createChildListing(), createChildListing("hansel"),
                 createChildListing("hansel", "gretel"), createChildListing("gretel"),
                 createChildListing());
     }
 
+    /**
+     * Waits until the mock has received at least {@code count} messages before the next ZooKeeper mutation is fired.
+     * <p>
+     * This ensures the previous ChildrenChangedOperation copy has been taken off the queue and its

Review Comment:
   Nit (optional): this sentence says the await ensures `installWatch()` has been called, but in `OperationsExecutor.run()` the copy is put back on the queue, and its watch installed, only *after* the mock has the exchange (which the next sentence says too). Maybe: "Once the mock has the exchange, the next ChildrenChangedOperation copy is put back on the queue and calls `installWatch()` shortly after."



-- 
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-25666: Stabilize ConsumeChildrenIT - replace fixed delay with Awaitility [camel]

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


-- 
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-25666: Stabilize ConsumeChildrenIT - replace fixed delay with Awaitility [camel]

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

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-zookeeper`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 1 of 705 tested, 0 compile-only — current: 8 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **1 affected modules** (current approach: 8).
   
   **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 (7)</summary>
   
   - `camel-jbang-mcp`
   - `camel-jbang-plugin-mcp`
   - `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-zookeeper` ← components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/integration/ConsumeChildrenIT.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 (8 modules, 1m 54s total)</summary>
   
   **Total reactor time:** 1m 54s
   
   | Module | Duration | Status |
   | --- | --- | --- |
   | Camel :: JBang :: Plugin :: Validate | 43.7s | SUCCESS |
   | Camel :: JBang :: MCP | 42.7s | SUCCESS |
   | Camel :: YAML DSL :: Validator | 20.0s | SUCCESS |
   | Camel :: YAML DSL :: Validator Maven Plugin | 3.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: MCP | 2.3s | SUCCESS |
   | Camel :: Launcher :: Container | 2.1s | SUCCESS |
   | Camel :: JBang :: Plugin :: TUI | n/a |  |
   | Camel :: Zookeeper | n/a |  |
   
   **Top 20 slowest modules:**
   - `Camel :: JBang :: Plugin :: Validate` (43.7s)
   - `Camel :: JBang :: MCP` (42.7s)
   - `Camel :: YAML DSL :: Validator` (20.0s)
   - `Camel :: YAML DSL :: Validator Maven Plugin` (3.2s)
   - `Camel :: JBang :: Plugin :: MCP` (2.3s)
   - `Camel :: Launcher :: Container` (2.1s)
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/38749274799)


-- 
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-25666: Stabilize ConsumeChildrenIT - replace fixed delay with [camel]

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

   :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-25666: Stabilize ConsumeChildrenIT - replace fixed delay with Awaitility [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27902:
URL: https://github.com/apache/camel/pull/27902#discussion_r4286193577


##########
components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/integration/ConsumeChildrenIT.java:
##########
@@ -52,19 +56,29 @@ public void shouldAwaitCreationAndGetDataNotification() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:zookeeper-data");
         mock.expectedMessageCount(5);
 
-        client.createPersistent("/grimm", "parent");
-        client.create("/grimm/hansel", "child");
-        client.create("/grimm/gretel", "child");
-        client.delete("/grimm/hansel");
-        client.delete("/grimm/gretel");
+        client.createPersistent(ZK_NODE, "parent");
+        awaitMockReceivedCount(mock, 1);
+        client.create(ZK_NODE + "/hansel", "child");
+        awaitMockReceivedCount(mock, 2);
+        client.create(ZK_NODE + "/gretel", "child");
+        awaitMockReceivedCount(mock, 3);
+        client.delete(ZK_NODE + "/hansel");
+        awaitMockReceivedCount(mock, 4);
+        client.delete(ZK_NODE + "/gretel");
 
-        MockEndpoint.assertIsSatisfied(context);
+        MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
 
         validateExchangesContainListings(mock, createChildListing(), createChildListing("hansel"),
                 createChildListing("hansel", "gretel"), createChildListing("gretel"),
                 createChildListing());
     }
 
+    private void awaitMockReceivedCount(MockEndpoint mock, int count) {

Review Comment:
   Small point about the PR description, not blocking: the exchange the mock counts comes from `GetChildrenOperation`. The consumer creates `ChildrenChangedOperation` with `getChangedListing=false`, so that operation returns `null` and never produces an exchange. In `OperationsExecutor.run()` the mock gets message N *before* the copy is offered back to the queue and before the next `ChildrenChangedOperation` is taken and calls `installWatch()` (an async `getChildren` with a watcher). So when this await returns, the watch may not be registered yet. What still covers that last gap is the `delay(200)` in `TestZookeeperClient.create/delete`.
   
   That gap is now tiny (one queue hop plus one round trip), so this is fine in practice. It may be worth a short comment here saying the sequencing still relies on the 200 ms pre-delay, so a later cleanup that drops `delay()` under the no-`Thread.sleep` rule does not quietly bring the flakiness back.



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