@@ -318,20 +318,39 @@ public void testCopyFromException() throws IOException {
318
318
}
319
319
320
320
public void testContainsFile () throws IOException {
321
- populateMetadata ();
321
+ List <String > metadataFiles = List .of ("metadata__1__5__abc" );
322
+ when (remoteMetadataDirectory .listFilesByPrefix (RemoteSegmentStoreDirectory .MetadataFilenameUtils .METADATA_PREFIX )).thenReturn (
323
+ metadataFiles
324
+ );
325
+
326
+ Map <String , String > metadata = new HashMap <>();
327
+ metadata .put ("_0.cfe" , "_0.cfe::_0.cfe__" + UUIDs .base64UUID () + "::1234" );
328
+ metadata .put ("_0.cfs" , "_0.cfs::_0.cfs__" + UUIDs .base64UUID () + "::2345" );
329
+
330
+ Map <String , Map <String , String >> metadataFilenameContentMapping = Map .of ("metadata__1__5__abc" , metadata );
331
+
332
+ IndexInput indexInput1 = mock (IndexInput .class );
333
+ when (indexInput1 .readMapOfStrings ()).thenReturn (metadataFilenameContentMapping .get ("metadata__1__5__abc" ));
334
+ when (remoteMetadataDirectory .openInput ("metadata__1__5__abc" , IOContext .DEFAULT )).thenReturn (indexInput1 );
335
+
322
336
remoteSegmentStoreDirectory .init ();
323
337
324
- // This is not the correct way to add files but the other way is to open up access to fields in UploadedSegmentMetadata
325
338
Map <String , RemoteSegmentStoreDirectory .UploadedSegmentMetadata > uploadedSegmentMetadataMap = remoteSegmentStoreDirectory
326
339
.getSegmentsUploadedToRemoteStore ();
327
- uploadedSegmentMetadataMap .put (
328
- "_100.si" ,
329
- new RemoteSegmentStoreDirectory .UploadedSegmentMetadata ("_100.si" , "_100.si__uuid1" , "1234" )
340
+
341
+ assertThrows (
342
+ UnsupportedOperationException .class ,
343
+ () -> uploadedSegmentMetadataMap .put (
344
+ "_100.si" ,
345
+ new RemoteSegmentStoreDirectory .UploadedSegmentMetadata ("_100.si" , "_100.si__uuid1" , "1234" )
346
+ )
330
347
);
331
348
332
- assertTrue (remoteSegmentStoreDirectory .containsFile ("_100.si" , "1234" ));
333
- assertFalse (remoteSegmentStoreDirectory .containsFile ("_100.si" , "2345" ));
334
- assertFalse (remoteSegmentStoreDirectory .containsFile ("_200.si" , "1234" ));
349
+ assertTrue (remoteSegmentStoreDirectory .containsFile ("_0.cfe" , "1234" ));
350
+ assertTrue (remoteSegmentStoreDirectory .containsFile ("_0.cfs" , "2345" ));
351
+ assertFalse (remoteSegmentStoreDirectory .containsFile ("_0.cfe" , "1234000" ));
352
+ assertFalse (remoteSegmentStoreDirectory .containsFile ("_0.cfs" , "2345000" ));
353
+ assertFalse (remoteSegmentStoreDirectory .containsFile ("_0.si" , "23" ));
335
354
}
336
355
337
356
public void testUploadMetadataEmpty () throws IOException {
0 commit comments