activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
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 GMT
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());      
     }



Mime
View raw message