|  | 
| 26 | 26 | import org.elasticsearch.action.support.PlainActionFuture; | 
| 27 | 27 | import org.elasticsearch.cluster.health.ClusterHealthStatus; | 
| 28 | 28 | import org.elasticsearch.cluster.metadata.IndexMetadata; | 
|  | 29 | +import org.elasticsearch.cluster.routing.UnassignedInfo; | 
| 29 | 30 | import org.elasticsearch.cluster.service.ClusterService; | 
| 30 | 31 | import org.elasticsearch.common.Priority; | 
| 31 | 32 | import org.elasticsearch.common.settings.Settings; | 
| @@ -308,21 +309,26 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS | 
| 308 | 309 |         } | 
| 309 | 310 |     } | 
| 310 | 311 | 
 | 
| 311 |  | -    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/62690") | 
| 312 | 312 |     public void testHealthOnMasterFailover() throws Exception { | 
| 313 | 313 |         final String node = internalCluster().startDataOnlyNode(); | 
| 314 |  | -        boolean withIndex = randomBoolean(); | 
|  | 314 | +        final boolean withIndex = randomBoolean(); | 
| 315 | 315 |         if (withIndex) { | 
| 316 | 316 |             // Create index with many shards to provoke the health request to wait (for green) while master is being shut down. | 
| 317 | 317 |             // Notice that this is set to 0 after the test completed starting a number of health requests and master restarts. | 
| 318 | 318 |             // This ensures that the cluster is yellow when the health request is made, making the health request wait on the observer, | 
| 319 | 319 |             // triggering a call to observer.onClusterServiceClose when master is shutdown. | 
| 320 |  | -            createIndex("test", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 10)).build()); | 
|  | 320 | +            createIndex("test", | 
|  | 321 | +                Settings.builder() | 
|  | 322 | +                .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 10)) | 
|  | 323 | +                    // avoid full recoveries of index, just wait for replica to reappear | 
|  | 324 | +                .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "5m") | 
|  | 325 | +                .build()); | 
| 321 | 326 |         } | 
| 322 | 327 |         final List<ActionFuture<ClusterHealthResponse>> responseFutures = new ArrayList<>(); | 
| 323 | 328 |         // Run a few health requests concurrent to master fail-overs against a data-node to make sure master failover is handled | 
| 324 | 329 |         // without exceptions | 
| 325 |  | -        for (int i = 0; i < 20; ++i) { | 
|  | 330 | +        final int iterations = withIndex ? 10 : 20; | 
|  | 331 | +        for (int i = 0; i < iterations; ++i) { | 
| 326 | 332 |             responseFutures.add(client(node).admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID) | 
| 327 | 333 |                 .setWaitForGreenStatus().setMasterNodeTimeout(TimeValue.timeValueMinutes(1)).execute()); | 
| 328 | 334 |             internalCluster().restartNode(internalCluster().getMasterName(), InternalTestCluster.EMPTY_CALLBACK); | 
|  | 
0 commit comments