Use destination statistics instead of global statistics to avoid side…#1668
Use destination statistics instead of global statistics to avoid side…#1668jeanouii wants to merge 1 commit intoapache:mainfrom
Conversation
… effects in asserts
There was a problem hiding this comment.
Pull request overview
Updates AdvisoryViaNetworkTest to assert dequeue/inflight counts using per-advisory-destination statistics (scoped to the relevant topics) instead of using the broker-wide destination statistics, to reduce cross-test / cross-destination interference in assertions.
Changes:
- Add a varargs topic list to
assertDeqInflight(...)and compute totals by summing stats from each topic’s consumer-advisory destination. - Update existing tests to pass the relevant topic(s) into
assertDeqInflight(...). - Add required imports to support advisory-topic derivation and destination-level stats access.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| long actualInflight = 0; | ||
| for (ActiveMQTopic topic : topics) { | ||
| ActiveMQTopic advisory = AdvisorySupport.getConsumerAdvisoryTopic(topic); | ||
| Destination destination = brokers.get("A").broker.getDestination(advisory); |
There was a problem hiding this comment.
BrokerService#getDestination(...) lazily creates the destination (it calls addDestination), so this assertion helper can still mutate broker state while waiting. To avoid side effects in the assert, lookup the advisory destination via the region broker’s existing destination map (e.g., ((RegionBroker) broker.getRegionBroker()).getDestinationMap().get(advisory)) rather than calling broker.getDestination(advisory).
| Destination destination = brokers.get("A").broker.getDestination(advisory); | |
| RegionBroker regionBroker = (RegionBroker) brokers.get("A").broker.getRegionBroker(); | |
| Destination destination = regionBroker.getDestinationMap().get(advisory); |
| long actualDeq = 0; | ||
| long actualInflight = 0; | ||
| for (ActiveMQTopic topic : topics) { | ||
| ActiveMQTopic advisory = AdvisorySupport.getConsumerAdvisoryTopic(topic); |
There was a problem hiding this comment.
Just for context: what we are testing here is not the global DestinationStatistics.
We want to test that the consuming actually increase the dequeue (after consuming completed) and the inflight (when consuming is in progress).
So, it's fine to use that for a specific destination (instead of global).
However, maybe it makes sense to try to keep also the test with global but "isolated" to avoid side effect. Just my $0.01.
There was a problem hiding this comment.
The point is that sometimes it's failing because on the global statistics we get advisory (nob statistics). So because the test is focused into testing statistics for one destination only, I changed it to match more closely what's the test is about.
… effects in asserts