Skip to content

Adjust load and timeout in testShrinkIndexPrimaryTerm #42098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.elasticsearch.test.junit.annotations.TestLogging;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -165,11 +164,8 @@ public void testCreateShrinkIndexToN() {
}

public void testShrinkIndexPrimaryTerm() throws Exception {
final List<Integer> factors = Arrays.asList(2, 3, 5, 7);
final List<Integer> numberOfShardsFactors = randomSubsetOf(scaledRandomIntBetween(1, factors.size() - 1), factors);
final int numberOfShards = numberOfShardsFactors.stream().reduce(1, (x, y) -> x * y);
final int numberOfTargetShards = randomSubsetOf(randomInt(numberOfShardsFactors.size() - 1), numberOfShardsFactors)
.stream().reduce(1, (x, y) -> x * y);
int numberOfShards = randomIntBetween(2, 20);
int numberOfTargetShards = randomValueOtherThanMany(n -> numberOfShards % n != 0, () -> randomIntBetween(1, numberOfShards - 1));
internalCluster().ensureAtLeastNumDataNodes(2);
prepareCreate("source").setSettings(Settings.builder().put(indexSettings()).put("number_of_shards", numberOfShards)).get();

Expand Down Expand Up @@ -218,7 +214,7 @@ public void testShrinkIndexPrimaryTerm() throws Exception {
final Settings.Builder prepareShrinkSettings =
Settings.builder().put("index.routing.allocation.require._name", mergeNode).put("index.blocks.write", true);
client().admin().indices().prepareUpdateSettings("source").setSettings(prepareShrinkSettings).get();
ensureGreen();
ensureGreen(TimeValue.timeValueSeconds(120)); // needs more than the default to relocate many shards

final IndexMetaData indexMetaData = indexMetaData(client(), "source");
final long beforeShrinkPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetaData::primaryTerm).max().getAsLong();
Expand All @@ -228,7 +224,7 @@ public void testShrinkIndexPrimaryTerm() throws Exception {
Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", numberOfTargetShards).build();
assertAcked(client().admin().indices().prepareResizeIndex("source", "target").setSettings(shrinkSettings).get());

ensureGreen();
ensureGreen(TimeValue.timeValueSeconds(120));

final IndexMetaData afterShrinkIndexMetaData = indexMetaData(client(), "target");
for (int shardId = 0; shardId < numberOfTargetShards; shardId++) {
Expand Down