diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 501e59d35cd..e570f16fff7 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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 diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 51f12c419b2..064ad214eef 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -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(); }