Expand tests for coverage

Prove tests handle SQN over batch, and also can handle mismatched tags in the store.
This commit is contained in:
Martin Sumner 2017-11-20 10:21:30 +00:00
parent 0e071d078e
commit d5babe0c29
2 changed files with 44 additions and 0 deletions

View file

@ -284,6 +284,8 @@ handoff(_Config) ->
{sync_strategy, riak_sync}], {sync_strategy, riak_sync}],
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1), {ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
% Add some noe Riak objects in - which should be ignored in folds.
Hashes = testutil:stdload(Bookie1, 1000),
% Generate 200K objects to be used within the test, and load them into % Generate 200K objects to be used within the test, and load them into
% the first store (outputting the generated objects as a list of lists) % the first store (outputting the generated objects as a list of lists)
% to be used elsewhere % to be used elsewhere
@ -322,6 +324,11 @@ handoff(_Config) ->
{sync_strategy, none}], {sync_strategy, none}],
{ok, Bookie4} = leveled_bookie:book_start(StartOpts4), {ok, Bookie4} = leveled_bookie:book_start(StartOpts4),
FoldStObjectsFun =
fun(B, K, V, Acc) ->
[{B, K, erlang:phash2(V)}|Acc]
end,
FoldObjectsFun = FoldObjectsFun =
fun(Book) -> fun(Book) ->
fun(B, K, Obj, ok) -> fun(B, K, Obj, ok) ->
@ -384,6 +391,26 @@ handoff(_Config) ->
check_tictacfold(Bookie2, Bookie3, TicTacFolder, none, TreeSize), check_tictacfold(Bookie2, Bookie3, TicTacFolder, none, TreeSize),
check_tictacfold(Bookie3, Bookie4, TicTacFolder, none, TreeSize), check_tictacfold(Bookie3, Bookie4, TicTacFolder, none, TreeSize),
StdFolder =
{foldobjects_allkeys,
?STD_TAG,
FoldStObjectsFun,
true,
sqn_order},
{async, StdFold1} = leveled_bookie:book_returnfolder(Bookie1, StdFolder),
{async, StdFold2} = leveled_bookie:book_returnfolder(Bookie2, StdFolder),
{async, StdFold3} = leveled_bookie:book_returnfolder(Bookie3, StdFolder),
{async, StdFold4} = leveled_bookie:book_returnfolder(Bookie4, StdFolder),
StdFoldOut1 = lists:sort(StdFold1()),
StdFoldOut2 = lists:sort(StdFold2()),
StdFoldOut3 = lists:sort(StdFold3()),
StdFoldOut4 = lists:sort(StdFold4()),
true = StdFoldOut1 == lists:sort(Hashes),
true = StdFoldOut2 == [],
true = StdFoldOut3 == [],
true = StdFoldOut4 == [],
% Shutdown % Shutdown
ok = leveled_bookie:book_close(Bookie1), ok = leveled_bookie:book_close(Bookie1),
ok = leveled_bookie:book_close(Bookie2), ok = leveled_bookie:book_close(Bookie2),

View file

@ -7,6 +7,7 @@
book_riakget/3, book_riakget/3,
book_riakhead/3, book_riakhead/3,
riakload/2, riakload/2,
stdload/2,
reset_filestructure/0, reset_filestructure/0,
reset_filestructure/1, reset_filestructure/1,
check_bucket_stats/2, check_bucket_stats/2,
@ -173,6 +174,22 @@ riakload(Bookie, ObjectList) ->
end, end,
ObjectList). ObjectList).
stdload(Bookie, Count) ->
stdload(Bookie, Count, []).
stdload(_Bookie, 0, Acc) ->
Acc;
stdload(Bookie, Count, Acc) ->
B = "Bucket",
K = leveled_codec:generate_uuid(),
V = get_compressiblevalue(),
R = leveled_bookie:book_put(Bookie, B, K, V, [], ?STD_TAG),
case R of
ok -> ok;
pause -> timer:sleep(?SLOWOFFER_DELAY)
end,
stdload(Bookie, Count - 1, [{B, K, erlang:phash2(V)}|Acc]).
reset_filestructure() -> reset_filestructure() ->
reset_filestructure(0, ?ROOT_PATH). reset_filestructure(0, ?ROOT_PATH).