@@ -89,8 +89,9 @@ all_tests() ->
8989 small_chunk_overview ,
9090 overview ,
9191 init_partial_writes ,
92+ init_with_unexpected_file ,
9293 overview_with_missing_segment ,
93- overview_with_missing_segment_at_start
94+ overview_with_missing_index_at_start
9495 ].
9596
9697groups () ->
@@ -1791,6 +1792,23 @@ run_scenario(Config, NumChunks, MsgSize, Scenario) ->
17911792
17921793 ok .
17931794
1795+ init_with_unexpected_file (Config ) ->
1796+ Data = crypto :strong_rand_bytes (1500 ),
1797+ EpochChunks =
1798+ [begin {1 , [Data || _ <- lists :seq (1 , 50 )]} end
1799+ || _ <- lists :seq (1 , 20 )],
1800+ Dir = ? config (dir , Config ),
1801+ Log = seed_log (Dir , EpochChunks , Config ),
1802+ osiris_log :close (Log ),
1803+ Segments = filelib :wildcard (filename :join (Dir , " *.segment" )),
1804+ Indexes = filelib :wildcard (filename :join (Dir , " *.index" )),
1805+ ? assertEqual (2 , length (Segments )),
1806+ ? assertEqual (2 , length (Indexes )),
1807+ ok = file :write_file (filename :join (Dir , " .nfs000000000000000000" ), <<" bananas" >>),
1808+ _ = osiris_log :init (? config (osiris_conf , Config )),
1809+ ? assertEqual ({{0 ,999 },[{1 ,950 }]}, osiris_log :overview (Dir )),
1810+ ok .
1811+
17941812overview_with_missing_segment (Config ) ->
17951813 Data = crypto :strong_rand_bytes (1500 ),
17961814 EpochChunks =
@@ -1821,7 +1839,7 @@ overview_with_missing_segment(Config) ->
18211839 filename :join (? config (dir , Config ), " *.index" )))),
18221840 ok .
18231841
1824- overview_with_missing_segment_at_start (Config ) ->
1842+ overview_with_missing_index_at_start (Config ) ->
18251843 Data = crypto :strong_rand_bytes (1500 ),
18261844 EpochChunks =
18271845 [begin {1 , [Data || _ <- lists :seq (1 , 50 )]} end
0 commit comments