From 8a09b7e5f6cf5fcb5579f7183bd410f22be076a6 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Wed, 16 Sep 2015 14:57:30 +0000 Subject: [PATCH] AMQ-5923 - Increasing test timeout times Logging showed that intermittent test failures were caused by not giving the tests enough time to finish. Also switched message generation to create random sizes in order to improve testing. --- .../cursors/AbstractPendingMessageCursorTest.java | 14 +++++++------- .../cursors/KahaDBPendingMessageCursorTest.java | 4 ++-- .../cursors/MemoryPendingMessageCursorTest.java | 6 +++--- .../store/AbstractMessageStoreSizeStatTest.java | 8 ++++---- .../store/AbstractStoreStatTestSupport.java | 15 ++++++++------- .../kahadb/KahaDBMessageStoreSizeStatTest.java | 2 +- .../MultiKahaDBMessageStoreSizeStatTest.java | 4 ++-- .../memory/MemoryMessageStoreSizeStatTest.java | 4 ++-- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java index 9b8ea91481..798746bf56 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java @@ -179,7 +179,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat verifyStoreStats(dest, 0, 0); } - @Test(timeout=10000) + @Test(timeout=30000) public void testTopicMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -205,7 +205,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat connection.close(); } - @Test(timeout=10000) + @Test(timeout=30000) public void testTopicNonPersistentMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -232,7 +232,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat connection.close(); } - @Test(timeout=10000) + @Test(timeout=30000) public void testTopicPersistentAndNonPersistentMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -261,7 +261,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat connection.close(); } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeOneDurable() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); @@ -286,7 +286,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat connection.close(); } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeOneDurablePartialConsumption() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -312,7 +312,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat connection.close(); } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeTwoDurables() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -518,7 +518,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat MessageProducer prod = session.createProducer(topic); prod.setDeliveryMode(deliveryMode); for (int i = 0; i < publishSize; i++) { - prod.send(createMessage(session, AbstractPendingMessageCursorTest.maxMessageSize, publishedMessageSize)); + prod.send(createMessage(i, session, AbstractPendingMessageCursorTest.maxMessageSize, publishedMessageSize)); } } finally { diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java index 557c70e6a5..b0bca7d9e4 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java @@ -68,7 +68,7 @@ public class KahaDBPendingMessageCursorTest extends * * @throws Exception */ - @Test(timeout=10000) + @Test(timeout=30000) public void testDurableMessageSizeAfterRestartAndPublish() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -107,7 +107,7 @@ public class KahaDBPendingMessageCursorTest extends * * @throws Exception */ - @Test(timeout=10000) + @Test(timeout=30000) public void testNonPersistentDurableMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java index 948193d99d..16d1919502 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/MemoryPendingMessageCursorTest.java @@ -48,7 +48,7 @@ public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursor @Override - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeOneDurable() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); @@ -77,7 +77,7 @@ public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursor } @Override - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeTwoDurables() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -109,7 +109,7 @@ public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursor } @Override - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeOneDurablePartialConsumption() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java index 116500efec..8f17746640 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java @@ -92,7 +92,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat protected abstract void initPersistence(BrokerService brokerService) throws IOException; - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSize() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -100,7 +100,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat verifyStats(dest, 200, publishedMessageSize.get()); } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeAfterConsumption() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -112,7 +112,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat verifyStats(dest, 0, 0); } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeOneDurable() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); @@ -133,7 +133,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat connection.close(); } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeTwoDurables() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractStoreStatTestSupport.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractStoreStatTestSupport.java index 085becbd09..e0e8992b9e 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractStoreStatTestSupport.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractStoreStatTestSupport.java @@ -179,8 +179,7 @@ public abstract class AbstractStoreStatTestSupport { MessageProducer prod = session.createProducer(queue); prod.setDeliveryMode(deliveryMode); for (int i = 0; i < count; i++) { - LOG.info("Publishing message: " + i + ", size: " + messageSize); - prod.send(createMessage(session, messageSize, publishedMessageSize)); + prod.send(createMessage(i, session, messageSize, publishedMessageSize)); } } finally { @@ -230,8 +229,7 @@ public abstract class AbstractStoreStatTestSupport { MessageProducer prod = session.createProducer(topic); prod.setDeliveryMode(deliveryMode); for (int i = 0; i < publishSize; i++) { - LOG.info("Publishing message: " + i + ", size: " + messageSize); - prod.send(createMessage(session, messageSize, publishedMessageSize)); + prod.send(createMessage(i, session, messageSize, publishedMessageSize)); } //verify the view has expected messages @@ -254,14 +252,17 @@ public abstract class AbstractStoreStatTestSupport { } /** - * Generate random messages between 100 bytes and messageSize + * Generate random messages between 100 bytes and maxMessageSize * @param session * @return * @throws JMSException */ - protected BytesMessage createMessage(Session session, int messageSize, AtomicLong publishedMessageSize) throws JMSException { + protected BytesMessage createMessage(int count, Session session, int maxMessageSize, AtomicLong publishedMessageSize) throws JMSException { final BytesMessage message = session.createBytesMessage(); - int size = messageSize; + + final Random randomSize = new Random(); + int size = randomSize.nextInt((maxMessageSize - 100) + 1) + 100; + LOG.info("Creating message to publish: " + count + ", size: " + size); if (publishedMessageSize != null) { publishedMessageSize.addAndGet(size); } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java index 276a310bba..5a302ca129 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java @@ -65,7 +65,7 @@ public class KahaDBMessageStoreSizeStatTest extends * * @throws Exception */ - @Test + @Test(timeout=30000) public void testMessageSizeAfterRestartAndPublish() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Destination dest = publishTestQueueMessages(200, publishedMessageSize); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java index 3572accc24..0adfcff521 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java @@ -85,7 +85,7 @@ public class MultiKahaDBMessageStoreSizeStatTest extends * * @throws Exception */ - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeAfterRestartAndPublish() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); @@ -104,7 +104,7 @@ public class MultiKahaDBMessageStoreSizeStatTest extends } - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeAfterRestartAndPublishMultiQueue() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize2 = new AtomicLong(); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/memory/MemoryMessageStoreSizeStatTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/store/memory/MemoryMessageStoreSizeStatTest.java index ba2ae33d64..0e8250b14b 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/memory/MemoryMessageStoreSizeStatTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/memory/MemoryMessageStoreSizeStatTest.java @@ -47,7 +47,7 @@ public class MemoryMessageStoreSizeStatTest extends AbstractMessageStoreSizeStat } @Override - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeOneDurable() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); @@ -72,7 +72,7 @@ public class MemoryMessageStoreSizeStatTest extends AbstractMessageStoreSizeStat } @Override - @Test(timeout=10000) + @Test(timeout=30000) public void testMessageSizeTwoDurables() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();