Apache Lucene open-source search software
SOLR-11407: Wait for collections to recover before starting the test.
Andrzej Bialeckieb80ca968ed2
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.javaindex fc44578f716..6f923eabd6e 100644--- a/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/admin/AutoscalingHistoryHandlerTest.java@@ -93,6 +93,8 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {.setCreateNodeSet(String.join(",", otherNodes)).setMaxShardsPerNode(3).process(solrClient);+ waitForRecovery(CollectionAdminParams.SYSTEM_COLL);+ waitForRecovery(COLL_NAME);}public static class TesterListener extends TriggerListenerBase {@@ -353,14 +355,14 @@ public class AutoscalingHistoryHandlerTest extends SolrCloudTestCase {if (docs.size() != expected) {log.info("History query: " + query);log.info("Wrong response: " + rsp);- query = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);- log.info("Full response: " + client.query(query));+ ModifiableSolrParams fullQuery = params(CommonParams.QT, CommonParams.AUTOSCALING_HISTORY_PATH);+ log.info("Full response: " + client.query(fullQuery));}assertEquals("Wrong number of documents", expected, docs.size());return docs;}- private void waitForRecovery(String collection) throws Exception {+ private static void waitForRecovery(String collection) throws Exception {log.info("Waiting for recovery of " + collection);boolean recovered = false;boolean allActive = true;diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.javaindex 42c4577d972..b8bf1f4d857 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java@@ -243,7 +243,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {/*** Get the collection state for a particular collection*/- protected DocCollection getCollectionState(String collectionName) {+ protected static DocCollection getCollectionState(String collectionName) {return cluster.getSolrClient().getZkStateReader().getClusterState().getCollection(collectionName);}@@ -256,7 +256,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {* @param collection the collection to watch* @param predicate a predicate to match against the collection state*/- protected void waitForState(String message, String collection, CollectionStatePredicate predicate) {+ protected static void waitForState(String message, String collection, CollectionStatePredicate predicate) {AtomicReference<DocCollection> state = new AtomicReference<>();AtomicReference<Set<String>> liveNodesLastSeen = new AtomicReference<>();try {