Skip to content

Commit 46e6b84

Browse files
committed
[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
1 parent a82291e commit 46e6b84

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
1616
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
1717
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
18+
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
1819
import org.elasticsearch.action.admin.indices.stats.ShardStats;
1920
import org.elasticsearch.action.search.SearchRequest;
2021
import org.elasticsearch.action.search.SearchResponse;
@@ -27,6 +28,7 @@
2728
import org.elasticsearch.cluster.metadata.IndexMetaData;
2829
import org.elasticsearch.cluster.metadata.MetaData;
2930
import org.elasticsearch.cluster.routing.ShardRouting;
31+
import org.elasticsearch.cluster.routing.UnassignedInfo;
3032
import org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings;
3133
import org.elasticsearch.cluster.service.ClusterService;
3234
import org.elasticsearch.common.Priority;
@@ -142,6 +144,18 @@ public final void startClusters() throws Exception {
142144
assertAcked(followerClient().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
143145
}
144146

147+
/**
148+
* Follower indices don't get all the settings from leader, for example 'index.unassigned.node_left.delayed_timeout'
149+
* is not replicated and if tests kill nodes, we have to wait 60s by default...
150+
*/
151+
protected void disableDelayedAllocation(String index) {
152+
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(index);
153+
Settings.Builder settingsBuilder = Settings.builder();
154+
settingsBuilder.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0);
155+
updateSettingsRequest.settings(settingsBuilder);
156+
assertAcked(followerClient().admin().indices().updateSettings(updateSettingsRequest).actionGet());
157+
}
158+
145159
@After
146160
public void afterTest() throws Exception {
147161
ensureEmptyWriteBuffers();
@@ -355,6 +369,7 @@ protected String getIndexSettings(final int numberOfShards, final int numberOfRe
355369
{
356370
builder.startObject("settings");
357371
{
372+
builder.field(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0);
358373
builder.field("index.number_of_shards", numberOfShards);
359374
builder.field("index.number_of_replicas", numberOfReplicas);
360375
for (final Map.Entry<String, String> additionalSetting : additionalIndexSettings.entrySet()) {

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/FollowerFailOverIT.java

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public void testFailOverOnFollower() throws Exception {
8585
follow.getFollowRequest().setMaxOutstandingWriteRequests(randomIntBetween(1, 10));
8686
logger.info("--> follow params {}", Strings.toString(follow.getFollowRequest()));
8787
followerClient().execute(PutFollowAction.INSTANCE, follow).get();
88+
disableDelayedAllocation("follower-index");
8889
ensureFollowerGreen("follower-index");
8990
awaitGlobalCheckpointAtLeast(followerClient(), new ShardId(resolveFollowerIndex("follower-index"), 0), between(30, 80));
9091
final ClusterState clusterState = getFollowerCluster().clusterService().state();
@@ -143,6 +144,7 @@ public void testFollowIndexAndCloseNode() throws Exception {
143144
followRequest.getFollowRequest().setMaxWriteRequestSize(new ByteSizeValue(randomIntBetween(1, 4096), ByteSizeUnit.KB));
144145
followRequest.getFollowRequest().setMaxOutstandingWriteRequests(randomIntBetween(1, 10));
145146
followerClient().execute(PutFollowAction.INSTANCE, followRequest).get();
147+
disableDelayedAllocation("index2");
146148
logger.info("--> follow params {}", Strings.toString(followRequest.getFollowRequest()));
147149

148150
int maxOpsPerRead = followRequest.getFollowRequest().getMaxReadRequestOperationCount();

0 commit comments

Comments
 (0)