From 9794ac769be277a214eaf8441eec199bcc4903a1 Mon Sep 17 00:00:00 2001 From: jbertram Date: Fri, 6 May 2016 13:25:59 -0500 Subject: [PATCH] Make ScaleDownTest#testStoreAndForward more robust --- .../integration/server/ScaleDownTest.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java index db2a907f40..dfc252ff22 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java @@ -181,10 +181,33 @@ public class ScaleDownTest extends ClusterTestBase { addConsumer(0, 1, queueName1, null); addConsumer(1, 1, queueName2, null); + LocalQueueBinding queue1Binding = ((LocalQueueBinding) servers[0].getPostOffice().getBinding(new SimpleString(queueName1))); + LocalQueueBinding queue2Binding = ((LocalQueueBinding) servers[0].getPostOffice().getBinding(new SimpleString(queueName2))); + LocalQueueBinding sfQueueBinding = ((LocalQueueBinding) servers[0].getPostOffice().getBinding(new SimpleString(sfQueueName))); + + long timeout = 5000; + long start = System.currentTimeMillis(); + + while (getMessageCount(queue1Binding.getQueue()) > 0 && System.currentTimeMillis() - start <= timeout) { + Thread.sleep(50); + } + + start = System.currentTimeMillis(); + + while (getMessageCount(queue2Binding.getQueue()) > 0 && System.currentTimeMillis() - start <= timeout) { + Thread.sleep(50); + } + + start = System.currentTimeMillis(); + + while (getMessageCount(sfQueueBinding.getQueue()) < TEST_SIZE * 2 && System.currentTimeMillis() - start <= timeout) { + Thread.sleep(50); + } + // at this point on node 0 there should be 0 messages in test queues and TEST_SIZE * 2 messages in the sf queue - Assert.assertEquals(0, getMessageCount(((LocalQueueBinding) servers[0].getPostOffice().getBinding(new SimpleString(queueName1))).getQueue())); - Assert.assertEquals(0, getMessageCount(((LocalQueueBinding) servers[0].getPostOffice().getBinding(new SimpleString(queueName2))).getQueue())); - Assert.assertEquals(TEST_SIZE * 2, getMessageCount(((LocalQueueBinding) servers[0].getPostOffice().getBinding(new SimpleString(sfQueueName))).getQueue())); + Assert.assertEquals(0, getMessageCount(queue1Binding.getQueue())); + Assert.assertEquals(0, getMessageCount(queue2Binding.getQueue())); + Assert.assertEquals(TEST_SIZE * 2, getMessageCount(sfQueueBinding.getQueue())); removeConsumer(0); removeConsumer(1);