diff --git a/.travis.yml b/.travis.yml index ddd415c..40363cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: erlang notifications: email: scott@basho.com +script: "make test" otp_release: - 17.5 diff --git a/src/machi_chain_manager1.erl b/src/machi_chain_manager1.erl index 83a5a93..0e8d95a 100644 --- a/src/machi_chain_manager1.erl +++ b/src/machi_chain_manager1.erl @@ -672,12 +672,12 @@ calc_projection(S, RelativeToServer) -> calc_projection(#ch_mgr{proj=P_current}=S, RelativeToServer, AllHosed) -> calc_projection(S, RelativeToServer, AllHosed, P_current). -calc_projection(#ch_mgr{name=MyName, consistency_mode=CMode, - runenv=RunEnv}=S, +calc_projection(#ch_mgr{name=_MyName, consistency_mode=CMode, + runenv=_RunEnv}=S, RelativeToServer, AllHosed, P_current) -> Dbg = [], - %% OldThreshold = proplists:get_value(old_threshold, RunEnv), - %% NoPartitionThreshold = proplists:get_value(no_partition_threshold, RunEnv), + %% OldThreshold = proplists:get_value(old_threshold, _RunEnv), + %% NoPartitionThreshold = proplists:get_value(no_partition_threshold, _RunEnv), if CMode == ap_mode -> calc_projection2(P_current, RelativeToServer, AllHosed, Dbg, S); CMode == cp_mode -> @@ -700,7 +700,7 @@ calc_projection(#ch_mgr{name=MyName, consistency_mode=CMode, %% Dbg, S); %% {_, false} -> %% {Up, _Partitions, RunEnv2} = calc_up_nodes( - %% MyName, AllMembers, RunEnv), + %% _MyName, AllMembers, _RunEnv), %% %% We can't improve on the current projection. %% {P_current, S#ch_mgr{runenv=RunEnv2}, Up} %% end @@ -1779,9 +1779,10 @@ react_to_env_C100(P_newprop, if Sane == true -> ok; 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_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)]) + %% 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])), + %% ?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, ?REACT({c100, ?LINE, [zoo, {me,MyName}, {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 %% and were forced to the none projection to recover. ?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); true -> ?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, if V -> @@ -1816,17 +1817,17 @@ react_to_env_C100(P_newprop, P_newprop, P_latest, P_current_calc, S) 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) -> NotSanesDict = orddict:update_counter(Author_latest, 1, NotSanesDict0), S2 = S#ch_mgr{not_sanes=NotSanesDict, sane_transitions=0}, case orddict:fetch(Author_latest, NotSanesDict) of 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_to_env_C103(P_newprop, P_latest, P_current_calc, S2); 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}]}), %% P_latest is not sane. %% By process of elimination, P_newprop is best, diff --git a/src/machi_chain_repair.erl b/src/machi_chain_repair.erl index 8dc4c17..055f07d 100644 --- a/src/machi_chain_repair.erl +++ b/src/machi_chain_repair.erl @@ -96,11 +96,6 @@ -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) -> %% Use process dict so that 'after' clause can always quit all %% proxy pids. @@ -156,7 +151,7 @@ repair(ap_mode=ConsistencyMode, Src, Repairing, UPI, MembersDict, ETS, Opts) -> Pid <- orddict:to_list(get(proxies_dict))] end, 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", []), repair(ap_mode, Src, Repairing, UPI, MembersDict, ETS, Opts). diff --git a/src/machi_fitness.erl b/src/machi_fitness.erl index 82d18a6..c5dc3bb 100644 --- a/src/machi_fitness.erl +++ b/src/machi_fitness.erl @@ -86,7 +86,7 @@ send_spam_to_everyone(Pid) -> init([{MyFluName}|Args]) -> RegName = machi_flu_psup:make_fitness_regname(MyFluName), register(RegName, self()), -timer:send_interval(5000, dump), + timer:send_interval(5000, debug_dump), UseSimulatorP = proplists:get_value(use_partition_simulator, Args, false), {ok, #state{my_flu_name=MyFluName, reg_name=RegName, partition_simulator_p=UseSimulatorP, @@ -139,7 +139,7 @@ handle_info({adjust_down_list, FLU}, #state{active_unfit=ActiveUnfit}=S) -> NewUnfit = make_unfit_list(S), Added_to_new = NewUnfit -- ActiveUnfit, 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 %% be redundant, or they might not. Here's a case where the current %% code needs the extra: @@ -182,9 +182,9 @@ handle_info({adjust_down_list, FLU}, #state{active_unfit=ActiveUnfit}=S) -> {false, false} -> {noreply, S} end; -handle_info(dump, #state{my_flu_name=MyFluName,active_unfit=ActiveUnfit, - pending_map=Map}=S) -> - %% io:format(user, "DUMP: ~w/~w: ~p ~W\n", [MyFluName, self(), ActiveUnfit, map_value(Map), 13]), +handle_info(debug_dump, #state{my_flu_name=_MyFluName,active_unfit=_ActiveUnfit, + 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, ", [MyFluName, ActiveUnfit]), {noreply, S}; handle_info(_Info, S) -> @@ -390,6 +390,7 @@ map_set(Actor, Map, Key, ValTerm) -> Actor, Map), Map2. +-ifdef(TEST). map_get(Map, Key) -> Field = {Key, ?LWWREG}, case lists:keyfind(Field, 1, ?MAP:value(Map)) of @@ -398,6 +399,7 @@ map_get(Map, Key) -> {Field, ValBin} -> {ok, binary_to_term(ValBin)} end. +-endif. % TEST map_fold(Fun, Acc, Map) -> Vs = map_value(Map), @@ -411,24 +413,6 @@ map_merge(Map1, Map2) -> -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() -> F1 = {'X', riak_dt_lwwreg}, F2 = {'Y', riak_dt_lwwreg}, diff --git a/src/machi_flu_sup.erl b/src/machi_flu_sup.erl index d2653ad..6f8b367 100644 --- a/src/machi_flu_sup.erl +++ b/src/machi_flu_sup.erl @@ -56,8 +56,8 @@ init([]) -> MaxSecondsBetweenRestarts = 3600, SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}, - Tab = ets:new(?TEST_ETS_TABLE, [named_table, public, ordered_set, - {read_concurrency,true}]), + _Tab = ets:new(?TEST_ETS_TABLE, [named_table, public, ordered_set, + {read_concurrency,true}]), Ps = get_initial_flus(), FLU_specs = [machi_flu_psup:make_package_spec(FluName, TcpPort, diff --git a/src/machi_pb_translate.erl b/src/machi_pb_translate.erl index 007e01b..bbed40b 100644 --- a/src/machi_pb_translate.erl +++ b/src/machi_pb_translate.erl @@ -747,16 +747,6 @@ enc_sexp(T) -> dec_sexp(Bin) when is_binary(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) -> %% Use list_to_binary() here to "flatten" the serialized #p_srvr{} [#mpb_membersdictentry{key=to_list(K), val=conv_from_p_srvr(V)} || diff --git a/test/machi_flu1_test.erl b/test/machi_flu1_test.erl index 6c99971..084086a 100644 --- a/test/machi_flu1_test.erl +++ b/test/machi_flu1_test.erl @@ -314,7 +314,7 @@ timing_pb_encoding_test2() -> RUN2 = timer:tc(fun() -> begin [_ = DoIt2() || _ <- XX], ok end end), erlang:garbage_collect(), Factor = (element(1, RUN1) / element(1, RUN2)), - io:format(user, " speed factor=~.2f ", [Factor]), + io:format(" speed factor=~.2f ", [Factor]), ok. -endif. % !PULSE diff --git a/test/machi_pb_high_client_test.erl b/test/machi_pb_high_client_test.erl index 49857d1..36387b5 100644 --- a/test/machi_pb_high_client_test.erl +++ b/test/machi_pb_high_client_test.erl @@ -97,7 +97,6 @@ smoke_test2() -> _Boring_stack_trace}}, ?C:trim_chunk(Clnt, Fl, Off, Sz)) end || {Ch, Fl, Off, Sz} <- Reads], - ?debugVal(?C:list_files(Clnt)), ok after