Merge pull request #15 from basho/slf/eunit-verbose-cleanup

Reduce compiler warnings and verbose output that clutters eunit test output
This commit is contained in:
Scott Lystig Fritchie 2015-10-16 17:45:24 +09:00
commit de364d3a99
8 changed files with 26 additions and 56 deletions

View file

@ -1,5 +1,6 @@
language: erlang language: erlang
notifications: notifications:
email: scott@basho.com email: scott@basho.com
script: "make test"
otp_release: otp_release:
- 17.5 - 17.5

View file

@ -672,12 +672,12 @@ calc_projection(S, RelativeToServer) ->
calc_projection(#ch_mgr{proj=P_current}=S, RelativeToServer, AllHosed) -> calc_projection(#ch_mgr{proj=P_current}=S, RelativeToServer, AllHosed) ->
calc_projection(S, RelativeToServer, AllHosed, P_current). calc_projection(S, RelativeToServer, AllHosed, P_current).
calc_projection(#ch_mgr{name=MyName, consistency_mode=CMode, calc_projection(#ch_mgr{name=_MyName, consistency_mode=CMode,
runenv=RunEnv}=S, runenv=_RunEnv}=S,
RelativeToServer, AllHosed, P_current) -> RelativeToServer, AllHosed, P_current) ->
Dbg = [], Dbg = [],
%% OldThreshold = proplists:get_value(old_threshold, RunEnv), %% OldThreshold = proplists:get_value(old_threshold, _RunEnv),
%% NoPartitionThreshold = proplists:get_value(no_partition_threshold, RunEnv), %% NoPartitionThreshold = proplists:get_value(no_partition_threshold, _RunEnv),
if CMode == ap_mode -> if CMode == ap_mode ->
calc_projection2(P_current, RelativeToServer, AllHosed, Dbg, S); calc_projection2(P_current, RelativeToServer, AllHosed, Dbg, S);
CMode == cp_mode -> CMode == cp_mode ->
@ -700,7 +700,7 @@ calc_projection(#ch_mgr{name=MyName, consistency_mode=CMode,
%% Dbg, S); %% Dbg, S);
%% {_, false} -> %% {_, false} ->
%% {Up, _Partitions, RunEnv2} = calc_up_nodes( %% {Up, _Partitions, RunEnv2} = calc_up_nodes(
%% MyName, AllMembers, RunEnv), %% _MyName, AllMembers, _RunEnv),
%% %% We can't improve on the current projection. %% %% We can't improve on the current projection.
%% {P_current, S#ch_mgr{runenv=RunEnv2}, Up} %% {P_current, S#ch_mgr{runenv=RunEnv2}, Up}
%% end %% end
@ -1779,9 +1779,10 @@ react_to_env_C100(P_newprop,
if Sane == true -> if Sane == true ->
ok; ok;
true -> true ->
QQ_current = lists:flatten(io_lib:format("cur=~w:~w,~w/calc=~w:~w,~w", [P_current#projection_v1.epoch_number, P_current#projection_v1.upi, P_current#projection_v1.repairing, P_current_calc#projection_v1.epoch_number, P_current_calc#projection_v1.upi, P_current_calc#projection_v1.repairing])), %% QQ_current = lists:flatten(io_lib:format("cur=~w:~w,~w/calc=~w:~w,~w", [P_current#projection_v1.epoch_number, P_current#projection_v1.upi, P_current#projection_v1.repairing, P_current_calc#projection_v1.epoch_number, P_current_calc#projection_v1.upi, P_current_calc#projection_v1.repairing])),
QQ_latest = lists:flatten(io_lib:format("~w:~w,~w", [P_latest#projection_v1.epoch_number, P_latest#projection_v1.upi, P_latest#projection_v1.repairing])), %% QQ_latest = lists:flatten(io_lib:format("~w:~w,~w", [P_latest#projection_v1.epoch_number, P_latest#projection_v1.upi, P_latest#projection_v1.repairing])),
?V("\n~w-insane-~w-auth=~w ~s -> ~s ~w\n ~p\n ~p\n", [?LINE, MyName, P_newprop#projection_v1.author_server, QQ_current, QQ_latest, Sane, get(why2), get(react)]) %% ?V("\n~w-insane-~w-auth=~w ~s -> ~s ~w\n ~p\n ~p\n", [?LINE, MyName, P_newprop#projection_v1.author_server, QQ_current, QQ_latest, Sane, get(why2), get(react)]),
ok
end, end,
?REACT({c100, ?LINE, [zoo, {me,MyName}, ?REACT({c100, ?LINE, [zoo, {me,MyName},
{author_latest,Author_latest}, {author_latest,Author_latest},
@ -1797,11 +1798,11 @@ react_to_env_C100(P_newprop,
%% or for when we got stuck in an insane projection transition %% or for when we got stuck in an insane projection transition
%% and were forced to the none projection to recover. %% and were forced to the none projection to recover.
?REACT({c100, ?LINE, [first_write]}), ?REACT({c100, ?LINE, [first_write]}),
if Sane == true -> ok; true -> ?V("~w-insane-~w-~w:~w:~w,", [?LINE, MyName, P_newprop#projection_v1.epoch_number, P_newprop#projection_v1.upi, P_newprop#projection_v1.repairing]) end, %%% DELME!!! %% if Sane == true -> ok; true -> ?V("~w-insane-~w-~w:~w:~w,", [?LINE, MyName, P_newprop#projection_v1.epoch_number, P_newprop#projection_v1.upi, P_newprop#projection_v1.repairing]) end, %%% DELME!!!
react_to_env_C110(P_latest, S); react_to_env_C110(P_latest, S);
true -> true ->
?REACT({c100, ?LINE, []}), ?REACT({c100, ?LINE, []}),
if Sane == true -> ok; true -> ?V("~w-insane-~w-~w:~w:~w@~w,", [?LINE, MyName, P_newprop#projection_v1.epoch_number, P_newprop#projection_v1.upi, P_newprop#projection_v1.repairing, ?LINE]) end, %%% DELME!!! %% if Sane == true -> ok; true -> ?V("~w-insane-~w-~w:~w:~w@~w,", [?LINE, MyName, P_newprop#projection_v1.epoch_number, P_newprop#projection_v1.upi, P_newprop#projection_v1.repairing, ?LINE]) end, %%% DELME!!!
V = case file:read_file("/tmp/bugbug."++atom_to_list(S#ch_mgr.name)) of {ok,_} -> true; _ -> false end, V = case file:read_file("/tmp/bugbug."++atom_to_list(S#ch_mgr.name)) of {ok,_} -> true; _ -> false end,
if V -> if V ->
@ -1816,17 +1817,17 @@ react_to_env_C100(P_newprop,
P_newprop, P_latest, P_current_calc, S) P_newprop, P_latest, P_current_calc, S)
end. end.
react_to_env_C100_inner(Author_latest, NotSanesDict0, MyName, react_to_env_C100_inner(Author_latest, NotSanesDict0, _MyName,
P_newprop, P_latest, P_current_calc, S) -> P_newprop, P_latest, P_current_calc, S) ->
NotSanesDict = orddict:update_counter(Author_latest, 1, NotSanesDict0), NotSanesDict = orddict:update_counter(Author_latest, 1, NotSanesDict0),
S2 = S#ch_mgr{not_sanes=NotSanesDict, sane_transitions=0}, S2 = S#ch_mgr{not_sanes=NotSanesDict, sane_transitions=0},
case orddict:fetch(Author_latest, NotSanesDict) of case orddict:fetch(Author_latest, NotSanesDict) of
N when N > ?TOO_FREQUENT_BREAKER -> N when N > ?TOO_FREQUENT_BREAKER ->
?V("\n\nYOYO ~w breaking the cycle of:\n current: ~w\n new : ~w\n", [MyName, machi_projection:make_summary(S#ch_mgr.proj), machi_projection:make_summary(P_latest)]), %% ?V("\n\nYOYO ~w breaking the cycle of:\n current: ~w\n new : ~w\n", [_MyName, machi_projection:make_summary(S#ch_mgr.proj), machi_projection:make_summary(P_latest)]),
?REACT({c100, ?LINE, [{not_sanes_author_count, N}]}), ?REACT({c100, ?LINE, [{not_sanes_author_count, N}]}),
react_to_env_C103(P_newprop, P_latest, P_current_calc, S2); react_to_env_C103(P_newprop, P_latest, P_current_calc, S2);
N -> N ->
?V("YOYO,~w,~w,~w,",[MyName, P_latest#projection_v1.epoch_number,N]), %% ?V("YOYO,~w,~w,~w,",[_MyName, P_latest#projection_v1.epoch_number,N]),
?REACT({c100, ?LINE, [{not_sanes_author_count, N}]}), ?REACT({c100, ?LINE, [{not_sanes_author_count, N}]}),
%% P_latest is not sane. %% P_latest is not sane.
%% By process of elimination, P_newprop is best, %% By process of elimination, P_newprop is best,

View file

@ -96,11 +96,6 @@
-export([repair/7]). -export([repair/7]).
repair_cp(_Src, _Dst, _MembersDict, _Opts) ->
%% TODO: add missing function: wipe away any trace of chunks
%% are present on Dst but missing on Src.
exit(todo_cp_mode).
repair(ap_mode=ConsistencyMode, Src, Repairing, UPI, MembersDict, ETS, Opts) -> repair(ap_mode=ConsistencyMode, Src, Repairing, UPI, MembersDict, ETS, Opts) ->
%% Use process dict so that 'after' clause can always quit all %% Use process dict so that 'after' clause can always quit all
%% proxy pids. %% proxy pids.
@ -156,7 +151,7 @@ repair(ap_mode=ConsistencyMode, Src, Repairing, UPI, MembersDict, ETS, Opts) ->
Pid <- orddict:to_list(get(proxies_dict))] Pid <- orddict:to_list(get(proxies_dict))]
end, end,
Res; Res;
repair(cp_mode=ConsistencyMode, Src, Repairing, UPI, MembersDict, ETS, Opts) -> repair(cp_mode=_ConsistencyMode, Src, Repairing, UPI, MembersDict, ETS, Opts) ->
io:format(user, "\n\nTODO! cp_mode repair is not fully implemented!\n\n", []), io:format(user, "\n\nTODO! cp_mode repair is not fully implemented!\n\n", []),
repair(ap_mode, Src, Repairing, UPI, MembersDict, ETS, Opts). repair(ap_mode, Src, Repairing, UPI, MembersDict, ETS, Opts).

View file

@ -86,7 +86,7 @@ send_spam_to_everyone(Pid) ->
init([{MyFluName}|Args]) -> init([{MyFluName}|Args]) ->
RegName = machi_flu_psup:make_fitness_regname(MyFluName), RegName = machi_flu_psup:make_fitness_regname(MyFluName),
register(RegName, self()), register(RegName, self()),
timer:send_interval(5000, dump), timer:send_interval(5000, debug_dump),
UseSimulatorP = proplists:get_value(use_partition_simulator, Args, false), UseSimulatorP = proplists:get_value(use_partition_simulator, Args, false),
{ok, #state{my_flu_name=MyFluName, reg_name=RegName, {ok, #state{my_flu_name=MyFluName, reg_name=RegName,
partition_simulator_p=UseSimulatorP, partition_simulator_p=UseSimulatorP,
@ -139,7 +139,7 @@ handle_info({adjust_down_list, FLU}, #state{active_unfit=ActiveUnfit}=S) ->
NewUnfit = make_unfit_list(S), NewUnfit = make_unfit_list(S),
Added_to_new = NewUnfit -- ActiveUnfit, Added_to_new = NewUnfit -- ActiveUnfit,
Dropped_from_new = ActiveUnfit -- NewUnfit, Dropped_from_new = ActiveUnfit -- NewUnfit,
io:format(user, "adjust_down_list: ~w: adjust ~w: add ~p drop ~p\n", [S#state.my_flu_name, FLU, Added_to_new, Dropped_from_new]), %% io:format(user, "adjust_down_list: ~w: adjust ~w: add ~p drop ~p\n", [S#state.my_flu_name, FLU, Added_to_new, Dropped_from_new]),
%% We need to schedule a new round of adjustment messages. They might %% We need to schedule a new round of adjustment messages. They might
%% be redundant, or they might not. Here's a case where the current %% be redundant, or they might not. Here's a case where the current
%% code needs the extra: %% code needs the extra:
@ -182,9 +182,9 @@ handle_info({adjust_down_list, FLU}, #state{active_unfit=ActiveUnfit}=S) ->
{false, false} -> {false, false} ->
{noreply, S} {noreply, S}
end; end;
handle_info(dump, #state{my_flu_name=MyFluName,active_unfit=ActiveUnfit, handle_info(debug_dump, #state{my_flu_name=_MyFluName,active_unfit=_ActiveUnfit,
pending_map=Map}=S) -> pending_map=_Map}=S) ->
%% io:format(user, "DUMP: ~w/~w: ~p ~W\n", [MyFluName, self(), ActiveUnfit, map_value(Map), 13]), %% io:format(user, "DUMP: ~w/~w: ~p ~W\n", [_MyFluName, self(), _ActiveUnfit, map_value(_Map), 13]),
%% io:format(user, "DUMP ~w: ~w, ", [MyFluName, ActiveUnfit]), %% io:format(user, "DUMP ~w: ~w, ", [MyFluName, ActiveUnfit]),
{noreply, S}; {noreply, S};
handle_info(_Info, S) -> handle_info(_Info, S) ->
@ -390,6 +390,7 @@ map_set(Actor, Map, Key, ValTerm) ->
Actor, Map), Actor, Map),
Map2. Map2.
-ifdef(TEST).
map_get(Map, Key) -> map_get(Map, Key) ->
Field = {Key, ?LWWREG}, Field = {Key, ?LWWREG},
case lists:keyfind(Field, 1, ?MAP:value(Map)) of case lists:keyfind(Field, 1, ?MAP:value(Map)) of
@ -398,6 +399,7 @@ map_get(Map, Key) ->
{Field, ValBin} -> {Field, ValBin} ->
{ok, binary_to_term(ValBin)} {ok, binary_to_term(ValBin)}
end. end.
-endif. % TEST
map_fold(Fun, Acc, Map) -> map_fold(Fun, Acc, Map) ->
Vs = map_value(Map), Vs = map_value(Map),
@ -411,24 +413,6 @@ map_merge(Map1, Map2) ->
-ifdef(TEST). -ifdef(TEST).
testing_sleep_perhaps() ->
try
[{_,Max}] = ets:lookup(?TEST_ETS_TABLE, projection_store_sleep_time),
MSec = random:uniform(Max),
timer:sleep(MSec),
ok
catch _X:_Y ->
ok
end.
-else. % TEST
testing_sleep_perhaps() ->
ok.
-endif. % TEST
-ifdef(TEST).
dt_understanding_test() -> dt_understanding_test() ->
F1 = {'X', riak_dt_lwwreg}, F1 = {'X', riak_dt_lwwreg},
F2 = {'Y', riak_dt_lwwreg}, F2 = {'Y', riak_dt_lwwreg},

View file

@ -56,7 +56,7 @@ init([]) ->
MaxSecondsBetweenRestarts = 3600, MaxSecondsBetweenRestarts = 3600,
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}, SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
Tab = ets:new(?TEST_ETS_TABLE, [named_table, public, ordered_set, _Tab = ets:new(?TEST_ETS_TABLE, [named_table, public, ordered_set,
{read_concurrency,true}]), {read_concurrency,true}]),
Ps = get_initial_flus(), Ps = get_initial_flus(),

View file

@ -747,16 +747,6 @@ enc_sexp(T) ->
dec_sexp(Bin) when is_binary(Bin) -> dec_sexp(Bin) when is_binary(Bin) ->
binary_to_term(Bin). binary_to_term(Bin).
enc_optional_sexp(undefined) ->
undefined;
enc_optional_sexp(T) ->
enc_sexp(T).
dec_optional_sexp(undefined) ->
undefined;
dec_optional_sexp(T) ->
dec_sexp(T).
conv_from_members_dict(D) -> conv_from_members_dict(D) ->
%% Use list_to_binary() here to "flatten" the serialized #p_srvr{} %% Use list_to_binary() here to "flatten" the serialized #p_srvr{}
[#mpb_membersdictentry{key=to_list(K), val=conv_from_p_srvr(V)} || [#mpb_membersdictentry{key=to_list(K), val=conv_from_p_srvr(V)} ||

View file

@ -314,7 +314,7 @@ timing_pb_encoding_test2() ->
RUN2 = timer:tc(fun() -> begin [_ = DoIt2() || _ <- XX], ok end end), RUN2 = timer:tc(fun() -> begin [_ = DoIt2() || _ <- XX], ok end end),
erlang:garbage_collect(), erlang:garbage_collect(),
Factor = (element(1, RUN1) / element(1, RUN2)), Factor = (element(1, RUN1) / element(1, RUN2)),
io:format(user, " speed factor=~.2f ", [Factor]), io:format(" speed factor=~.2f ", [Factor]),
ok. ok.
-endif. % !PULSE -endif. % !PULSE

View file

@ -97,7 +97,6 @@ smoke_test2() ->
_Boring_stack_trace}}, _Boring_stack_trace}},
?C:trim_chunk(Clnt, Fl, Off, Sz)) ?C:trim_chunk(Clnt, Fl, Off, Sz))
end || {Ch, Fl, Off, Sz} <- Reads], end || {Ch, Fl, Off, Sz} <- Reads],
?debugVal(?C:list_files(Clnt)),
ok ok
after after