提交 fbdbddd1 编写于 作者: R Rajan 提交者: Matteo Merli

fix Intermittent test failure in BrokerServiceThrottlingTest (#280)

上级 ea85d954
......@@ -249,8 +249,15 @@ public class BrokerServiceThrottlingTest extends BrokerTestBase {
stopBroker();
conf.setMaxConcurrentLookupRequest(1);
startBroker();
// wait for consumer to reconnect
Thread.sleep(3000);
// wait strategically for all consumers to reconnect
for (int i = 0; i < 5; i++) {
if (!areAllConsumersConnected(consumers)) {
Thread.sleep(1000 + (i * 500));
} else {
break;
}
}
int totalConnectedConsumers = 0;
for (int i = 0; i < consumers.size(); i++) {
......@@ -265,6 +272,15 @@ public class BrokerServiceThrottlingTest extends BrokerTestBase {
pulsarClient.close();
}
private boolean areAllConsumersConnected(List<Consumer> consumers) {
for (int i = 0; i < consumers.size(); i++) {
if (!((ConsumerImpl) consumers.get(i)).isConnected()) {
return false;
}
}
return true;
}
private void upsertLookupPermits(int permits) throws Exception {
Map<String, String> throttlingMap = Maps.newHashMap();
throttlingMap.put("maxConcurrentLookupRequest", Integer.toString(permits));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册