mirror of https://github.com/apache/lucene.git
eliminate CPU hogging spin-loops in OverseerTest
this test already uses waitForState (frequently via verifyReplicaStatus) so there is no reason to include CPU/network/ZK intensive infinite loop checks looking for udpated cluster state
This commit is contained in:
parent
7eb8703df6
commit
3030ea9d94
|
@ -670,42 +670,33 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
||||||
waitForCollections(reader, COLLECTION);
|
waitForCollections(reader, COLLECTION);
|
||||||
verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.RECOVERING);
|
verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.RECOVERING);
|
||||||
|
|
||||||
int version = getClusterStateVersion(zkClient);
|
|
||||||
|
|
||||||
mockController.publishState(COLLECTION, core, core_node, "shard1", Replica.State.ACTIVE,
|
mockController.publishState(COLLECTION, core, core_node, "shard1", Replica.State.ACTIVE,
|
||||||
numShards, true, overseers.get(0));
|
numShards, true, overseers.get(0));
|
||||||
|
|
||||||
while (version == getClusterStateVersion(zkClient));
|
|
||||||
|
|
||||||
verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.ACTIVE);
|
verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.ACTIVE);
|
||||||
version = getClusterStateVersion(zkClient);
|
|
||||||
|
|
||||||
mockController.publishState(COLLECTION, core, core_node, "shard1",
|
mockController.publishState(COLLECTION, core, core_node, "shard1",
|
||||||
Replica.State.RECOVERING, numShards, true, overseers.get(0));
|
Replica.State.RECOVERING, numShards, true, overseers.get(0));
|
||||||
|
|
||||||
overseerClient.close();
|
overseerClient.close();
|
||||||
|
|
||||||
version = getClusterStateVersion(zkClient);
|
|
||||||
|
|
||||||
overseerClient = electNewOverseer(server.getZkAddress());
|
overseerClient = electNewOverseer(server.getZkAddress());
|
||||||
|
|
||||||
while (version == getClusterStateVersion(zkClient));
|
|
||||||
|
|
||||||
verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.RECOVERING);
|
verifyReplicaStatus(reader, COLLECTION, "shard1", "core_node1", Replica.State.RECOVERING);
|
||||||
|
|
||||||
assertEquals("Live nodes count does not match", 1, reader
|
assertEquals("Live nodes count does not match", 1, reader
|
||||||
.getClusterState().getLiveNodes().size());
|
.getClusterState().getLiveNodes().size());
|
||||||
assertEquals(shard+" replica count does not match", 1, reader.getClusterState()
|
assertEquals(shard+" replica count does not match", 1, reader.getClusterState()
|
||||||
.getCollection(COLLECTION).getSlice(shard).getReplicasMap().size());
|
.getCollection(COLLECTION).getSlice(shard).getReplicasMap().size());
|
||||||
version = getClusterStateVersion(zkClient);
|
|
||||||
mockController.publishState(COLLECTION, core, core_node, "shard1", null, numShards, true, overseers.get(1));
|
mockController.publishState(COLLECTION, core, core_node, "shard1", null, numShards, true, overseers.get(1));
|
||||||
while (version == getClusterStateVersion(zkClient));
|
|
||||||
|
|
||||||
assertTrue(COLLECTION +" should remain after removal of the last core", // as of SOLR-5209 core removal does not cascade to remove the slice and collection
|
|
||||||
reader.getClusterState().hasCollection(COLLECTION));
|
|
||||||
|
|
||||||
reader.waitForState(COLLECTION, 5000,
|
reader.waitForState(COLLECTION, 5000,
|
||||||
TimeUnit.MILLISECONDS, (liveNodes, collectionState) -> collectionState != null && collectionState.getReplica(core_node) == null);
|
TimeUnit.MILLISECONDS, (liveNodes, collectionState) -> collectionState != null && collectionState.getReplica(core_node) == null);
|
||||||
|
|
||||||
|
reader.forceUpdateCollection(COLLECTION);
|
||||||
|
// as of SOLR-5209 core removal does not cascade to remove the slice and collection
|
||||||
|
assertTrue(COLLECTION +" should remain after removal of the last core",
|
||||||
|
reader.getClusterState().hasCollection(COLLECTION));
|
||||||
assertTrue(core_node+" should be gone after publishing the null state",
|
assertTrue(core_node+" should be gone after publishing the null state",
|
||||||
null == reader.getClusterState().getCollection(COLLECTION).getReplica(core_node));
|
null == reader.getClusterState().getCollection(COLLECTION).getReplica(core_node));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1055,18 +1046,11 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
mockController.close();
|
mockController.close();
|
||||||
|
|
||||||
int version = getClusterStateVersion(zkClient);
|
|
||||||
|
|
||||||
mockController = new MockZKController(server.getZkAddress(), "node1", overseers);
|
mockController = new MockZKController(server.getZkAddress(), "node1", overseers);
|
||||||
|
|
||||||
mockController.publishState(COLLECTION, "core1", "core_node1","shard1", Replica.State.RECOVERING, 1, true, overseers.get(0));
|
mockController.publishState(COLLECTION, "core1", "core_node1","shard1", Replica.State.RECOVERING, 1, true, overseers.get(0));
|
||||||
|
|
||||||
try {
|
reader.forceUpdateCollection(COLLECTION);
|
||||||
reader.waitForState(COLLECTION, 5, TimeUnit.SECONDS, (liveNodes, collectionState) -> version == zkController
|
|
||||||
.getZkStateReader().getClusterState().getZkClusterStateVersion());
|
|
||||||
} catch (TimeoutException e) {
|
|
||||||
// okay
|
|
||||||
}
|
|
||||||
ClusterState state = reader.getClusterState();
|
ClusterState state = reader.getClusterState();
|
||||||
|
|
||||||
int numFound = 0;
|
int numFound = 0;
|
||||||
|
@ -1397,12 +1381,6 @@ public class OverseerTest extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getClusterStateVersion(SolrZkClient controllerClient)
|
|
||||||
throws KeeperException, InterruptedException {
|
|
||||||
return controllerClient.exists(ZkStateReader.CLUSTER_STATE, null, false).getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private SolrZkClient electNewOverseer(String address)
|
private SolrZkClient electNewOverseer(String address)
|
||||||
throws InterruptedException, TimeoutException, IOException,
|
throws InterruptedException, TimeoutException, IOException,
|
||||||
KeeperException, ParserConfigurationException, SAXException, NoSuchFieldException, SecurityException {
|
KeeperException, ParserConfigurationException, SAXException, NoSuchFieldException, SecurityException {
|
||||||
|
|
Loading…
Reference in New Issue