Skip to content

Commit 6ee5bcf

Browse files
Fix assertion in DiskThresholdDeciderIT (#127615) (#127643)
The test launches two concurrent restores and wants to verify that the node with limited disk space is only assigned a single shard from one of the indices. The test was asserting that it had one shard from the first index, but it is possible for it to get one shard from the index copy instead. This change allows the shard to be from either index, but still asserts there is only one assignment to the tiny node. Closes #127286 (cherry picked from commit 6263f44)
1 parent 8a7feac commit 6ee5bcf

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

muted-tests.yml

-3
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,6 @@ tests:
455455
- class: org.elasticsearch.search.SearchServiceSingleNodeTests
456456
method: testLookUpSearchContext
457457
issue: https://github.com/elastic/elasticsearch/issues/126813
458-
- class: org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDeciderIT
459-
method: testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleRestores
460-
issue: https://github.com/elastic/elasticsearch/issues/127286
461458
- class: org.elasticsearch.test.index.IndexVersionUtilsTests
462459
method: testIndexCompatibleVersionMatches
463460
issue: https://github.com/elastic/elasticsearch/issues/120760

server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import static org.hamcrest.Matchers.contains;
5757
import static org.hamcrest.Matchers.empty;
5858
import static org.hamcrest.Matchers.equalTo;
59-
import static org.hamcrest.Matchers.hasSize;
6059
import static org.hamcrest.Matchers.in;
6160
import static org.hamcrest.Matchers.is;
6261
import static org.hamcrest.Matchers.lessThanOrEqualTo;
@@ -242,7 +241,7 @@ public void testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleResto
242241
clusterAdmin().prepareRestoreSnapshot(TEST_REQUEST_TIMEOUT, "repo", "snap")
243242
.setWaitForCompletion(true)
244243
.setRenamePattern(indexName)
245-
.setRenameReplacement(indexName + "-copy")
244+
.setRenameReplacement(copyIndexName)
246245
.execute(ActionTestUtils.assertNoFailureListener(restoreSnapshotResponse -> {
247246
final RestoreInfo restoreInfo = restoreSnapshotResponse.getRestoreInfo();
248247
assertThat(restoreInfo.successfulShards(), is(snapshotInfo.totalShards()));
@@ -268,10 +267,19 @@ public void testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleResto
268267

269268
// wait for all the shards to finish moving
270269
safeAwait(allShardsActiveListener);
271-
ensureGreen(indexName, indexName + "-copy");
270+
ensureGreen(indexName, copyIndexName);
272271

273272
final var tinyNodeShardIds = getShardIds(dataNodeId, indexName);
274-
assertThat(tinyNodeShardIds, hasSize(1));
273+
final var tinyNodeShardIdsCopy = getShardIds(dataNodeId, copyIndexName);
274+
assertThat(
275+
"expected just one shard from one index on the tiny node, instead got "
276+
+ tinyNodeShardIds
277+
+ " from the original index and "
278+
+ tinyNodeShardIdsCopy
279+
+ " from the copy",
280+
tinyNodeShardIds.size() + tinyNodeShardIdsCopy.size(),
281+
is(1)
282+
);
275283
assertThat(tinyNodeShardIds.iterator().next(), in(shardSizes.getShardIdsWithSizeSmallerOrEqual(usableSpace)));
276284
}
277285

0 commit comments

Comments
 (0)