SOLR-11452: Leader from collectionState can be null

This commit is contained in:
Cao Manh Dat 2017-10-30 10:04:08 +07:00
parent e0239b9e84
commit cc519b9ddd
1 changed files with 6 additions and 2 deletions

View File

@ -676,8 +676,12 @@ public class TestTlogReplica extends SolrCloudTestCase {
String oldLeaderNodeName = oldLeaderJetty.getNodeName(); String oldLeaderNodeName = oldLeaderJetty.getNodeName();
ChaosMonkey.kill(oldLeaderJetty); ChaosMonkey.kill(oldLeaderJetty);
waitForState("Replica not removed", collectionName, activeReplicaCount(0, 1, 0)); waitForState("Replica not removed", collectionName, activeReplicaCount(0, 1, 0));
waitForState("Expect new leader", collectionName, (liveNodes, collectionState) -> waitForState("Expect new leader", collectionName,
!collectionState.getLeader("shard1").getNodeName().equals(oldLeaderNodeName) (liveNodes, collectionState) -> {
Replica leader = collectionState.getLeader("shard1");
if (leader == null) return false;
return !leader.getNodeName().equals(oldLeaderNodeName);
}
); );
ChaosMonkey.start(oldLeaderJetty); ChaosMonkey.start(oldLeaderJetty);
waitForState("Replica not added", collectionName, activeReplicaCount(0, 2, 0)); waitForState("Replica not added", collectionName, activeReplicaCount(0, 2, 0));