Skip to content

Commit f713e7b

Browse files
Fix assertion in DiskThresholdDeciderIT
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
1 parent c5c3615 commit f713e7b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,6 @@ tests:
444444
- class: org.elasticsearch.xpack.inference.action.filter.ShardBulkInferenceActionFilterIT
445445
method: testRestart {p0=true p1=true}
446446
issue: https://github.com/elastic/elasticsearch/issues/127595
447-
- class: org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDeciderIT
448-
method: testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleRestores
449-
issue: https://github.com/elastic/elasticsearch/issues/127286
450447

451448
# Examples:
452449
#

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

Lines changed: 12 additions & 4 deletions
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)