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 2011/12/01 20:25:39 UTC
svn commit: r1209201 -
/activemq/trunk/activemq-spring/src/test/java/org/apache/bugs/LoadBalanceTest.java
Author: gtully
Date: Thu Dec 1 19:25:38 2011
New Revision: 1209201
URL: http://svn.apache.org/viewvc?rev=1209201&view=rev
Log:
have test wait for both network bridges before starting producer to check load balance
Modified:
activemq/trunk/activemq-spring/src/test/java/org/apache/bugs/LoadBalanceTest.java
Modified: activemq/trunk/activemq-spring/src/test/java/org/apache/bugs/LoadBalanceTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-spring/src/test/java/org/apache/bugs/LoadBalanceTest.java?rev=1209201&r1=1209200&r2=1209201&view=diff
==============================================================================
--- activemq/trunk/activemq-spring/src/test/java/org/apache/bugs/LoadBalanceTest.java (original)
+++ activemq/trunk/activemq-spring/src/test/java/org/apache/bugs/LoadBalanceTest.java Thu Dec 1 19:25:38 2011
@@ -177,7 +177,7 @@ public class LoadBalanceTest {
}
});
- waitForBridgeFormation(10000);
+ waitForBridgeFormation();
startProducer.countDown();
pool.shutdown();
@@ -291,7 +291,7 @@ public class LoadBalanceTest {
});
// give network a chance to build, needs advisories
- waitForBridgeFormation(10000);
+ waitForBridgeFormation();
startProducer.countDown();
pool.shutdown();
@@ -321,16 +321,24 @@ public class LoadBalanceTest {
// need to ensure broker bridge is alive before starting the consumer
// peeking at the internals will give us this info
- private void waitForBridgeFormation(long delay) throws Exception {
- long done = System.currentTimeMillis() + delay;
+ private void waitForBridgeFormation() throws Exception {
+ long done = System.currentTimeMillis() + 30000;
while (done > System.currentTimeMillis()) {
- BrokerService broker = BrokerRegistry.getInstance().lookup("two");
+ if (hasBridge("one") && hasBridge("two")) {
+ return;
+ }
+ Thread.sleep(1000);
+ }
+ }
+
+ private boolean hasBridge(String name) {
+ boolean result = false;
+ BrokerService broker = BrokerRegistry.getInstance().lookup(name);
if (broker != null && !broker.getNetworkConnectors().isEmpty()) {
if (!broker.getNetworkConnectors().get(0).activeBridges().isEmpty()) {
- return;
+ result = true;
}
}
- Thread.sleep(1000);
- }
+ return result;
}
}