From 869426dba3c152af0403dd2a87c50a98298317c6 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Tue, 19 Jan 2010 19:26:30 +0000 Subject: QPID-1825 : Updated test to only start the 'clock' for timeout when the message count on the queue hasn't changed after a 100ms sleep. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@900919 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/server/queue/TimeToLiveTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'java') diff --git a/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java b/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java index 428368f859..c73959676d 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java @@ -177,15 +177,26 @@ public class TimeToLiveTest extends QpidTestCase { producer.send(producerSession.createTextMessage("Message: "+i)); } - long failureTime = System.currentTimeMillis() + 2*SERVER_TTL_TIMEOUT; + long failureTime = System.currentTimeMillis() + 2 * SERVER_TTL_TIMEOUT; - // check Queue depth for up to TIMEOUT seconds - long messageCount; + // check Queue depth for up to TIMEOUT seconds after the Queue Depth hasn't changed for 100ms. + long messageCount = MSG_COUNT; + long lastPass; do { + lastPass = messageCount; Thread.sleep(100); messageCount = producerSession.getQueueDepth((AMQDestination) queue); + + // If we have received messages in the last loop then extend the timeout time. + // if we get messages stuck that are not expiring then the failureTime will occur + // failing the test. This will help with the scenario when the broker does not + // have enough CPU cycles to process the TTLs. + if (lastPass != messageCount) + { + failureTime = System.currentTimeMillis() + 2 * SERVER_TTL_TIMEOUT; + } } while(messageCount > 0L && System.currentTimeMillis() < failureTime); -- cgit v1.2.1