git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1459969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-03-22 20:24:43 +00:00
parent 9027d49516
commit 091ee37b8e
1 changed files with 8 additions and 4 deletions

View File

@ -53,7 +53,7 @@ public class LoadBalanceTest {
private static final String TESTING_QUEUE = "testingqueue"; private static final String TESTING_QUEUE = "testingqueue";
private static int networkBridgePrefetch = 1000; private static int networkBridgePrefetch = 1000;
@Test @Test(timeout=120000)
public void does_load_balance_between_consumers() throws Exception { public void does_load_balance_between_consumers() throws Exception {
BrokerService brokerService1 = null; BrokerService brokerService1 = null;
BrokerService brokerService2 = null; BrokerService brokerService2 = null;
@ -61,13 +61,13 @@ public class LoadBalanceTest {
final AtomicInteger broker1Count = new AtomicInteger(0); final AtomicInteger broker1Count = new AtomicInteger(0);
final AtomicInteger broker2Count = new AtomicInteger(0); final AtomicInteger broker2Count = new AtomicInteger(0);
final CountDownLatch startProducer = new CountDownLatch(1); final CountDownLatch startProducer = new CountDownLatch(1);
final CountDownLatch consumer1Started = new CountDownLatch(1);
final CountDownLatch consumer2Started = new CountDownLatch(1);
String broker1Uri; String broker1Uri;
String broker2Uri; String broker2Uri;
try { try {
brokerService1 = new BrokerService(); brokerService1 = new BrokerService();
brokerService1.setBrokerName("one"); brokerService1.setBrokerName("one");
brokerService1.setUseJmx(false); brokerService1.setUseJmx(false);
@ -118,6 +118,7 @@ public class LoadBalanceTest {
}); });
container1.afterPropertiesSet(); container1.afterPropertiesSet();
container1.start(); container1.start();
consumer1Started.countDown();
pool.submit(new Callable<Object>() { pool.submit(new Callable<Object>() {
@Override @Override
@ -143,6 +144,7 @@ public class LoadBalanceTest {
}); });
container2.afterPropertiesSet(); container2.afterPropertiesSet();
container2.start(); container2.start();
consumer2Started.countDown();
assertTrue("wait for start signal", startProducer.await(20, TimeUnit.SECONDS)); assertTrue("wait for start signal", startProducer.await(20, TimeUnit.SECONDS));
@ -185,9 +187,11 @@ public class LoadBalanceTest {
waitForBridgeFormation(); waitForBridgeFormation();
startProducer.countDown(); startProducer.countDown();
consumer1Started.await();
consumer2Started.await();
pool.shutdown(); pool.shutdown();
pool.awaitTermination(10, TimeUnit.SECONDS); pool.awaitTermination(20, TimeUnit.SECONDS);
LOG.info("broker1Count " + broker1Count.get() + ", broker2Count " + broker2Count.get()); LOG.info("broker1Count " + broker1Count.get() + ", broker2Count " + broker2Count.get());
int count = 0; int count = 0;