Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remote Store] Add missing unit test in main #9101

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,35 @@ public void testUploadMetadataNonEmpty() throws IOException {
}
}

public void testUploadMetadataMissingSegment() throws IOException {
populateMetadata();
remoteSegmentStoreDirectory.init();

Directory storeDirectory = mock(Directory.class);
IndexOutput indexOutput = mock(IndexOutput.class);

String generation = RemoteStoreUtils.invertLong(segmentInfos.getGeneration());
long primaryTermLong = indexShard.getLatestReplicationCheckpoint().getPrimaryTerm();
String primaryTerm = RemoteStoreUtils.invertLong(primaryTermLong);
when(storeDirectory.createOutput(startsWith("metadata__" + primaryTerm + "__" + generation), eq(IOContext.DEFAULT))).thenReturn(
indexOutput
);

Collection<String> segmentFiles = List.of("_123.si");
assertThrows(
NoSuchFileException.class,
() -> remoteSegmentStoreDirectory.uploadMetadata(
segmentFiles,
segmentInfos,
storeDirectory,
12L,
indexShard.getLatestReplicationCheckpoint()
)
);
verify(indexOutput).close();
verify(storeDirectory).deleteFile(startsWith("metadata__" + primaryTerm + "__" + generation));
}

public void testUploadMetadataNoSegmentCommitInfos() throws IOException {
SegmentInfos segInfos = indexShard.store().readLastCommittedSegmentsInfo();
int numSegCommitInfos = segInfos.size();
Expand Down