Pick-up test misses

There were some coverage misses in tests, so check in unit test coverage
or remove branches not currently needed.
This commit is contained in:
martinsumner 2016-11-18 21:35:45 +00:00
parent 427b97873c
commit f40ecdd529
6 changed files with 37 additions and 27 deletions

View file

@ -866,12 +866,7 @@ get_opt(Key, Opts) ->
get_opt(Key, Opts, Default) -> get_opt(Key, Opts, Default) ->
case proplists:get_value(Key, Opts) of case proplists:get_value(Key, Opts) of
undefined -> undefined ->
case application:get_env(?MODULE, Key) of Default;
{ok, Value} ->
Value;
undefined ->
Default
end;
Value -> Value ->
Value Value
end. end.

View file

@ -1682,18 +1682,29 @@ get_keys_byposition_manykeys_test() ->
#cdb_options{binary_mode=false}), #cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(KeyCount, []), KVList = generate_sequentialkeys(KeyCount, []),
lists:foreach(fun({K, V}) -> cdb_put(P1, K, V) end, KVList), lists:foreach(fun({K, V}) -> cdb_put(P1, K, V) end, KVList),
SW1 = os:timestamp(), ok = cdb_roll(P1),
% Should not return posiitons when rolling
?assertMatch([], cdb_getpositions(P1, 10)),
lists:foldl(fun(X, Complete) ->
case Complete of
true ->
true;
false ->
case cdb_checkhashtable(P1) of
true ->
true;
false ->
timer:sleep(X),
false
end
end end,
false,
lists:seq(1, 20)),
?assertMatch(10, length(cdb_getpositions(P1, 10))),
{ok, F2} = cdb_complete(P1), {ok, F2} = cdb_complete(P1),
SW2 = os:timestamp(),
io:format("CDB completed in ~w microseconds~n",
[timer:now_diff(SW2, SW1)]),
{ok, P2} = cdb_open_reader(F2, #cdb_options{binary_mode=false}), {ok, P2} = cdb_open_reader(F2, #cdb_options{binary_mode=false}),
SW3 = os:timestamp(),
io:format("CDB opened for read in ~w microseconds~n",
[timer:now_diff(SW3, SW2)]),
PositionList = cdb_getpositions(P2, all), PositionList = cdb_getpositions(P2, all),
io:format("Positions fetched in ~w microseconds~n",
[timer:now_diff(os:timestamp(), SW3)]),
L1 = length(PositionList), L1 = length(PositionList),
?assertMatch(L1, KeyCount), ?assertMatch(L1, KeyCount),

View file

@ -223,7 +223,7 @@ handle_info(_Info, State) ->
terminate(normal, _State) -> terminate(normal, _State) ->
ok; ok;
terminate(Reason, _State) -> terminate(Reason, _State) ->
leveled_log:log("IC001", Reason). leveled_log:log("IC001", [Reason]).
code_change(_OldVsn, State, _Extra) -> code_change(_OldVsn, State, _Extra) ->
{ok, State}. {ok, State}.
@ -846,6 +846,7 @@ compact_singlefile_totwosmallfiles_test() ->
coverage_cheat_test() -> coverage_cheat_test() ->
{noreply, _State0} = handle_info(timeout, #state{}), {noreply, _State0} = handle_info(timeout, #state{}),
{ok, _State1} = code_change(null, #state{}, null), {ok, _State1} = code_change(null, #state{}, null),
{reply, not_supported, _State2} = handle_call(null, null, #state{}). {reply, not_supported, _State2} = handle_call(null, null, #state{}),
terminate(error, #state{}).
-endif. -endif.

View file

@ -908,10 +908,13 @@ empty_manifest_test() ->
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath, {ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
cdb_options=CDBopts}), cdb_options=CDBopts}),
?assertMatch(not_present, ink_fetch(Ink1, "Key1", 1)), ?assertMatch(not_present, ink_fetch(Ink1, "Key1", 1)),
CheckFun = fun(L, K, SQN) -> lists:member({SQN, K}, L) end,
?assertMatch(false, CheckFun([], "key", 1)),
ok = ink_compactjournal(Ink1, ok = ink_compactjournal(Ink1,
[], [],
fun(X) -> {X, 55} end, fun(X) -> {X, 55} end,
fun(L, K, SQN) -> lists:member({SQN, K}, L) end, CheckFun,
5000), 5000),
timer:sleep(1000), timer:sleep(1000),
?assertMatch(1, length(ink_getmanifest(Ink1))), ?assertMatch(1, length(ink_getmanifest(Ink1))),

View file

@ -68,7 +68,8 @@
{"P0017", {"P0017",
{info, "No L0 file found"}}, {info, "No L0 file found"}},
{"P0018", {"P0018",
{info, "Respone to push_mem of ~w ~s"}}, {info, "Response to push_mem of ~w with "
++ "L0 pending ~w and merge backlog ~w"}},
{"P0019", {"P0019",
{info, "Rolling level zero to filename ~s"}}, {info, "Rolling level zero to filename ~s"}},
{"P0020", {"P0020",

View file

@ -321,15 +321,14 @@ handle_call({push_mem, PushedTree}, From, State=#state{is_snapshot=Snap})
% %
% Check the approximate size of the cache. If it is over the maximum size, % Check the approximate size of the cache. If it is over the maximum size,
% trigger a backgroun L0 file write and update state of levelzero_pending. % trigger a backgroun L0 file write and update state of levelzero_pending.
case {State#state.levelzero_pending, State#state.work_backlog} of case State#state.levelzero_pending or State#state.work_backlog of
{true, _} -> true ->
leveled_log:log("P0018", [returned, "L-0 persist pending"]), leveled_log:log("P0018", [returned,
State#state.levelzero_pending,
State#state.work_backlog]),
{reply, returned, State}; {reply, returned, State};
{false, true} -> false ->
leveled_log:log("P0018", [returned, "Merge tree work backlog"]), leveled_log:log("P0018", [ok, false, false]),
{reply, returned, State};
{false, false} ->
leveled_log:log("P0018", [ok, "L0 memory updated"]),
gen_server:reply(From, ok), gen_server:reply(From, ok),
{noreply, update_levelzero(State#state.levelzero_index, {noreply, update_levelzero(State#state.levelzero_index,
State#state.levelzero_size, State#state.levelzero_size,