Skip to content

Commit 6263f44

Browse files
Fix assertion in DiskThresholdDeciderIT (#127615)
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 7a19a05 commit 6263f44

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
@@ -438,9 +438,6 @@ tests:
438438
- class: org.elasticsearch.xpack.inference.action.filter.ShardBulkInferenceActionFilterIT
439439
method: testRestart {p0=true p1=true}
440440
issue: https://github.com/elastic/elasticsearch/issues/127595
441-
- class: org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDeciderIT
442-
method: testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleRestores
443-
issue: https://github.com/elastic/elasticsearch/issues/127286
444441
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
445442
method: test {p0=ml/data_frame_analytics_cat_apis/Test cat data frame analytics all jobs with header}
446443
issue: https://github.com/elastic/elasticsearch/issues/127625

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)