mirror of https://github.com/apache/lucene.git
SOLR-10233: ChaosMonkeySafeLeaderWithPullReplicasTest - Catch SolrException while waiting for the cluster to be ready
This commit is contained in:
parent
b3024d67ca
commit
1e4d2052e6
|
@ -27,6 +27,7 @@ import org.apache.solr.SolrTestCaseJ4.SuppressObjectReleaseTracker;
|
||||||
import org.apache.solr.client.solrj.SolrQuery;
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
import org.apache.solr.client.solrj.SolrServerException;
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||||
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.apache.solr.common.cloud.DocCollection;
|
import org.apache.solr.common.cloud.DocCollection;
|
||||||
import org.apache.solr.common.cloud.Replica;
|
import org.apache.solr.common.cloud.Replica;
|
||||||
|
@ -234,7 +235,7 @@ public class ChaosMonkeySafeLeaderWithPullReplicasTest extends AbstractFullDistr
|
||||||
try {
|
try {
|
||||||
del("*:*");
|
del("*:*");
|
||||||
break;
|
break;
|
||||||
} catch (SolrServerException e) {
|
} catch (SolrServerException | SolrException e) {
|
||||||
// cluster may not be up yet
|
// cluster may not be up yet
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,13 @@ import java.nio.charset.Charset;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -256,13 +258,15 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
|
||||||
*/
|
*/
|
||||||
protected void waitForState(String message, String collection, CollectionStatePredicate predicate) {
|
protected void waitForState(String message, String collection, CollectionStatePredicate predicate) {
|
||||||
AtomicReference<DocCollection> state = new AtomicReference<>();
|
AtomicReference<DocCollection> state = new AtomicReference<>();
|
||||||
|
AtomicReference<Set<String>> liveNodesLastSeen = new AtomicReference<>();
|
||||||
try {
|
try {
|
||||||
cluster.getSolrClient().waitForState(collection, DEFAULT_TIMEOUT, TimeUnit.SECONDS, (n, c) -> {
|
cluster.getSolrClient().waitForState(collection, DEFAULT_TIMEOUT, TimeUnit.SECONDS, (n, c) -> {
|
||||||
state.set(c);
|
state.set(c);
|
||||||
|
liveNodesLastSeen.set(n);
|
||||||
return predicate.matches(n, c);
|
return predicate.matches(n, c);
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(message + "\n" + e.getMessage() + "\nLast available state: " + state.get());
|
fail(message + "\n" + e.getMessage() + "\nLive Nodes: " + Arrays.toString(liveNodesLastSeen.get().toArray()) + "\nLast available state: " + state.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue