Skip to content

Commit

Permalink
Addressed comments 3
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Kala <ankikala@amazon.com>
  • Loading branch information
ankitkala committed May 15, 2023
1 parent 4406a7f commit e487a38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void afterRefresh(boolean didRefresh) throws IOException {
if (didRefresh
&& shard.state() == IndexShardState.STARTED
&& shard.getReplicationTracker().isPrimaryMode()
&& !shard.indexSettings.isRemoteStoreEnabled()) {
&& !shard.indexSettings.isSegRepWithRemoteEnabled()) {
publisher.publish(shard, shard.getLatestReplicationCheckpoint());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.apache.lucene.store.FilterDirectory;
import org.apache.lucene.tests.store.BaseDirectoryWrapper;
import org.junit.After;
import org.mockito.Mockito;
import org.opensearch.action.ActionListener;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.routing.IndexShardRoutingTable;
Expand All @@ -37,16 +36,13 @@

import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.opensearch.index.shard.RemoteStoreRefreshListener.SEGMENT_INFO_SNAPSHOT_FILENAME_PREFIX;

public class RemoteStoreRefreshListenerTests extends IndexShardTestCase {
private IndexShard indexShard;
private RemoteStoreRefreshListener remoteStoreRefreshListener;

private SegmentReplicationCheckpointPublisher checkpointPublisher;

public void setup(boolean primary, int numberOfDocs) throws IOException {
indexShard = newStartedShard(
primary,
Expand All @@ -56,7 +52,7 @@ public void setup(boolean primary, int numberOfDocs) throws IOException {

indexDocs(1, numberOfDocs);
indexShard.refresh("test");
checkpointPublisher = mock(SegmentReplicationCheckpointPublisher.class);

remoteStoreRefreshListener = new RemoteStoreRefreshListener(indexShard, SegmentReplicationCheckpointPublisher.EMPTY);
}

Expand Down Expand Up @@ -166,8 +162,6 @@ public void testReplica() throws IOException {
(RemoteSegmentStoreDirectory) ((FilterDirectory) ((FilterDirectory) remoteStore.directory()).getDelegate()).getDelegate();

assertEquals(0, remoteSegmentStoreDirectory.getSegmentsUploadedToRemoteStore().size());
Mockito.verify(checkpointPublisher, times(1)).publish(Mockito.any(), Mockito.any());

}
}

Expand Down Expand Up @@ -216,7 +210,6 @@ public void onFailure(Exception e) {
remoteSegmentStoreDirectory.init();

verifyUploadedSegments(remoteSegmentStoreDirectory);
Mockito.verify(checkpointPublisher, times(2)).publish(Mockito.any(), Mockito.any());
}

public void testRefreshSuccessOnFirstAttempt() throws Exception {
Expand Down

0 comments on commit e487a38

Please sign in to comment.