You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2009/06/30 17:58:08 UTC
svn commit: r789810 -
/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java
Author: gtully
Date: Tue Jun 30 15:58:08 2009
New Revision: 789810
URL: http://svn.apache.org/viewvc?rev=789810&view=rev
Log:
have the test wait for advisories for slower machines, resolve intermittent failure
Modified:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java?rev=789810&r1=789809&r2=789810&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java Tue Jun 30 15:58:08 2009
@@ -28,12 +28,10 @@
import javax.jms.MessageConsumer;
import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.JmsMultipleBrokersTestSupport.BrokerItem;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerFilter;
import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.region.Queue;
import org.apache.activemq.broker.region.RegionBroker;
import org.apache.activemq.broker.region.Subscription;
@@ -50,7 +48,12 @@
public class ThreeBrokerQueueNetworkTest extends JmsMultipleBrokersTestSupport {
private static final Log LOG = LogFactory.getLog(ThreeBrokerQueueNetworkTest.class);
protected static final int MESSAGE_COUNT = 100;
+ private static final long MAX_WAIT_MILLIS = 10000;
+ interface Condition {
+ boolean isSatisified() throws Exception;
+ }
+
/**
* BrokerA -> BrokerB -> BrokerC
*/
@@ -280,14 +283,31 @@
Thread.sleep(1000);
// Get message count
- MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
+ final MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
+ waitFor(new Condition() {
+ public boolean isSatisified() {
+ return msgsA.getMessageCount() == MESSAGE_COUNT;
+ }
+ });
+
assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount() + msgsB.getMessageCount() + msgsC.getMessageCount());
}
-
+ // on slow machines some more waiting is required on account of slow advisories
+ private void waitFor(Condition condition) throws Exception {
+ final long expiry = System.currentTimeMillis() + MAX_WAIT_MILLIS;
+ while (!condition.isSatisified() && System.currentTimeMillis() < expiry) {
+ Thread.sleep(1000);
+ }
+ if (System.currentTimeMillis() >= expiry) {
+ LOG.error("expired while waiting for condition " + condition);
+ }
+
+ }
+
public void testAllConnectedUsingMulticastProducerConsumerOnA() throws Exception {
bridgeAllBrokers("default", 3, false);
startAllBrokers();
@@ -551,8 +571,13 @@
}
}
- private void verifyConsumerCount(BrokerService broker, int count, Destination dest) throws Exception {
- RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
+ private void verifyConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception {
+ final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
+ waitFor(new Condition() {
+ public boolean isSatisified() throws Exception {
+ return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty();
+ }
+ });
Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next();
assertEquals("consumer count on " + broker.getBrokerName() + " matches for q: " + internalQueue, count, internalQueue.getConsumers().size());
}