You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2017/02/08 13:56:21 UTC

svn commit: r1782168 - /qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java

Author: kwall
Date: Wed Feb  8 13:56:21 2017
New Revision: 1782168

URL: http://svn.apache.org/viewvc?rev=1782168&view=rev
Log:
QPID-7603: [Java Broker, AMQP 1.0] Fix 0-9/0-10 test failure caused by r1781876

Modified:
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java?rev=1782168&r1=1782167&r2=1782168&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java Wed Feb  8 13:56:21 2017
@@ -71,12 +71,19 @@ public class MaxDeliveryCountTest extend
     private static final int MAX_DELIVERY_COUNT = 2;
     private CountDownLatch _awaitCompletion;
 
+    protected long _awaitEmptyQueue;
+    protected long _awaitCompletionTimeout = 20;
+
     /** index numbers of messages to be redelivered */
     private final List<Integer> _redeliverMsgs = Arrays.asList(1, 2, 5, 14);
     private String _testQueueName;
 
+    @Override
     public void setUp() throws Exception
     {
+        _awaitEmptyQueue = Long.parseLong(System.getProperty("MaxDeliveryCountTest.awaitEmptyQueue", "2500"));
+        _awaitCompletionTimeout = Long.parseLong(System.getProperty("MaxDeliveryCountTest.awaitCompletionTimeout", "20000"));
+
         setTestSystemProperty("queue.deadLetterQueueEnabled","true");
         setTestSystemProperty("queue.maximumDeliveryAttempts", String.valueOf(MAX_DELIVERY_COUNT));
 
@@ -237,7 +244,7 @@ public class MaxDeliveryCountTest extend
 
             try
             {
-                if (!_awaitCompletion.await(20, TimeUnit.SECONDS))
+                if (!_awaitCompletion.await(_awaitCompletionTimeout, TimeUnit.MILLISECONDS))
                 {
                     fail("Test did not complete in 20 seconds.");
                 }
@@ -252,9 +259,21 @@ public class MaxDeliveryCountTest extend
             {
                 fail(_failMsg);
             }
+
         }
         consumer.close();
 
+        // In the non-transaction case, control may return to the client before the messaging transaction is committed.
+        if (clientSession.getAcknowledgeMode() != Session.SESSION_TRANSACTED
+            && clientSession.getAcknowledgeMode() != Session.CLIENT_ACKNOWLEDGE)
+        {
+            final long timeout = System.currentTimeMillis() + _awaitEmptyQueue;
+            while(getQueueDepth(clientConnection, checkQueue) > 0 && System.currentTimeMillis() < timeout)
+            {
+                Thread.sleep(100);
+            }
+        }
+
         //check the source queue is now empty
         assertEquals("The queue should have 0 msgs left", 0, getQueueDepth(clientConnection, checkQueue));
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org