have test wait for both network bridges before starting producer to check load balance

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1209201 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-12-01 19:25:38 +00:00
parent 3a26442d92
commit d04c10845c
1 changed files with 17 additions and 9 deletions

View File

@ -177,7 +177,7 @@ public class LoadBalanceTest {
} }
}); });
waitForBridgeFormation(10000); waitForBridgeFormation();
startProducer.countDown(); startProducer.countDown();
pool.shutdown(); pool.shutdown();
@ -291,7 +291,7 @@ public class LoadBalanceTest {
}); });
// give network a chance to build, needs advisories // give network a chance to build, needs advisories
waitForBridgeFormation(10000); waitForBridgeFormation();
startProducer.countDown(); startProducer.countDown();
pool.shutdown(); pool.shutdown();
@ -321,16 +321,24 @@ public class LoadBalanceTest {
// need to ensure broker bridge is alive before starting the consumer // need to ensure broker bridge is alive before starting the consumer
// peeking at the internals will give us this info // peeking at the internals will give us this info
private void waitForBridgeFormation(long delay) throws Exception { private void waitForBridgeFormation() throws Exception {
long done = System.currentTimeMillis() + delay; long done = System.currentTimeMillis() + 30000;
while (done > System.currentTimeMillis()) { while (done > System.currentTimeMillis()) {
BrokerService broker = BrokerRegistry.getInstance().lookup("two"); if (hasBridge("one") && hasBridge("two")) {
if (broker != null && !broker.getNetworkConnectors().isEmpty()) { return;
if (!broker.getNetworkConnectors().get(0).activeBridges().isEmpty()) {
return;
}
} }
Thread.sleep(1000); 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()) {
result = true;
}
}
return result;
}
} }