Skip to content

Commit ab9b37a

Browse files
Fix test timeout for health on master failover (#63455)
testHealthOnMasterFailover could timeout on some of the health requests in the case where an index is added, since the recovery leads to extended test run time. Closes #62690
1 parent 7104e21 commit ab9b37a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterHealthIT.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.action.support.PlainActionFuture;
2727
import org.elasticsearch.cluster.health.ClusterHealthStatus;
2828
import org.elasticsearch.cluster.metadata.IndexMetadata;
29+
import org.elasticsearch.cluster.routing.UnassignedInfo;
2930
import org.elasticsearch.cluster.service.ClusterService;
3031
import org.elasticsearch.common.Priority;
3132
import org.elasticsearch.common.settings.Settings;
@@ -308,21 +309,26 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
308309
}
309310
}
310311

311-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/62690")
312312
public void testHealthOnMasterFailover() throws Exception {
313313
final String node = internalCluster().startDataOnlyNode();
314-
boolean withIndex = randomBoolean();
314+
final boolean withIndex = randomBoolean();
315315
if (withIndex) {
316316
// Create index with many shards to provoke the health request to wait (for green) while master is being shut down.
317317
// Notice that this is set to 0 after the test completed starting a number of health requests and master restarts.
318318
// This ensures that the cluster is yellow when the health request is made, making the health request wait on the observer,
319319
// 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());
321326
}
322327
final List<ActionFuture<ClusterHealthResponse>> responseFutures = new ArrayList<>();
323328
// Run a few health requests concurrent to master fail-overs against a data-node to make sure master failover is handled
324329
// 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) {
326332
responseFutures.add(client(node).admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID)
327333
.setWaitForGreenStatus().setMasterNodeTimeout(TimeValue.timeValueMinutes(1)).execute());
328334
internalCluster().restartNode(internalCluster().getMasterName(), InternalTestCluster.EMPTY_CALLBACK);

0 commit comments

Comments
 (0)