From ae812e04406ad44a85357fc9652fd6b6780e3e14 Mon Sep 17 00:00:00 2001 From: Jeremy Dahlgren Date: Mon, 12 May 2025 14:21:53 -0400 Subject: [PATCH] Fix assertion in DiskThresholdDeciderIT (part 2) (#127846) Fixes the final assertion in testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleRestores() that wasn't addressed with the fix in PR 127615 for issue 127286. Closes #127787 Co-authored-by: David Turner (cherry picked from commit 98296d7e520d186ea2094a4741b188a020bc7576) # Conflicts: # muted-tests.yml --- .../routing/allocation/decider/DiskThresholdDeciderIT.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java index 6f2be0a188b9e..18a49844af7d6 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java @@ -280,7 +280,12 @@ public void testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleResto tinyNodeShardIds.size() + tinyNodeShardIdsCopy.size(), is(1) ); - assertThat(tinyNodeShardIds.iterator().next(), in(shardSizes.getShardIdsWithSizeSmallerOrEqual(usableSpace))); + final var useableSpaceShardSizes = shardSizes.getShardIdsWithSizeSmallerOrEqual(usableSpace); + final var tinyNodeShardId = tinyNodeShardIds.isEmpty() == false + ? tinyNodeShardIds.iterator().next() + // shardSizes only contains the sizes from the original index, not the copy, so we map the copied shard back to the original idx + : new ShardId(useableSpaceShardSizes.iterator().next().getIndex(), tinyNodeShardIdsCopy.iterator().next().id()); + assertThat(tinyNodeShardId, in(useableSpaceShardSizes)); } private Set getShardIds(final String nodeId, final String indexName) {