[TEST] [ML] Run ensureStableCluster(...) on all nodes and run synched flush before executing the disrupt

Original commit: elastic/x-pack-elasticsearch@d10beacb73
This commit is contained in:
Martijn van Groningen 2017-04-07 09:51:13 +02:00
parent ee5ab5b1d2
commit b248b6dbfc
1 changed files with 12 additions and 5 deletions

View File

@ -44,13 +44,13 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
public void testFailOver() throws Exception { public void testFailOver() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(3); internalCluster().ensureAtLeastNumDataNodes(3);
ensureStableCluster(3); ensureStableClusterOnAllNodes(3);
run(() -> { run(() -> {
GetJobsStatsAction.Request request = new GetJobsStatsAction.Request("job_id"); GetJobsStatsAction.Request request = new GetJobsStatsAction.Request("job_id");
GetJobsStatsAction.Response response = client().execute(GetJobsStatsAction.INSTANCE, request).actionGet(); GetJobsStatsAction.Response response = client().execute(GetJobsStatsAction.INSTANCE, request).actionGet();
DiscoveryNode discoveryNode = response.getResponse().results().get(0).getNode(); DiscoveryNode discoveryNode = response.getResponse().results().get(0).getNode();
internalCluster().stopRandomNode(settings -> discoveryNode.getName().equals(settings.get("node.name"))); internalCluster().stopRandomNode(settings -> discoveryNode.getName().equals(settings.get("node.name")));
ensureStableCluster(2); ensureStableClusterOnAllNodes(2);
}); });
} }
@ -67,7 +67,7 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
String mlAndDataNode = internalCluster().startNode(Settings.builder() String mlAndDataNode = internalCluster().startNode(Settings.builder()
.put("node.master", false) .put("node.master", false)
.build()); .build());
ensureStableCluster(2); ensureStableClusterOnAllNodes(2);
run(() -> { run(() -> {
logger.info("Stopping dedicated master node"); logger.info("Stopping dedicated master node");
internalCluster().stopRandomNode(settings -> settings.getAsBoolean("node.master", false)); internalCluster().stopRandomNode(settings -> settings.getAsBoolean("node.master", false));
@ -82,13 +82,13 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
.put("node.data", false) .put("node.data", false)
.put("node.ml", false) .put("node.ml", false)
.build()); .build());
ensureStableCluster(2); ensureStableClusterOnAllNodes(2);
}); });
} }
public void testFullClusterRestart() throws Exception { public void testFullClusterRestart() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(3); internalCluster().ensureAtLeastNumDataNodes(3);
ensureStableCluster(3); ensureStableClusterOnAllNodes(3);
run(() -> { run(() -> {
logger.info("Restarting all nodes"); logger.info("Restarting all nodes");
internalCluster().fullRestart(); internalCluster().fullRestart();
@ -131,6 +131,7 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
assertEquals(numDocs1, dataCounts.getProcessedRecordCount()); assertEquals(numDocs1, dataCounts.getProcessedRecordCount());
assertEquals(0L, dataCounts.getOutOfOrderTimeStampCount()); assertEquals(0L, dataCounts.getOutOfOrderTimeStampCount());
}); });
client().admin().indices().prepareSyncedFlush().get();
disrupt.run(); disrupt.run();
assertBusy(() -> { assertBusy(() -> {
@ -186,4 +187,10 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase {
} }
} }
private void ensureStableClusterOnAllNodes(int nodeCount) {
for (String nodeName : internalCluster().getNodeNames()) {
ensureStableCluster(nodeCount, nodeName);
}
}
} }