Skip to content

Commit

Permalink
Fix flaky RemoteStoreRefreshListenerTests test opensearch-project#11256
Browse files Browse the repository at this point in the history
… (opensearch-project#11803)

Signed-off-by: Ashish Singh <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
ashking94 authored and shiv0408 committed Apr 25, 2024
1 parent cd311c2 commit 19366ff
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public void testTrackerData() throws Exception {
RemoteStoreRefreshListener listener = tuple.v1();
RemoteStoreStatsTrackerFactory trackerFactory = tuple.v2();
RemoteSegmentTransferTracker tracker = trackerFactory.getRemoteSegmentTransferTracker(indexShard.shardId());
assertNoLag(tracker);
assertBusy(() -> assertNoLag(tracker));
indexDocs(100, randomIntBetween(100, 200));
indexShard.refresh("test");
listener.afterRefresh(true);
Expand Down Expand Up @@ -473,6 +473,14 @@ private Tuple<RemoteStoreRefreshListener, RemoteStoreStatsTrackerFactory> mockIn
new InternalEngineFactory()
);

RemoteSegmentTransferTracker tracker = indexShard.getRemoteStoreStatsTrackerFactory()
.getRemoteSegmentTransferTracker(indexShard.shardId());
try {
assertBusy(() -> assertTrue(tracker.getTotalUploadsSucceeded() > 0));
} catch (Exception e) {
assert false;
}

indexDocs(1, randomIntBetween(1, 100));

// Mock indexShard.store().directory()
Expand Down Expand Up @@ -554,7 +562,6 @@ private Tuple<RemoteStoreRefreshListener, RemoteStoreStatsTrackerFactory> mockIn
RecoverySettings recoverySettings = mock(RecoverySettings.class);
when(recoverySettings.getMinRemoteSegmentMetadataFiles()).thenReturn(10);
when(shard.getRecoverySettings()).thenReturn(recoverySettings);
RemoteSegmentTransferTracker tracker = remoteStoreStatsTrackerFactory.getRemoteSegmentTransferTracker(indexShard.shardId());
RemoteStoreRefreshListener refreshListener = new RemoteStoreRefreshListener(shard, emptyCheckpointPublisher, tracker);
refreshListener.afterRefresh(true);
return Tuple.tuple(refreshListener, remoteStoreStatsTrackerFactory);
Expand Down

0 comments on commit 19366ff

Please sign in to comment.