This is an automated email from the ASF dual-hosted git repository.

mattrpav pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/main by this push:
     new 82351687a6 Fix flaky NetworkAdvancedStatisticsTest race condition
82351687a6 is described below

commit 82351687a6dfa84d4e89614d77d2438f6d159b7a
Author: pradeep85841 <[email protected]>
AuthorDate: Thu Apr 2 09:04:57 2026 +0530

    Fix flaky NetworkAdvancedStatisticsTest race condition
---
 .../activemq/network/NetworkAdvancedStatisticsTest.java       | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
index 50f61d35de..a7bbacfc54 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
@@ -165,8 +165,15 @@ public class NetworkAdvancedStatisticsTest extends 
BaseNetworkTest {
         assertTrue(Wait.waitFor(new Condition() {
             @Override
             public boolean isSatisified() throws Exception {
-                // The number of message that remain is due to the exclude 
queue
-                return receivedMessages.size() == MESSAGE_COUNT;
+                // Check if messages arrived at the consumer
+                boolean messagesReceived = receivedMessages.size() == 
MESSAGE_COUNT;
+
+                // Check if the asynchronous broker statistics have settled
+                long localDequeues = 
localBroker.getDestination(includedDestination).getDestinationStatistics().getDequeues().getCount();
+                long remoteEnqueues = 
remoteBroker.getDestination(includedDestination).getDestinationStatistics().getEnqueues().getCount();
+
+                // The test can only proceed when BOTH the messages are 
received and the stats match
+                return messagesReceived && localDequeues == MESSAGE_COUNT && 
remoteEnqueues == MESSAGE_COUNT;
             }
         }, 30000, 500));
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to