From e8d9b709e02827ac0471953f4407b27e7118ffa4 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Wed, 16 Feb 2011 17:42:19 +0000 Subject: [PATCH] remove duplicate test and add auto fail, see if we can find why it hangs in hudson git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1071323 13f79535-47bb-0310-9956-ffa450edef68 --- .../broker/region/QueuePurgeTest.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java index e4743d38d6..17ce3035fc 100644 --- a/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java @@ -33,7 +33,9 @@ import javax.management.ObjectName; import junit.framework.TestCase; import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.CombinationTestSupport; import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.BrokerTestSupport; import org.apache.activemq.broker.jmx.QueueViewMBean; import org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy; import org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy; @@ -43,8 +45,9 @@ import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QueuePurgeTest extends TestCase { +public class QueuePurgeTest extends CombinationTestSupport { private static final Logger LOG = LoggerFactory.getLogger(QueuePurgeTest.class); + private static final int NUM_TO_SEND = 40000; private final String MESSAGE_TEXT = new String(new byte[1024]); BrokerService broker; ConnectionFactory factory; @@ -54,12 +57,17 @@ public class QueuePurgeTest extends TestCase { MessageConsumer consumer; protected void setUp() throws Exception { + setMaxTestTime(10*60*1000); // 10 mins + setAutoFail(true); + super.setUp(); broker = new BrokerService(); - broker.setDataDirectory("target/activemq-data"); + + File testDataDir = new File("target/activemq-data/QueuePurgeTest"); + broker.setDataDirectoryFile(testDataDir); broker.setUseJmx(true); broker.setDeleteAllMessagesOnStartup(true); KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); - persistenceAdapter.setDirectory(new File("target/activemq-data/kahadb/QueuePurgeTest")); + persistenceAdapter.setDirectory(new File(testDataDir, "kahadb")); broker.setPersistenceAdapter(persistenceAdapter); broker.addConnector("tcp://localhost:0"); broker.start(); @@ -69,6 +77,7 @@ public class QueuePurgeTest extends TestCase { } protected void tearDown() throws Exception { + super.tearDown(); if (consumer != null) { consumer.close(); } @@ -78,19 +87,9 @@ public class QueuePurgeTest extends TestCase { broker.stop(); } - public void testPurgeQueueWithActiveConsumer() throws Exception { - createProducerAndSendMessages(10000); - QueueViewMBean proxy = getProxyToQueueViewMBean(); - createConsumer(); - proxy.purge(); - assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0, - proxy.getQueueSize()); - } - - - public void testPurgeLargeQueue() throws Exception { + public void testPurgeLargeQueue() throws Exception { applyBrokerSpoolingPolicy(); - createProducerAndSendMessages(90000); + createProducerAndSendMessages(NUM_TO_SEND); QueueViewMBean proxy = getProxyToQueueViewMBean(); LOG.info("purging.."); proxy.purge(); @@ -103,11 +102,11 @@ public class QueuePurgeTest extends TestCase { applyBrokerSpoolingPolicy(); final int exprityPeriod = 1000; applyExpiryDuration(exprityPeriod); - createProducerAndSendMessages(90000); + createProducerAndSendMessages(NUM_TO_SEND); QueueViewMBean proxy = getProxyToQueueViewMBean(); LOG.info("waiting for expiry to kick in a bunch of times to verify it does not blow mem"); Thread.sleep(10000); - assertEquals("Queue size is has not changed " + proxy.getQueueSize(), 90000, + assertEquals("Queue size is has not changed " + proxy.getQueueSize(), NUM_TO_SEND, proxy.getQueueSize()); } @@ -129,7 +128,7 @@ public class QueuePurgeTest extends TestCase { public void testPurgeLargeQueueWithConsumer() throws Exception { applyBrokerSpoolingPolicy(); - createProducerAndSendMessages(90000); + createProducerAndSendMessages(NUM_TO_SEND); QueueViewMBean proxy = getProxyToQueueViewMBean(); createConsumer(); long start = System.currentTimeMillis(); @@ -158,7 +157,7 @@ public class QueuePurgeTest extends TestCase { MessageProducer producer = session.createProducer(queue); for (int i = 0; i < numToSend; i++) { TextMessage message = session.createTextMessage(MESSAGE_TEXT + i); - if (i != 0 && i % 50000 == 0) { + if (i != 0 && i % 10000 == 0) { LOG.info("sent: " + i); } producer.send(message);