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

jbonofre 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 6adc875a06 fix(test): avoid race condition in 
TwoBrokerVirtualTopicSelectorAwareForwardingTest (#1951)
6adc875a06 is described below

commit 6adc875a060ce1efab58a92a14d38475e177155f
Author: JB Onofré <[email protected]>
AuthorDate: Thu Apr 23 15:22:08 2026 +0200

    fix(test): avoid race condition in 
TwoBrokerVirtualTopicSelectorAwareForwardingTest (#1951)
    
    Replace bare assertEquals with Wait.waitFor for the queue depth check in
    testSelectorAwareForwarding. The broker decrements its messages counter only
    after processing the MessageAck asynchronously, so asserting immediately 
after
    waitForMessagesToArrive could fire before the ACK is processed on a loaded 
CI runner.
---
 .../TwoBrokerVirtualTopicSelectorAwareForwardingTest.java        | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
index 83ed1ed8af..d09868cb8d 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
@@ -520,10 +520,11 @@ public class 
TwoBrokerVirtualTopicSelectorAwareForwardingTest extends
         assertEquals(2, msgsB.getMessageCount());
 
 
-        // queue should be drained
-        assertEquals(0, brokerB.getDestination(new 
ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic"))
-                .getDestinationStatistics().getMessages().getCount());
-        // and the enqueue count for the remote queue should only be 1
+        // queue should be drained - use Wait.waitFor to allow broker ACK 
processing to complete
+        assertTrue("queue should be drained after consumer ACKs", 
Wait.waitFor(() ->
+                brokerB.getDestination(new 
ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic"))
+                        .getDestinationStatistics().getMessages().getCount() 
== 0, 5000, 100));
+        // and the enqueue count for the remote queue should only be 3
         assertEquals(3, brokerB.getDestination(new 
ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic"))
                 .getDestinationStatistics().getEnqueues().getCount());
 


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