[TEST] Fix cluster forming in testDynamicUpdateMinimumMasterNodes

This test can run into a split-brain situation as minimum_master_nodes is not properly set. To prevent this, make sure that at least one of the two
master nodes that are initially started has minimum_master_nodes correctly set.
This commit is contained in:
Yannick Welsch 2017-04-26 21:06:20 +02:00
parent ebe98f9d62
commit b7bf651738
1 changed files with 10 additions and 11 deletions

View File

@ -263,18 +263,17 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
} }
public void testDynamicUpdateMinimumMasterNodes() throws Exception { public void testDynamicUpdateMinimumMasterNodes() throws Exception {
Settings settings = Settings.builder() Settings settingsWithMinMaster1 = Settings.builder()
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "400ms") .put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "400ms")
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), "1") .put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 1)
.build(); .build();
logger.info("--> start first node and wait for it to be a master"); Settings settingsWithMinMaster2 = Settings.builder()
internalCluster().startNode(settings); .put(settingsWithMinMaster1).put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 2)
ensureClusterSizeConsistency(); .build();
// wait until second node join the cluster logger.info("--> start two nodes and wait for them to form a cluster");
logger.info("--> start second node and wait for it to join"); internalCluster().startNodes(settingsWithMinMaster1, settingsWithMinMaster2);
internalCluster().startNode(settings);
ensureClusterSizeConsistency(); ensureClusterSizeConsistency();
logger.info("--> setting minimum master node to 2"); logger.info("--> setting minimum master node to 2");
@ -292,7 +291,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
assertNoMasterBlockOnAllNodes(); assertNoMasterBlockOnAllNodes();
logger.info("--> bringing another node up"); logger.info("--> bringing another node up");
internalCluster().startNode(Settings.builder().put(settings).put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 2).build()); internalCluster().startNode(settingsWithMinMaster2);
ensureClusterSizeConsistency(); ensureClusterSizeConsistency();
} }