From c2fb148d8f10016ba3ff2f50616c099e5c3f6ea4 Mon Sep 17 00:00:00 2001 From: Harsh Garg Date: Wed, 4 Sep 2024 08:57:47 +0530 Subject: [PATCH] Asserting segment's name in test Signed-off-by: Harsh Garg --- .../admin/indices/segments/IndicesSegmentResponseTests.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/test/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponseTests.java b/server/src/test/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponseTests.java index 7d518966addfa..934bd4d4d7ce8 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponseTests.java @@ -43,6 +43,7 @@ import org.opensearch.test.OpenSearchTestCase; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -95,6 +96,7 @@ public void testGetIndices() { shardSegmentsList.add(new ShardSegments(shardRouting, segmentList)); } } + Collections.shuffle(shardSegmentsList); // Prepare the IndicesSegmentResponse object and get the indicesSegments map IndicesSegmentResponse response = new IndicesSegmentResponse( @@ -112,6 +114,10 @@ public void testGetIndices() { for (IndexShardSegments indexShardSegment : indexSegmentEntry.getValue().getShards().values()) { for (ShardSegments shardSegment : indexShardSegment.getShards()) { assertEquals(segmentsPerShard, shardSegment.getSegments().size()); + for (int i = 0; i < segmentsPerShard; i++) { + String segmentName = indexSegmentEntry.getKey() + shardSegment.getShardRouting().getId() + i; + assertEquals(segmentName, shardSegment.getSegments().get(i).getName()); + } } } }