SOLR-7146: MiniSolrCloudCluster based tests can fail with ZooKeeperException NoNode for /live_nodes

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1682002 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-05-27 12:48:28 +00:00
parent 4c6300f105
commit 60298db833
2 changed files with 26 additions and 0 deletions

View File

@ -97,6 +97,9 @@ Other Changes
* SOLR-7595: Allow method chaining for all CollectionAdminRequests in Solrj. (shalin)
* SOLR-7146: MiniSolrCloudCluster based tests can fail with ZooKeeperException NoNode for /live_nodes.
(Vamsee Yarlagadda via shalin)
================== 5.2.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -167,6 +167,29 @@ public class MiniSolrCloudCluster {
throw startupError;
}
try (SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(),
AbstractZkTestCase.TIMEOUT, 45000, null)) {
int numliveNodes = 0;
int retries = 60;
String liveNodesPath = "/solr/live_nodes";
// Wait up to 60 seconds for number of live_nodes to match up number of servers
do {
if (zkClient.exists(liveNodesPath, true)) {
numliveNodes = zkClient.getChildren(liveNodesPath, null, true).size();
if (numliveNodes == numServers) {
break;
}
}
retries--;
if (retries == 0) {
throw new IllegalStateException("Solr servers failed to register with ZK."
+ " Current count: " + numliveNodes + "; Expected count: " + numServers);
}
Thread.sleep(1000);
} while (numliveNodes != numServers);
}
solrClient = buildSolrClient();
}