Skip to content

Commit

Permalink
Fix success countdown latch in UT & remove redundant condition
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <[email protected]>
  • Loading branch information
ashking94 committed May 8, 2023
1 parent 1eb8c5d commit be43780
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public void testRefreshSuccessOnFirstAttempt() throws Exception {
// We spy on IndexShard.getReplicationTracker() to validate that we have tried running remote time as per the expectation.
CountDownLatch refreshCountLatch = new CountDownLatch(succeedOnAttempt);
// We spy on IndexShard.getEngine() to validate that we have successfully hit the terminal code for ascertaining successful upload.
CountDownLatch successLatch = new CountDownLatch(2);
// Value has been set as 3 as during a successful upload IndexShard.getEngine() is hit thrice and with mockito we are counting down
CountDownLatch successLatch = new CountDownLatch(3);
mockIndexShardWithRetryAndScheduleRefresh(succeedOnAttempt, refreshCountLatch, successLatch);
assertBusy(() -> assertEquals(0, refreshCountLatch.getCount()));
assertBusy(() -> assertEquals(0, successLatch.getCount()));
Expand Down Expand Up @@ -302,7 +303,6 @@ private void mockIndexShardWithRetryAndScheduleRefresh(
return indexShard.getSegmentInfosSnapshot();
}).when(shard).getSegmentInfosSnapshot();

when(shard.getEngine()).thenReturn(indexShard.getEngine());
doAnswer(invocation -> {
successLatch.countDown();
return indexShard.getEngine();
Expand Down

0 comments on commit be43780

Please sign in to comment.