Commit df6d9a5 1 parent 4fd6c27 commit df6d9a5 Copy full SHA for df6d9a5
File tree 1 file changed +29
-0
lines changed
server/src/test/java/org/opensearch/index/store
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -758,6 +758,35 @@ public void testUploadMetadataNonEmpty() throws IOException {
758
758
}
759
759
}
760
760
761
+ public void testUploadMetadataMissingSegment () throws IOException {
762
+ populateMetadata ();
763
+ remoteSegmentStoreDirectory .init ();
764
+
765
+ Directory storeDirectory = mock (Directory .class );
766
+ IndexOutput indexOutput = mock (IndexOutput .class );
767
+
768
+ String generation = RemoteStoreUtils .invertLong (segmentInfos .getGeneration ());
769
+ long primaryTermLong = indexShard .getLatestReplicationCheckpoint ().getPrimaryTerm ();
770
+ String primaryTerm = RemoteStoreUtils .invertLong (primaryTermLong );
771
+ when (storeDirectory .createOutput (startsWith ("metadata__" + primaryTerm + "__" + generation ), eq (IOContext .DEFAULT ))).thenReturn (
772
+ indexOutput
773
+ );
774
+
775
+ Collection <String > segmentFiles = List .of ("_123.si" );
776
+ assertThrows (
777
+ NoSuchFileException .class ,
778
+ () -> remoteSegmentStoreDirectory .uploadMetadata (
779
+ segmentFiles ,
780
+ segmentInfos ,
781
+ storeDirectory ,
782
+ 12L ,
783
+ indexShard .getLatestReplicationCheckpoint ()
784
+ )
785
+ );
786
+ verify (indexOutput ).close ();
787
+ verify (storeDirectory ).deleteFile (startsWith ("metadata__" + primaryTerm + "__" + generation ));
788
+ }
789
+
761
790
public void testUploadMetadataNoSegmentCommitInfos () throws IOException {
762
791
SegmentInfos segInfos = indexShard .store ().readLastCommittedSegmentsInfo ();
763
792
int numSegCommitInfos = segInfos .size ();
You can’t perform that action at this time.
0 commit comments