From f6cbce1c6ec45d02653070bd09b4f48800c010b9 Mon Sep 17 00:00:00 2001 From: Cao Manh Dat Date: Tue, 31 Oct 2017 09:13:02 +0700 Subject: [PATCH] SOLR-11576: CollectionsAPIDistributedZkTest.testCollectionsAPI() get failed when query node has stale clusterstate --- .../cloud/CollectionsAPIDistributedZkTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java index b2f0d44a47a..b385b4f8f8b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java @@ -457,7 +457,21 @@ public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase { .add("id", "7") .add("id", "8") .commit(cluster.getSolrClient(), collectionName); - assertEquals(3, cluster.getSolrClient().query(collectionName, new SolrQuery("*:*")).getResults().getNumFound()); + TimeOut timeOut = new TimeOut(10, TimeUnit.SECONDS); + while (!timeOut.hasTimedOut()) { + try { + long numFound = cluster.getSolrClient().query(collectionName, new SolrQuery("*:*")).getResults().getNumFound(); + assertEquals(3, numFound); + break; + } catch (Exception e) { + // Query node can have stale clusterstate + log.info("Error when query " + collectionName, e); + Thread.sleep(500); + } + } + if (timeOut.hasTimedOut()) { + fail("Timeout on query " + collectionName); + } checkNoTwoShardsUseTheSameIndexDir(); }