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.java index 5f30f212e2f..d8d2472177d 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 @@ -64,7 +64,7 @@ import static org.apache.solr.common.cloud.ZkConfigManager.CONFIGS_ZKNODE; /** * Base class for SolrCloud tests - * + *
* Derived tests should call {@link #configureCluster(int)} in a {@code BeforeClass}
* static method or {@code Before} setUp method. This configures and starts a {@link MiniSolrCloudCluster}, available
* via the {@code cluster} variable. Cluster shutdown is handled automatically if using {@code BeforeClass}.
@@ -83,15 +83,15 @@ import static org.apache.solr.common.cloud.ZkConfigManager.CONFIGS_ZKNODE;
public class SolrCloudTestCase extends SolrTestCaseJ4 {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
+
public static final int DEFAULT_TIMEOUT = 45; // this is an important timeout for test stability - can't be too short
private static class Config {
final String name;
final Path path;
- final Map
* NB you must call {@link Builder#configure()} to start the cluster
*
* @param nodeCount the number of nodes
@@ -305,15 +314,15 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
protected static void waitForState(String message, String collection, CollectionStatePredicate predicate) {
waitForState(message, collection, predicate, DEFAULT_TIMEOUT, TimeUnit.SECONDS);
}
-
+
/**
* Wait for a particular collection state to appear in the cluster client's state reader
- *
+ *
* This is a convenience method using the {@link #DEFAULT_TIMEOUT}
*
- * @param message a message to report on failure
- * @param collection the collection to watch
- * @param predicate a predicate to match against the collection state
+ * @param message a message to report on failure
+ * @param collection the collection to watch
+ * @param predicate a predicate to match against the collection state
*/
protected static void waitForState(String message, String collection, CollectionStatePredicate predicate, int timeout, TimeUnit timeUnit) {
log.info("waitForState ({}): {}", collection, message);
@@ -340,8 +349,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
return false;
if (collectionState.getSlices().size() != expectedShards)
return false;
- if (compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState)) return true;
- return false;
+ return compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState);
};
}
@@ -356,23 +364,22 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
log.info("active slice count: " + collectionState.getActiveSlices().size() + " expected:" + expectedShards);
if (collectionState.getActiveSlices().size() != expectedShards)
return false;
- if (compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState)) return true;
- return false;
+ return compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState);
};
}
-
+
public static LiveNodesPredicate containsLiveNode(String node) {
return (oldNodes, newNodes) -> {
return newNodes.contains(node);
};
}
-
+
public static LiveNodesPredicate missingLiveNode(String node) {
return (oldNodes, newNodes) -> {
return !newNodes.contains(node);
};
}
-
+
public static LiveNodesPredicate missingLiveNodes(List
* This assumes that the replica is hosted on a live node.
*/
protected static CoreStatus getCoreStatus(Replica replica) throws IOException, SolrServerException {
@@ -476,6 +480,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
/**
* Ensure that the given number of solr instances are running. If less instances are found then new instances are
* started. If extra instances are found then they are stopped.
+ *
* @param nodeCount the number of Solr instances that should be running at the end of this method
* @throws Exception on error
*/
@@ -484,7 +489,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
List