Skip to content

Commit

Permalink
[TEST] Set 'index.unassigned.node_left.delayed_timeout' to 0 in ccr t…
Browse files Browse the repository at this point in the history
…ests

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 elastic#35403
  • Loading branch information
martijnvg committed Nov 30, 2018
1 parent d128b38 commit 957da22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand All @@ -27,6 +28,7 @@
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;
Expand Down Expand Up @@ -138,6 +140,18 @@ public final void startClusters() throws Exception {
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();
Expand Down Expand Up @@ -350,6 +364,7 @@ protected String getIndexSettings(final int numberOfShards, final int numberOfRe
{
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<String, String> additionalSetting : additionalIndexSettings.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void testFailOverOnFollower() throws Exception {
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();
Expand Down Expand Up @@ -143,6 +144,7 @@ public void testFollowIndexAndCloseNode() throws Exception {
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();
Expand Down

0 comments on commit 957da22

Please sign in to comment.