From 628a7feda807d4a25f09a10c1ff4a19489724aca Mon Sep 17 00:00:00 2001 From: Anshu Agarwal Date: Sat, 27 May 2023 17:57:33 +0530 Subject: [PATCH] Fix test coverage Signed-off-by: Anshu Agarwal --- .../routing/FailAwareWeightedRoutingTests.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/src/test/java/org/opensearch/cluster/routing/FailAwareWeightedRoutingTests.java b/server/src/test/java/org/opensearch/cluster/routing/FailAwareWeightedRoutingTests.java index 1ecc1b4b2c5f2..4b343b7f6046f 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/FailAwareWeightedRoutingTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/FailAwareWeightedRoutingTests.java @@ -434,6 +434,12 @@ public void testUpdateFailOpenStatsForOneHealthyCopy() { boolean update = FailAwareWeightedRouting.getInstance() .updateFailOpenStatsForOneHealthyCopy(searchShardIterator, clusterState, shardRoutingA.currentNodeId()); assertTrue(update); + + ShardsIterator shardIterator = new PlainShardIterator(shardId, shardRoutings); + + update = FailAwareWeightedRouting.getInstance() + .updateFailOpenStatsForOneHealthyCopy(shardIterator, clusterState, shardRoutingA.currentNodeId()); + assertTrue(update); } public void testUpdateFailOpenStatsForWithTwoHealthyCopies() { @@ -483,6 +489,12 @@ public void testUpdateFailOpenStatsForWithTwoHealthyCopies() { boolean update = FailAwareWeightedRouting.getInstance() .updateFailOpenStatsForOneHealthyCopy(searchShardIterator, clusterState, shardRoutingA.currentNodeId()); assertFalse(update); + + ShardsIterator shardIterator = new PlainShardIterator(shardId, shardRoutings); + + update = FailAwareWeightedRouting.getInstance() + .updateFailOpenStatsForOneHealthyCopy(shardIterator, clusterState, shardRoutingA.currentNodeId()); + assertFalse(update); } public void testUpdateFailOpenStatsForOneHealthyCopyWithIgnoreWeightedRouting() { @@ -532,6 +544,12 @@ public void testUpdateFailOpenStatsForOneHealthyCopyWithIgnoreWeightedRouting() boolean update = FailAwareWeightedRouting.getInstance() .updateFailOpenStatsForOneHealthyCopy(searchShardIterator, clusterState, shardRoutingA.currentNodeId()); assertFalse(update); + + ShardsIterator shardIterator = new PlainShardIterator(shardId, shardRoutings); + + update = FailAwareWeightedRouting.getInstance() + .updateFailOpenStatsForOneHealthyCopy(shardIterator, clusterState, shardRoutingA.currentNodeId()); + assertFalse(update); } }