Skip to content

Commit 92b673f

Browse files
Fix assertion in DiskThresholdDeciderIT (elastic#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 elastic#127286 (cherry picked from commit 6263f44)
1 parent 4a46d6a commit 92b673f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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)