Skip to content

Commit

Permalink
Fix SegmentReplicationTargetTests
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 committed Sep 5, 2022
1 parent e60f8d4 commit 13c1301
Showing 1 changed file with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,18 @@ public class SegmentReplicationTargetTests extends IndexShardTestCase {
private ReplicationCheckpoint repCheckpoint;
private ByteBuffersDataOutput buffer;

private static final StoreFileMetadata SEGMENTS_FILE = new StoreFileMetadata(IndexFileNames.SEGMENTS, 1L, "0", Version.LATEST);
private static final StoreFileMetadata SEGMENTS_FILE_DIFF = new StoreFileMetadata(
IndexFileNames.SEGMENTS,
private static final String SEGMENT_NAME = "_0.si";
private static final StoreFileMetadata SEGMENT_FILE = new StoreFileMetadata(SEGMENT_NAME, 1L, "0", Version.LATEST);
private static final StoreFileMetadata SEGMENT_FILE_DIFF = new StoreFileMetadata(
SEGMENT_NAME,
5L,
"different",
Version.LATEST
);
private static final StoreFileMetadata PENDING_DELETE_FILE = new StoreFileMetadata("pendingDelete.del", 1L, "1", Version.LATEST);

private static final Store.MetadataSnapshot SI_SNAPSHOT = new Store.MetadataSnapshot(
Map.of(SEGMENTS_FILE.name(), SEGMENTS_FILE),
null,
0
);
private static final Map<String, StoreFileMetadata> SI_SNAPSHOT = Map.of(SEGMENT_FILE.name(), SEGMENT_FILE);

private static final Store.MetadataSnapshot SI_SNAPSHOT_DIFFERENT = new Store.MetadataSnapshot(
Map.of(SEGMENTS_FILE_DIFF.name(), SEGMENTS_FILE_DIFF),
null,
0
);
private static final Map<String, StoreFileMetadata> SI_SNAPSHOT_DIFFERENT = Map.of(SEGMENT_FILE_DIFF.name(), SEGMENT_FILE_DIFF);

private static final IndexSettings INDEX_SETTINGS = IndexSettingsModule.newIndexSettings(
"index",
Expand Down Expand Up @@ -134,7 +126,7 @@ public void getCheckpointMetadata(
ReplicationCheckpoint checkpoint,
ActionListener<CheckpointInfoResponse> listener
) {
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT.asMap(), buffer.toArrayCopy()));
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT, buffer.toArrayCopy()));
}

@Override
Expand All @@ -146,7 +138,7 @@ public void getSegmentFiles(
ActionListener<GetSegmentFilesResponse> listener
) {
assertEquals(1, filesToFetch.size());
assert (filesToFetch.contains(SEGMENTS_FILE));
assert (filesToFetch.contains(SEGMENT_FILE));
listener.onResponse(new GetSegmentFilesResponse(filesToFetch));
}
};
Expand Down Expand Up @@ -228,7 +220,7 @@ public void getCheckpointMetadata(
ReplicationCheckpoint checkpoint,
ActionListener<CheckpointInfoResponse> listener
) {
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT.asMap(), buffer.toArrayCopy()));
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT, buffer.toArrayCopy()));
}

@Override
Expand Down Expand Up @@ -271,7 +263,7 @@ public void getCheckpointMetadata(
ReplicationCheckpoint checkpoint,
ActionListener<CheckpointInfoResponse> listener
) {
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT.asMap(), buffer.toArrayCopy()));
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT, buffer.toArrayCopy()));
}

@Override
Expand Down Expand Up @@ -316,7 +308,7 @@ public void getCheckpointMetadata(
ReplicationCheckpoint checkpoint,
ActionListener<CheckpointInfoResponse> listener
) {
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT.asMap(), buffer.toArrayCopy()));
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT, buffer.toArrayCopy()));
}

@Override
Expand Down Expand Up @@ -360,7 +352,7 @@ public void getCheckpointMetadata(
ReplicationCheckpoint checkpoint,
ActionListener<CheckpointInfoResponse> listener
) {
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT.asMap(), buffer.toArrayCopy()));
listener.onResponse(new CheckpointInfoResponse(checkpoint, SI_SNAPSHOT, buffer.toArrayCopy()));
}

@Override
Expand All @@ -378,7 +370,7 @@ public void getSegmentFiles(
SegmentReplicationTargetService.SegmentReplicationListener.class
);
segrepTarget = spy(new SegmentReplicationTarget(repCheckpoint, indexShard, segrepSource, segRepListener));
when(segrepTarget.getMetadataMap()).thenReturn(SI_SNAPSHOT_DIFFERENT.asMap());
when(segrepTarget.getMetadataMap()).thenReturn(SI_SNAPSHOT_DIFFERENT);
segrepTarget.startReplication(new ActionListener<Void>() {
@Override
public void onResponse(Void replicationResponse) {
Expand Down

0 comments on commit 13c1301

Please sign in to comment.