Adjust load and timeout in testShrinkIndexPrimaryTerm (#42098)
This test can create and shuffle 2*(3*5*7) = 210 shards which is quite heavy for our CI. This commit reduces the load, so we don't timeout on CI. Closes #28153
This commit is contained in:
parent
7473742e6e
commit
a75e916078
|
@ -65,7 +65,6 @@ import org.elasticsearch.test.VersionUtils;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
@ -165,11 +164,8 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testShrinkIndexPrimaryTerm() throws Exception {
|
public void testShrinkIndexPrimaryTerm() throws Exception {
|
||||||
final List<Integer> factors = Arrays.asList(2, 3, 5, 7);
|
int numberOfShards = randomIntBetween(2, 20);
|
||||||
final List<Integer> numberOfShardsFactors = randomSubsetOf(scaledRandomIntBetween(1, factors.size() - 1), factors);
|
int numberOfTargetShards = randomValueOtherThanMany(n -> numberOfShards % n != 0, () -> randomIntBetween(1, numberOfShards - 1));
|
||||||
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);
|
|
||||||
internalCluster().ensureAtLeastNumDataNodes(2);
|
internalCluster().ensureAtLeastNumDataNodes(2);
|
||||||
prepareCreate("source").setSettings(Settings.builder().put(indexSettings()).put("number_of_shards", numberOfShards)).get();
|
prepareCreate("source").setSettings(Settings.builder().put(indexSettings()).put("number_of_shards", numberOfShards)).get();
|
||||||
|
|
||||||
|
@ -218,7 +214,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
||||||
final Settings.Builder prepareShrinkSettings =
|
final Settings.Builder prepareShrinkSettings =
|
||||||
Settings.builder().put("index.routing.allocation.require._name", mergeNode).put("index.blocks.write", true);
|
Settings.builder().put("index.routing.allocation.require._name", mergeNode).put("index.blocks.write", true);
|
||||||
client().admin().indices().prepareUpdateSettings("source").setSettings(prepareShrinkSettings).get();
|
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 IndexMetaData indexMetaData = indexMetaData(client(), "source");
|
||||||
final long beforeShrinkPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetaData::primaryTerm).max().getAsLong();
|
final long beforeShrinkPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetaData::primaryTerm).max().getAsLong();
|
||||||
|
@ -228,7 +224,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
||||||
Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", numberOfTargetShards).build();
|
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());
|
assertAcked(client().admin().indices().prepareResizeIndex("source", "target").setSettings(shrinkSettings).get());
|
||||||
|
|
||||||
ensureGreen();
|
ensureGreen(TimeValue.timeValueSeconds(120));
|
||||||
|
|
||||||
final IndexMetaData afterShrinkIndexMetaData = indexMetaData(client(), "target");
|
final IndexMetaData afterShrinkIndexMetaData = indexMetaData(client(), "target");
|
||||||
for (int shardId = 0; shardId < numberOfTargetShards; shardId++) {
|
for (int shardId = 0; shardId < numberOfTargetShards; shardId++) {
|
||||||
|
|
Loading…
Reference in New Issue