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.
This commit is contained in:
Christopher L. Shannon (cshannon) 2015-09-16 14:57:30 +00:00
parent 4cddd2c015
commit 8a09b7e5f6
8 changed files with 29 additions and 28 deletions

View File

@ -179,7 +179,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
verifyStoreStats(dest, 0, 0); verifyStoreStats(dest, 0, 0);
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testTopicMessageSize() throws Exception { public void testTopicMessageSize() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -205,7 +205,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
connection.close(); connection.close();
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testTopicNonPersistentMessageSize() throws Exception { public void testTopicNonPersistentMessageSize() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -232,7 +232,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
connection.close(); connection.close();
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testTopicPersistentAndNonPersistentMessageSize() throws Exception { public void testTopicPersistentAndNonPersistentMessageSize() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -261,7 +261,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
connection.close(); connection.close();
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeOneDurable() throws Exception { public void testMessageSizeOneDurable() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();
@ -286,7 +286,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
connection.close(); connection.close();
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeOneDurablePartialConsumption() throws Exception { public void testMessageSizeOneDurablePartialConsumption() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -312,7 +312,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
connection.close(); connection.close();
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeTwoDurables() throws Exception { public void testMessageSizeTwoDurables() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -518,7 +518,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
MessageProducer prod = session.createProducer(topic); MessageProducer prod = session.createProducer(topic);
prod.setDeliveryMode(deliveryMode); prod.setDeliveryMode(deliveryMode);
for (int i = 0; i < publishSize; i++) { for (int i = 0; i < publishSize; i++) {
prod.send(createMessage(session, AbstractPendingMessageCursorTest.maxMessageSize, publishedMessageSize)); prod.send(createMessage(i, session, AbstractPendingMessageCursorTest.maxMessageSize, publishedMessageSize));
} }
} finally { } finally {

View File

@ -68,7 +68,7 @@ public class KahaDBPendingMessageCursorTest extends
* *
* @throws Exception * @throws Exception
*/ */
@Test(timeout=10000) @Test(timeout=30000)
public void testDurableMessageSizeAfterRestartAndPublish() throws Exception { public void testDurableMessageSizeAfterRestartAndPublish() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -107,7 +107,7 @@ public class KahaDBPendingMessageCursorTest extends
* *
* @throws Exception * @throws Exception
*/ */
@Test(timeout=10000) @Test(timeout=30000)
public void testNonPersistentDurableMessageSize() throws Exception { public void testNonPersistentDurableMessageSize() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();

View File

@ -48,7 +48,7 @@ public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursor
@Override @Override
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeOneDurable() throws Exception { public void testMessageSizeOneDurable() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();
@ -77,7 +77,7 @@ public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursor
} }
@Override @Override
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeTwoDurables() throws Exception { public void testMessageSizeTwoDurables() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -109,7 +109,7 @@ public class MemoryPendingMessageCursorTest extends AbstractPendingMessageCursor
} }
@Override @Override
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeOneDurablePartialConsumption() throws Exception { public void testMessageSizeOneDurablePartialConsumption() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();

View File

@ -92,7 +92,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
protected abstract void initPersistence(BrokerService brokerService) throws IOException; protected abstract void initPersistence(BrokerService brokerService) throws IOException;
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSize() throws Exception { public void testMessageSize() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -100,7 +100,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
verifyStats(dest, 200, publishedMessageSize.get()); verifyStats(dest, 200, publishedMessageSize.get());
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeAfterConsumption() throws Exception { public void testMessageSizeAfterConsumption() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -112,7 +112,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
verifyStats(dest, 0, 0); verifyStats(dest, 0, 0);
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeOneDurable() throws Exception { public void testMessageSizeOneDurable() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();
@ -133,7 +133,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
connection.close(); connection.close();
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeTwoDurables() throws Exception { public void testMessageSizeTwoDurables() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();

View File

@ -179,8 +179,7 @@ public abstract class AbstractStoreStatTestSupport {
MessageProducer prod = session.createProducer(queue); MessageProducer prod = session.createProducer(queue);
prod.setDeliveryMode(deliveryMode); prod.setDeliveryMode(deliveryMode);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
LOG.info("Publishing message: " + i + ", size: " + messageSize); prod.send(createMessage(i, session, messageSize, publishedMessageSize));
prod.send(createMessage(session, messageSize, publishedMessageSize));
} }
} finally { } finally {
@ -230,8 +229,7 @@ public abstract class AbstractStoreStatTestSupport {
MessageProducer prod = session.createProducer(topic); MessageProducer prod = session.createProducer(topic);
prod.setDeliveryMode(deliveryMode); prod.setDeliveryMode(deliveryMode);
for (int i = 0; i < publishSize; i++) { for (int i = 0; i < publishSize; i++) {
LOG.info("Publishing message: " + i + ", size: " + messageSize); prod.send(createMessage(i, session, messageSize, publishedMessageSize));
prod.send(createMessage(session, messageSize, publishedMessageSize));
} }
//verify the view has expected messages //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 * @param session
* @return * @return
* @throws JMSException * @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(); 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) { if (publishedMessageSize != null) {
publishedMessageSize.addAndGet(size); publishedMessageSize.addAndGet(size);
} }

View File

@ -65,7 +65,7 @@ public class KahaDBMessageStoreSizeStatTest extends
* *
* @throws Exception * @throws Exception
*/ */
@Test @Test(timeout=30000)
public void testMessageSizeAfterRestartAndPublish() throws Exception { public void testMessageSizeAfterRestartAndPublish() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Destination dest = publishTestQueueMessages(200, publishedMessageSize); Destination dest = publishTestQueueMessages(200, publishedMessageSize);

View File

@ -85,7 +85,7 @@ public class MultiKahaDBMessageStoreSizeStatTest extends
* *
* @throws Exception * @throws Exception
*/ */
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeAfterRestartAndPublish() throws Exception { public void testMessageSizeAfterRestartAndPublish() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
@ -104,7 +104,7 @@ public class MultiKahaDBMessageStoreSizeStatTest extends
} }
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeAfterRestartAndPublishMultiQueue() throws Exception { public void testMessageSizeAfterRestartAndPublishMultiQueue() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
AtomicLong publishedMessageSize2 = new AtomicLong(); AtomicLong publishedMessageSize2 = new AtomicLong();

View File

@ -47,7 +47,7 @@ public class MemoryMessageStoreSizeStatTest extends AbstractMessageStoreSizeStat
} }
@Override @Override
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeOneDurable() throws Exception { public void testMessageSizeOneDurable() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();
@ -72,7 +72,7 @@ public class MemoryMessageStoreSizeStatTest extends AbstractMessageStoreSizeStat
} }
@Override @Override
@Test(timeout=10000) @Test(timeout=30000)
public void testMessageSizeTwoDurables() throws Exception { public void testMessageSizeTwoDurables() throws Exception {
AtomicLong publishedMessageSize = new AtomicLong(); AtomicLong publishedMessageSize = new AtomicLong();
Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection(); Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();