Skip to content

Use destination statistics instead of global statistics to avoid side…#1668

Open
jeanouii wants to merge 1 commit intoapache:mainfrom
jeanouii:fix/AdvisoryViaNetworkTest
Open

Use destination statistics instead of global statistics to avoid side…#1668
jeanouii wants to merge 1 commit intoapache:mainfrom
jeanouii:fix/AdvisoryViaNetworkTest

Conversation

@jeanouii
Copy link
Contributor

… effects in asserts

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

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

Suggested change
Destination destination = brokers.get("A").broker.getDestination(advisory);
RegionBroker regionBroker = (RegionBroker) brokers.get("A").broker.getRegionBroker();
Destination destination = regionBroker.getDestinationMap().get(advisory);

Copilot uses AI. Check for mistakes.
long actualDeq = 0;
long actualInflight = 0;
for (ActiveMQTopic topic : topics) {
ActiveMQTopic advisory = AdvisorySupport.getConsumerAdvisoryTopic(topic);
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants