Skip to content

Commit c94e5d2

Browse files
committed
TEST: Lower num of shards in testShrinkIndexPrimaryTerm
In some cases testShrinkIndexPrimaryTerm creates then 'mutates' 210 shards. If each shard opens more than 10 files (translog, lucene index), we exceeded the maximum allowed file handles. In our test, the number of file handles is limited to 2048 by HandleLimitFS. This commit reduces the number of shards in testShrinkIndexPrimaryTerm to avoid such errors.
1 parent 85d3f98 commit c94e5d2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/src/test/java/org/elasticsearch/action/admin/indices/create/ShrinkIndexIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.elasticsearch.common.Priority;
4848
import org.elasticsearch.common.collect.ImmutableOpenMap;
4949
import org.elasticsearch.common.settings.Settings;
50+
import org.elasticsearch.common.unit.TimeValue;
5051
import org.elasticsearch.common.xcontent.XContentType;
5152
import org.elasticsearch.index.Index;
5253
import org.elasticsearch.index.IndexService;
@@ -153,7 +154,7 @@ public void testCreateShrinkIndexToN() {
153154

154155
public void testShrinkIndexPrimaryTerm() throws Exception {
155156
final List<Integer> factors = Arrays.asList(2, 3, 5, 7);
156-
final List<Integer> numberOfShardsFactors = randomSubsetOf(scaledRandomIntBetween(1, factors.size()), factors);
157+
final List<Integer> numberOfShardsFactors = randomSubsetOf(scaledRandomIntBetween(1, factors.size() - 1), factors);
157158
final int numberOfShards = numberOfShardsFactors.stream().reduce(1, (x, y) -> x * y);
158159
final int numberOfTargetShards = randomSubsetOf(numberOfShardsFactors).stream().reduce(1, (x, y) -> x * y);
159160
internalCluster().ensureAtLeastNumDataNodes(2);
@@ -164,8 +165,8 @@ public void testShrinkIndexPrimaryTerm() throws Exception {
164165
assertThat(dataNodes.size(), greaterThanOrEqualTo(2));
165166
final DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode.class);
166167
final String mergeNode = discoveryNodes[0].getName();
167-
ensureGreen();
168-
168+
// This may need more time than the default value if a large number of shards were created.
169+
ensureGreen(TimeValue.timeValueSeconds(120));
169170
// fail random primary shards to force primary terms to increase
170171
final Index source = resolveIndex("source");
171172
final int iterations = scaledRandomIntBetween(0, 16);

0 commit comments

Comments
 (0)