Apache Solr open-source search software
SOLR-7774: revise BasicDistributedZkTest.test logic w.r.t. 'commitWithin did not work on some nodes'
Christine Poerschkef81a8348ab68
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 6a1092e3719..f86501599dc 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -252,6 +252,9 @@ Other Changes* SOLR-8381: Cleanup data_driven managed-schema and solrconfig.xml files. Commented out copyFields are removedand solrconfig.xml doesn't refer to field which are not defined. (Varun Thacker)+* SOLR-7774: revise BasicDistributedZkTest.test logic w.r.t. 'commitWithin did not work on some nodes'+ (Christine Poerschke)+================== 5.4.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this releasediff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.javaindex 7f39a548d8b..e06b4769139 100644--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java@@ -64,6 +64,7 @@ import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.HashSet;+import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;@@ -322,21 +323,28 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {// try commitWithinlong before = cloudClient.query(new SolrQuery("*:*")).getResults().getNumFound();+ for (SolrClient client : clients) {+ assertEquals("unexpected pre-commitWithin document count on node: " + ((HttpSolrClient)client).getBaseURL(), before, client.query(new SolrQuery("*:*")).getResults().getNumFound());+ }+ModifiableSolrParams params = new ModifiableSolrParams();params.set("commitWithin", 10);add(cloudClient, params, getDoc("id", 300));+ final List<SolrClient> clientsToCheck = new ArrayList<>(clients);TimeOut timeout = new TimeOut(45, TimeUnit.SECONDS);- while (cloudClient.query(new SolrQuery("*:*")).getResults().getNumFound() != before + 1) {- if (timeout.hasTimedOut()) {- fail("commitWithin did not work");+ do {+ final Iterator<SolrClient> it = clientsToCheck.iterator();+ while (it.hasNext()) {+ final SolrClient sc = it.next();+ if ((before + 1) == sc.query(new SolrQuery("*:*")).getResults().getNumFound()) {+ it.remove();+ }}Thread.sleep(100);- }+ } while (!clientsToCheck.isEmpty() && !timeout.hasTimedOut());- for (SolrClient client : clients) {- assertEquals("commitWithin did not work on node: " + ((HttpSolrClient)client).getBaseURL(), before + 1, client.query(new SolrQuery("*:*")).getResults().getNumFound());- }+ assertTrue("commitWithin did not work on some nodes: "+clientsToCheck, clientsToCheck.isEmpty());// TODO: This test currently fails because debug info is obtained only// on shards with matches.