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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]