Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 74634 invoked from network); 6 Aug 2010 09:18:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Aug 2010 09:18:25 -0000 Received: (qmail 26085 invoked by uid 500); 6 Aug 2010 09:18:25 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 26021 invoked by uid 500); 6 Aug 2010 09:18:23 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 26014 invoked by uid 99); 6 Aug 2010 09:18:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Aug 2010 09:18:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Aug 2010 09:18:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 27F6723889C5; Fri, 6 Aug 2010 09:16:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r982912 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq: JmsMultipleBrokersTestSupport.java usecases/ThreeBrokerQueueNetworkTest.java Date: Fri, 06 Aug 2010 09:16:58 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100806091659.27F6723889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gtully Date: Fri Aug 6 09:16:56 2010 New Revision: 982912 URL: http://svn.apache.org/viewvc?rev=982912&view=rev Log: revert http://svn.apache.org/viewvc?rev=982099&view=rev - seems to make tests fail locally, now work ok - mvn clean test -Dtest=SimpleNetworkTest,ThreeBrokerQueueNetworkTest Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkTest.java Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java?rev=982912&r1=982911&r2=982912&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java (original) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java Fri Aug 6 09:16:56 2010 @@ -149,18 +149,16 @@ public class JmsMultipleBrokersTestSuppo } - protected boolean waitForBridgeFormation() throws Exception { - boolean success = true; + protected void waitForBridgeFormation() throws Exception { for (BrokerItem brokerItem : brokers.values()) { final BrokerService broker = brokerItem.broker; - if (success && !broker.getNetworkConnectors().isEmpty()) { - success = success && Wait.waitFor(new Wait.Condition() { + if (!broker.getNetworkConnectors().isEmpty()) { + Wait.waitFor(new Wait.Condition() { public boolean isSatisified() throws Exception { return !broker.getNetworkConnectors().get(0).activeBridges().isEmpty(); }}); } } - return success; } protected void startAllBrokers() throws Exception { @@ -388,7 +386,6 @@ public class JmsMultipleBrokersTestSuppo brokerItem.destroy(); } brokers.clear(); - destinations.clear(); } // Class to group broker components together 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=982912&r1=982911&r2=982912&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 Fri Aug 6 09:16:56 2010 @@ -37,7 +37,6 @@ import org.apache.activemq.command.Activ import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.MessageDispatch; import org.apache.activemq.util.MessageIdList; -import org.apache.activemq.util.Wait; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -49,6 +48,10 @@ public class ThreeBrokerQueueNetworkTest protected static final int MESSAGE_COUNT = 100; private static final long MAX_WAIT_MILLIS = 10000; + interface Condition { + boolean isSatisified() throws Exception; + } + /** * BrokerA -> BrokerB -> BrokerC */ @@ -58,7 +61,7 @@ public class ThreeBrokerQueueNetworkTest bridgeBrokers("BrokerB", "BrokerC"); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -86,7 +89,7 @@ public class ThreeBrokerQueueNetworkTest bridgeBrokers("BrokerB", "BrokerC"); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -118,7 +121,7 @@ public class ThreeBrokerQueueNetworkTest bridgeBrokers("BrokerB", "BrokerC", true, 1, false); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -160,7 +163,7 @@ public class ThreeBrokerQueueNetworkTest bridgeBrokers("BrokerB", "BrokerC", true, 1, false); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -202,7 +205,7 @@ public class ThreeBrokerQueueNetworkTest bridgeBrokers("BrokerC", "BrokerB"); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -235,7 +238,7 @@ public class ThreeBrokerQueueNetworkTest bridgeBrokers("BrokerC", "BrokerA"); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -266,7 +269,7 @@ public class ThreeBrokerQueueNetworkTest bridgeAllBrokers(); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -289,19 +292,31 @@ public class ThreeBrokerQueueNetworkTest MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); MessageIdList msgsC = getConsumerMessages("BrokerC", clientC); - assertTrue("Messaged not received within time limit", Wait.waitFor(new Wait.Condition() { + waitFor(new Condition() { public boolean isSatisified() { return msgsA.getMessageCount() == MESSAGE_COUNT; } - }, MAX_WAIT_MILLIS)); + }); 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(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -327,7 +342,7 @@ public class ThreeBrokerQueueNetworkTest public void testAllConnectedWithSpare() throws Exception { bridgeAllBrokers("default", 3, false); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -355,12 +370,13 @@ public class ThreeBrokerQueueNetworkTest * http://issues.apache.org/activemq/browse/AMQ-2530 - which highlights that * For a Conduit bridge - local subscription Ids weren't removed in a ConduitBridge * The test fails because on closing clientA - clientB correctly receives all the - * messages - ie. half don't get stuck on BrokerA - + * messages - ie. half dont get stuck on BrokerA - */ public void XtestMigrateConsumerStuckMessages() throws Exception { - bridgeAllBrokers("default", 3, false); + boolean suppressQueueDuplicateSubscriptions = false; + bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -418,7 +434,7 @@ public class ThreeBrokerQueueNetworkTest boolean decreaseNetworkConsumerPriority = true; bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions, decreaseNetworkConsumerPriority); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -460,8 +476,9 @@ public class ThreeBrokerQueueNetworkTest public void testNoDuplicateQueueSubs() throws Exception { bridgeAllBrokers("default", 3, true); + startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -531,7 +548,8 @@ public class ThreeBrokerQueueNetworkTest }); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); + // Setup consumers String brokerName = "BrokerA"; @@ -558,7 +576,7 @@ public class ThreeBrokerQueueNetworkTest bridgeAllBrokers("default", 3, false); startAllBrokers(); - assertTrue("Bridge formation incomplete", waitForBridgeFormation()); + waitForBridgeFormation(); // Setup destination Destination dest = createDestination("TEST.FOO", false); @@ -596,11 +614,11 @@ public class ThreeBrokerQueueNetworkTest private void verifyConsumerCount(BrokerService broker, int count, final Destination dest) throws Exception { final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker(); - assertTrue("RegionBroker should have at least one destination", Wait.waitFor(new Wait.Condition() { + waitFor(new Condition() { public boolean isSatisified() throws Exception { return !regionBroker.getDestinations(ActiveMQDestination.transform(dest)).isEmpty(); } - }, MAX_WAIT_MILLIS)); + }); Queue internalQueue = (Queue) regionBroker.getDestinations(ActiveMQDestination.transform(dest)).iterator().next(); assertEquals("consumer count on " + broker.getBrokerName() + " matches for q: " + internalQueue, count, internalQueue.getConsumers().size()); }