Test coverage

... and column width formatting
This commit is contained in:
Martin Sumner 2017-11-01 15:11:14 +00:00
parent 033cf1954d
commit ee7f9ee4e0
2 changed files with 36 additions and 28 deletions

View file

@ -776,20 +776,14 @@ handle_cast(work_for_clerk, State) ->
case WC of case WC of
0 -> 0 ->
{noreply, State#state{work_backlog=false}}; {noreply, State#state{work_backlog=false}};
N when N > ?WORKQUEUE_BACKLOG_TOLERANCE ->
leveled_log:log("P0024", [N, true]),
[TL|_Tail] = WL,
ok = leveled_pclerk:clerk_push(State#state.clerk,
{TL, State#state.manifest}),
{noreply,
State#state{work_backlog=true, work_ongoing=true}};
N -> N ->
leveled_log:log("P0024", [N, false]), Backlog = N > ?WORKQUEUE_BACKLOG_TOLERANCE,
leveled_log:log("P0024", [N, Backlog]),
[TL|_Tail] = WL, [TL|_Tail] = WL,
ok = leveled_pclerk:clerk_push(State#state.clerk, ok = leveled_pclerk:clerk_push(State#state.clerk,
{TL, State#state.manifest}), {TL, State#state.manifest}),
{noreply, {noreply,
State#state{work_backlog=false, work_ongoing=true}} State#state{work_backlog=Backlog, work_ongoing=true}}
end; end;
_ -> _ ->
{noreply, State} {noreply, State}
@ -986,7 +980,8 @@ update_levelzero(L0Size, {PushedTree, PushedIdx, MinSQN, MaxSQN},
ledger_sqn=UpdMaxSQN}, ledger_sqn=UpdMaxSQN},
CacheTooBig = NewL0Size > State#state.levelzero_maxcachesize, CacheTooBig = NewL0Size > State#state.levelzero_maxcachesize,
CacheMuchTooBig = NewL0Size > ?SUPER_MAX_TABLE_SIZE, CacheMuchTooBig = NewL0Size > ?SUPER_MAX_TABLE_SIZE,
L0Free = not leveled_pmanifest:levelzero_present(State#state.manifest), L0Free =
not leveled_pmanifest:levelzero_present(State#state.manifest),
RandomFactor = RandomFactor =
case State#state.levelzero_cointoss of case State#state.levelzero_cointoss of
true -> true ->
@ -1364,8 +1359,11 @@ find_nextkey(QueryArray, LCnt,
if if
SQN =< BestSQN -> SQN =< BestSQN ->
% This is a dominated key, so we need to skip over it % This is a dominated key, so we need to skip over it
NewEntry = {LCnt, RestOfKeys}, NewQArray = lists:keyreplace(LCnt,
find_nextkey(lists:keyreplace(LCnt, 1, QueryArray, NewEntry), 1,
QueryArray,
{LCnt, RestOfKeys}),
find_nextkey(NewQArray,
LCnt + 1, LCnt + 1,
{BKL, {BestKey, BestVal}}, {BKL, {BestKey, BestVal}},
StartKey, EndKey, StartKey, EndKey,
@ -1535,7 +1533,8 @@ simple_server_test() ->
?assertMatch(Key3, pcl_fetch(PCL, {o,"Bucket0003", "Key0003", null})), ?assertMatch(Key3, pcl_fetch(PCL, {o,"Bucket0003", "Key0003", null})),
timer:sleep(200), timer:sleep(200),
% This sleep should make sure that the merge to L1 has occurred % This sleep should make sure that the merge to L1 has occurred
% This will free up the L0 slot for the remainder to be written in shutdown % This will free up the L0 slot for the remainder to be written in
% shutdown
ok = pcl_close(PCL), ok = pcl_close(PCL),
{ok, PCLr} = pcl_start(#penciller_options{root_path=RootPath, {ok, PCLr} = pcl_start(#penciller_options{root_path=RootPath,
@ -1591,8 +1590,8 @@ simple_server_test() ->
null}, null},
3004)), 3004)),
% Add some more keys and confirm that check sequence number still % Add some more keys and confirm that check sequence number still
% sees the old version in the previous snapshot, but will see the new version % sees the old version in the previous snapshot, but will see the new
% in a new snapshot % version in a new snapshot
Key1A_Pre = {{o,"Bucket0001", "Key0001", null}, Key1A_Pre = {{o,"Bucket0001", "Key0001", null},
{4005, {active, infinity}, null}}, {4005, {active, infinity}, null}},
@ -1754,13 +1753,15 @@ foldwithimm_simple_test() ->
{8, {active, infinity}, 0, null}}], {8, {active, infinity}, 0, null}}],
AccA = keyfolder(IMMiterA, AccA = keyfolder(IMMiterA,
QueryArray, QueryArray,
{o, "Bucket1", "Key1", null}, {o, "Bucket1", "Key6", null}, {o, "Bucket1", "Key1", null},
{o, "Bucket1", "Key6", null},
{AccFun, []}), {AccFun, []}),
?assertMatch([{{o, "Bucket1", "Key1", null}, 8}, ?assertMatch([{{o, "Bucket1", "Key1", null}, 8},
{{o, "Bucket1", "Key3", null}, 3}, {{o, "Bucket1", "Key3", null}, 3},
{{o, "Bucket1", "Key5", null}, 2}], AccA), {{o, "Bucket1", "Key5", null}, 2}], AccA),
KL1B = [{{o, "Bucket1", "Key4", null}, {10, {active, infinity}, 0, null}}|KL1A], AddKV = {{o, "Bucket1", "Key4", null}, {10, {active, infinity}, 0, null}},
KL1B = [AddKV|KL1A],
IMM3 = leveled_tree:from_orderedlist(lists:ukeysort(1, KL1B), ?CACHE_TYPE), IMM3 = leveled_tree:from_orderedlist(lists:ukeysort(1, KL1B), ?CACHE_TYPE),
IMMiterB = leveled_tree:match_range({o, "Bucket1", "Key1", null}, IMMiterB = leveled_tree:match_range({o, "Bucket1", "Key1", null},
{o, null, null, null}, {o, null, null, null},

View file

@ -1837,16 +1837,8 @@ indexed_list_mixedkeys_bitflip_test() ->
Keys = lists:ukeysort(1, generate_indexkeys(60) ++ KVL1), Keys = lists:ukeysort(1, generate_indexkeys(60) ++ KVL1),
{_PosBinIndex1, FullBin, _HL, LK} = generate_binary_slot(lookup, Keys), {_PosBinIndex1, FullBin, _HL, LK} = generate_binary_slot(lookup, Keys),
?assertMatch(LK, element(1, lists:last(Keys))), ?assertMatch(LK, element(1, lists:last(Keys))),
L = byte_size(FullBin),
Byte1 = leveled_rand:uniform(L), FullBin0 = flip_byte(FullBin),
<<PreB1:Byte1/binary, A:8/integer, PostByte1/binary>> = FullBin,
FullBin0 =
case A of
0 ->
<<PreB1:Byte1/binary, 255:8/integer, PostByte1/binary>>;
_ ->
<<PreB1:Byte1/binary, 0:8/integer, PostByte1/binary>>
end,
{TestK1, _TestV1} = lists:nth(20, KVL1), {TestK1, _TestV1} = lists:nth(20, KVL1),
MH1 = leveled_codec:segment_hash(TestK1), MH1 = leveled_codec:segment_hash(TestK1),
@ -1862,6 +1854,17 @@ indexed_list_mixedkeys_bitflip_test() ->
?assertMatch([], O1). ?assertMatch([], O1).
flip_byte(Binary) ->
L = byte_size(Binary),
Byte1 = leveled_rand:uniform(L),
<<PreB1:Byte1/binary, A:8/integer, PostByte1/binary>> = Binary,
case A of
0 ->
<<PreB1:Byte1/binary, 255:8/integer, PostByte1/binary>>;
_ ->
<<PreB1:Byte1/binary, 0:8/integer, PostByte1/binary>>
end.
test_binary_slot(FullBin, Key, Hash, ExpectedValue) -> test_binary_slot(FullBin, Key, Hash, ExpectedValue) ->
% SW = os:timestamp(), % SW = os:timestamp(),
@ -2222,7 +2225,11 @@ nonsense_coverage_test() ->
#state{}, #state{},
nonsense)), nonsense)),
?assertMatch({reply, undefined, reader, #state{}}, ?assertMatch({reply, undefined, reader, #state{}},
handle_sync_event("hello", self(), reader, #state{})). handle_sync_event("hello", self(), reader, #state{})),
SampleBin = <<0:128/integer>>,
FlippedBin = flip_byte(SampleBin),
?assertMatch(false, FlippedBin == SampleBin).
hashmatching_bytreesize_test() -> hashmatching_bytreesize_test() ->
B = <<"Bucket">>, B = <<"Bucket">>,