mirror of https://github.com/apache/lucene.git
SOLR-12762: Fix javadoc for SolrCloudTestCase.clusterShape() method and add a method that validates only against Active slices while testing
This commit is contained in:
parent
623cdf29ad
commit
a1b6db26db
|
@ -84,7 +84,11 @@ Apache ZooKeeper 3.4.11
|
||||||
Jetty 9.4.11.v20180605
|
Jetty 9.4.11.v20180605
|
||||||
|
|
||||||
|
|
||||||
(No Changes)
|
Other Changes
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* SOLR-12762: Fix javadoc for SolrCloudTestCase.clusterShape() method and add a method that validates only against
|
||||||
|
Active slices (Anshum Gupta)
|
||||||
|
|
||||||
|
|
||||||
================== 7.5.0 ==================
|
================== 7.5.0 ==================
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link CollectionStatePredicate} that returns true if a collection has the expected
|
* Return a {@link CollectionStatePredicate} that returns true if a collection has the expected
|
||||||
* number of active shards and active replicas
|
* number of shards and active replicas
|
||||||
*/
|
*/
|
||||||
public static CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas) {
|
public static CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas) {
|
||||||
return (liveNodes, collectionState) -> {
|
return (liveNodes, collectionState) -> {
|
||||||
|
@ -291,6 +291,27 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
|
||||||
return false;
|
return false;
|
||||||
if (collectionState.getSlices().size() != expectedShards)
|
if (collectionState.getSlices().size() != expectedShards)
|
||||||
return false;
|
return false;
|
||||||
|
if (compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState)) return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a {@link CollectionStatePredicate} that returns true if a collection has the expected
|
||||||
|
* number of active shards and active replicas
|
||||||
|
*/
|
||||||
|
public static CollectionStatePredicate activeClusterShape(int expectedShards, int expectedReplicas) {
|
||||||
|
return (liveNodes, collectionState) -> {
|
||||||
|
if (collectionState == null)
|
||||||
|
return false;
|
||||||
|
if (collectionState.getActiveSlices().size() != expectedShards)
|
||||||
|
return false;
|
||||||
|
if (compareActiveReplicaCountsForShards(expectedReplicas, liveNodes, collectionState)) return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean compareActiveReplicaCountsForShards(int expectedReplicas, Set<String> liveNodes, DocCollection collectionState) {
|
||||||
for (Slice slice : collectionState) {
|
for (Slice slice : collectionState) {
|
||||||
int activeReplicas = 0;
|
int activeReplicas = 0;
|
||||||
for (Replica replica : slice) {
|
for (Replica replica : slice) {
|
||||||
|
@ -298,10 +319,9 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
|
||||||
activeReplicas++;
|
activeReplicas++;
|
||||||
}
|
}
|
||||||
if (activeReplicas != expectedReplicas)
|
if (activeReplicas != expectedReplicas)
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue