From 1a8eb82a4da184d541ac77c61819f51b216b19f4 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 5 Dec 2018 17:09:59 +0100 Subject: [PATCH] Avoid shutting down the only master Today the InternalTestClusterTests sometimes set up a cluster with a single master, start some other ndoes, shut the original master down, and then reset the cluster. This doesn't really work, because the original master may be stale. This change avoids shutting down the only master in this situation. --- .../org/elasticsearch/test/test/InternalTestClusterTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java index 4fa1ae6970d36..05c99ef83d470 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java @@ -300,7 +300,8 @@ public Settings transportClientSettings() { for (String name: cluster.getNodeNames()) { shardNodePaths.put(name, getNodePaths(cluster, name)); } - String poorNode = randomFrom(cluster.getNodeNames()); + String poorNode = randomValueOtherThanMany(n -> originalMasterCount == 1 && n.equals(cluster.getMasterName()), + () -> randomFrom(cluster.getNodeNames())); Path dataPath = getNodePaths(cluster, poorNode)[0]; final Path testMarker = dataPath.resolve("testMarker"); Files.createDirectories(testMarker);