Test: MinimumMasterNodesTests.testCanNotBringClusterDown didn't check for cluster health properly

Also reduced the number of nodes the test uses
This commit is contained in:
Boaz Leskes 2014-11-04 12:17:19 +01:00
parent 44e24d3916
commit 1c66317443
1 changed files with 9 additions and 4 deletions

View File

@ -315,7 +315,7 @@ public class MinimumMasterNodesTests extends ElasticsearchIntegrationTest {
@Test
public void testCanNotBringClusterDown() throws ExecutionException, InterruptedException {
int nodeCount = scaledRandomIntBetween(1, 10);
int nodeCount = scaledRandomIntBetween(1, 5);
ImmutableSettings.Builder settings = settingsBuilder()
.put("discovery.type", "zen")
.put("discovery.zen.ping_timeout", "200ms")
@ -327,9 +327,12 @@ public class MinimumMasterNodesTests extends ElasticsearchIntegrationTest {
settings.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES, randomIntBetween(1, nodeCount));
}
logger.info("--> starting [{}] nodes", nodeCount);
internalCluster().startNodesAsync(nodeCount, settings.build()).get();
client().admin().cluster().prepareHealth().setWaitForNodes("=" + nodeCount);
logger.info("--> waiting for nodes to join");
assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nodeCount)).get().isTimedOut());
int updateCount = randomIntBetween(1, nodeCount);
@ -337,7 +340,8 @@ public class MinimumMasterNodesTests extends ElasticsearchIntegrationTest {
assertAcked(client().admin().cluster().prepareUpdateSettings()
.setPersistentSettings(settingsBuilder().put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES, updateCount)));
client().admin().cluster().prepareHealth().setWaitForNodes("=" + nodeCount);
logger.info("--> verifying no node left and master is up");
assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nodeCount)).get().isTimedOut());
updateCount = nodeCount + randomIntBetween(1, 2000);
logger.info("--> trying to updating [{}] to [{}]", ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES, updateCount);
@ -346,6 +350,7 @@ public class MinimumMasterNodesTests extends ElasticsearchIntegrationTest {
.get().getPersistentSettings().getAsMap().keySet(),
empty());
client().admin().cluster().prepareHealth().setWaitForNodes("=" + nodeCount);
logger.info("--> verifying no node left and master is up");
assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nodeCount)).get().isTimedOut());
}
}