Add coverage for CDB delete_pending with snapshot

CDB file in delete_pending state, and times out but the Inker has a snapshot open - and so the file is not deleted.
This commit is contained in:
Martin Sumner 2017-11-09 12:02:03 +00:00
parent 53afd70174
commit 29ffb74a5b

View file

@ -172,32 +172,53 @@ journal_compaction_tester(Restart, WRP) ->
Bookie0 Bookie0
end, end,
ok = leveled_bookie:book_compactjournal(Bookie1, 30000),
testutil:wait_for_compaction(Bookie1), WasteFP = RootPath ++ "/journal/journal_files/waste",
% Start snapshot - should not stop deletions % Start snapshot - should stop deletions
{ok, PclClone, InkClone} = {ok, PclClone, InkClone} =
leveled_bookie:book_snapshot(Bookie1, store, undefined, false), leveled_bookie:book_snapshot(Bookie1, store, undefined, false),
ok = leveled_bookie:book_compactjournal(Bookie1, 30000),
testutil:wait_for_compaction(Bookie1),
% Wait to cause delete_pending to be blocked by snapshot
% timeout on switch to delete_pending is 10s
timer:sleep(10100),
case WRP of
undefined ->
ok;
_ ->
% Check nothing got deleted
{ok, CJs} = file:list_dir(WasteFP),
true = length(CJs) == 0
end,
ok = leveled_penciller:pcl_close(PclClone),
ok = leveled_inker:ink_close(InkClone),
% Snapshot released so deletes shoudl occur at next timeout
case WRP of
undefined ->
timer:sleep(10100); % wait for delete_pending timeout
% Wait 2 seconds for files to be deleted % Wait 2 seconds for files to be deleted
WasteFP = RootPath ++ "/journal/journal_files/waste", _ ->
lists:foldl(fun(X, Found) -> FindDeletedFilesFun =
case Found of fun(X, Found) ->
true -> case Found of
Found; true ->
false -> Found;
{ok, Files} = file:list_dir(WasteFP), false ->
if {ok, Files} = file:list_dir(WasteFP),
length(Files) > 0 -> if
io:format("Deleted files found~n"), length(Files) > 0 ->
true; io:format("Deleted files found~n"),
length(Files) == 0 -> true;
timer:sleep(X), length(Files) == 0 ->
false timer:sleep(X),
end false
end end
end, end
false, end,
[2000,2000,2000,2000,2000,2000]), lists:foldl(FindDeletedFilesFun,
false,
[2000,2000,2000,2000,2000,2000])
end,
{ok, ClearedJournals} = file:list_dir(WasteFP), {ok, ClearedJournals} = file:list_dir(WasteFP),
io:format("~w ClearedJournals found~n", [length(ClearedJournals)]), io:format("~w ClearedJournals found~n", [length(ClearedJournals)]),
case is_integer(WRP) of case is_integer(WRP) of
@ -210,10 +231,8 @@ journal_compaction_tester(Restart, WRP) ->
ChkList3 = lists:sublist(lists:sort(ObjList2), 500), ChkList3 = lists:sublist(lists:sort(ObjList2), 500),
testutil:check_forlist(Bookie1, ChkList3), testutil:check_forlist(Bookie1, ChkList3),
ok = leveled_penciller:pcl_close(PclClone),
ok = leveled_inker:ink_close(InkClone),
ok = leveled_bookie:book_close(Bookie1), ok = leveled_bookie:book_close(Bookie1),
% Restart % Restart
{ok, Bookie2} = leveled_bookie:book_start(StartOpts1), {ok, Bookie2} = leveled_bookie:book_start(StartOpts1),
testutil:check_forobject(Bookie2, TestObject), testutil:check_forobject(Bookie2, TestObject),