Test: ZenUnicastDiscoveryTests.testNormalClusterForming should start unicast hosts first
The test starts a cluster with random nodes as unicast hosts but *doesn't* use min_master_nodes. If the unicast hosts are started last, nodes may elect themselves as master as they do not have mechanism yet to share information.
This commit is contained in:
parent
8cf922bf9e
commit
3142fec206
|
@ -52,10 +52,19 @@ public class ZenUnicastDiscoveryTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
public void testNormalClusterForming() throws ExecutionException, InterruptedException {
|
||||
int currentNumNodes = randomIntBetween(3, 5);
|
||||
int currentNumOfUnicastHosts = randomIntBetween(1, currentNumNodes);
|
||||
discoveryConfig = new ClusterDiscoveryConfiguration.UnicastZen(currentNumNodes, currentNumOfUnicastHosts);
|
||||
|
||||
internalCluster().startNodesAsync(currentNumNodes).get();
|
||||
// use explicit unicast hosts so we can start those first
|
||||
int[] unicastHostOrdinals = new int[randomIntBetween(1, currentNumNodes)];
|
||||
for (int i = 0; i < unicastHostOrdinals.length; i++) {
|
||||
unicastHostOrdinals[i] = i;
|
||||
}
|
||||
discoveryConfig = new ClusterDiscoveryConfiguration.UnicastZen(currentNumNodes, unicastHostOrdinals);
|
||||
|
||||
// start the unicast hosts
|
||||
internalCluster().startNodesAsync(unicastHostOrdinals.length).get();
|
||||
|
||||
// start the rest of the cluster
|
||||
internalCluster().startNodesAsync(currentNumNodes - unicastHostOrdinals.length).get();
|
||||
|
||||
if (client().admin().cluster().prepareHealth().setWaitForNodes("" + currentNumNodes).get().isTimedOut()) {
|
||||
logger.info("cluster forming timed out, cluster state:\n{}", client().admin().cluster().prepareState().get().getState().prettyPrint());
|
||||
|
|
Loading…
Reference in New Issue