From 32f7fbd9f0429dbf80d57778c6e55a50d0938f85 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 30 Nov 2018 10:58:46 +0100 Subject: [PATCH] [TEST] Set 'index.unassigned.node_left.delayed_timeout' to 0 in ccr tests Some tests kill nodes and otherwise it would take 60s by default for replicas to get allocated and that is longer than we wait for getting in a green state in tests. Relates to #35403 --- .../org/elasticsearch/xpack/CcrIntegTestCase.java | 15 +++++++++++++++ .../xpack/ccr/FollowerFailOverIT.java | 2 ++ 2 files changed, 17 insertions(+) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java index 9e5137d3cd1..6ec36fe4762 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java @@ -15,6 +15,7 @@ import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.action.admin.indices.get.GetIndexResponse; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; +import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; @@ -27,6 +28,7 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Priority; @@ -138,6 +140,18 @@ public abstract class CcrIntegTestCase extends ESTestCase { assertAcked(followerClient().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); } + /** + * Follower indices don't get all the settings from leader, for example 'index.unassigned.node_left.delayed_timeout' + * is not replicated and if tests kill nodes, we have to wait 60s by default... + */ + protected void disableDelayedAllocation(String index) { + UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(index); + Settings.Builder settingsBuilder = Settings.builder(); + settingsBuilder.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0); + updateSettingsRequest.settings(settingsBuilder); + assertAcked(followerClient().admin().indices().updateSettings(updateSettingsRequest).actionGet()); + } + @After public void afterTest() throws Exception { ensureEmptyWriteBuffers(); @@ -350,6 +364,7 @@ public abstract class CcrIntegTestCase extends ESTestCase { { builder.startObject("settings"); { + builder.field(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0); builder.field("index.number_of_shards", numberOfShards); builder.field("index.number_of_replicas", numberOfReplicas); for (final Map.Entry additionalSetting : additionalIndexSettings.entrySet()) { diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java index 6685776e980..d58a2d0a0f1 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java @@ -85,6 +85,7 @@ public class FollowerFailOverIT extends CcrIntegTestCase { follow.getFollowRequest().setMaxOutstandingWriteRequests(randomIntBetween(1, 10)); logger.info("--> follow params {}", Strings.toString(follow.getFollowRequest())); followerClient().execute(PutFollowAction.INSTANCE, follow).get(); + disableDelayedAllocation("follower-index"); ensureFollowerGreen("follower-index"); awaitGlobalCheckpointAtLeast(followerClient(), new ShardId(resolveFollowerIndex("follower-index"), 0), between(30, 80)); final ClusterState clusterState = getFollowerCluster().clusterService().state(); @@ -143,6 +144,7 @@ public class FollowerFailOverIT extends CcrIntegTestCase { followRequest.getFollowRequest().setMaxWriteRequestSize(new ByteSizeValue(randomIntBetween(1, 4096), ByteSizeUnit.KB)); followRequest.getFollowRequest().setMaxOutstandingWriteRequests(randomIntBetween(1, 10)); followerClient().execute(PutFollowAction.INSTANCE, followRequest).get(); + disableDelayedAllocation("index2"); logger.info("--> follow params {}", Strings.toString(followRequest.getFollowRequest())); int maxOpsPerRead = followRequest.getFollowRequest().getMaxReadRequestOperationCount();