Fix fitness timing problem with short-circuit +trigger_early_adjustment/2
This commit is contained in:
parent
ef10ebed22
commit
27e8a31307
2 changed files with 25 additions and 29 deletions
|
@ -39,7 +39,8 @@
|
|||
get_unfit_list/1, update_local_down_list/3,
|
||||
add_admin_down/3, delete_admin_down/2,
|
||||
send_fitness_update_spam/3,
|
||||
send_spam_to_everyone/1]).
|
||||
send_spam_to_everyone/1,
|
||||
trigger_early_adjustment/2]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
|
@ -81,6 +82,13 @@ send_fitness_update_spam(Pid, FromName, Dict) ->
|
|||
send_spam_to_everyone(Pid) ->
|
||||
gen_server:call(Pid, {send_spam_to_everyone}, infinity).
|
||||
|
||||
%% @doc For testing purposes, we don't want a test to wait for
|
||||
%% wall-clock time to elapse before the fitness server makes a
|
||||
%% down->up status decision.
|
||||
|
||||
trigger_early_adjustment(Pid, FLU) ->
|
||||
Pid ! {adjust_down_list, FLU}.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
init([{MyFluName}|Args]) ->
|
||||
|
@ -95,13 +103,11 @@ init([{MyFluName}|Args]) ->
|
|||
|
||||
handle_call({get_unfit_list}, _From, #state{active_unfit=ActiveUnfit}=S) ->
|
||||
Reply = ActiveUnfit,
|
||||
io:format(user, "get_unfit_list ~p: ~p\n", [S#state.my_flu_name, Reply]),
|
||||
{reply, Reply, S};
|
||||
handle_call({update_local_down_list, Down, MembersDict}, _From,
|
||||
#state{my_flu_name=MyFluName, pending_map=OldMap,
|
||||
local_down=OldDown, members_dict=OldMembersDict,
|
||||
admin_down=AdminDown}=S) ->
|
||||
io:format(user, "update_local_down_list: ~w: down ~w md ~W\n", [S#state.my_flu_name, Down, MembersDict, 10]),
|
||||
NewMap = store_in_map(OldMap, MyFluName, erlang:now(), Down,
|
||||
AdminDown, [props_yo]),
|
||||
S2 = if Down == OldDown, MembersDict == OldMembersDict ->
|
||||
|
|
|
@ -357,10 +357,13 @@ nonunanimous_setup_and_fix_test2() ->
|
|||
MgrProxies = [{Ma, Proxy_a}, {Mb, Proxy_b}, {Mc, Proxy_c}],
|
||||
Advance = fun() ->
|
||||
[begin
|
||||
catch ?MGR:trigger_react_to_env(Mgr),
|
||||
[catch machi_fitness:trigger_early_adjustment(Fit, Tgt) ||
|
||||
Fit <- [a_fitness,b_fitness,c_fitness],
|
||||
Tgt <- [a,b,c] ],
|
||||
[catch ?MGR:trigger_react_to_env(Mgr) ||
|
||||
{Mgr,_Proxy} <- MgrProxies],
|
||||
ok
|
||||
end || _ <- lists:seq(1, 7),
|
||||
{Mgr,Proxy} <- MgrProxies]
|
||||
end || _ <- lists:seq(1, 3)]
|
||||
end,
|
||||
ok = machi_chain_manager1:set_chain_members(Ma, MembersDict),
|
||||
ok = machi_chain_manager1:set_chain_members(Mb, MembersDict),
|
||||
|
@ -498,32 +501,19 @@ nonunanimous_setup_and_fix_test2() ->
|
|||
ok = machi_chain_manager1:set_chain_members(
|
||||
Mb, ch_not_def_yet, TheEpoch_9, ap_mode, MembersDict9, []),
|
||||
Advance(),
|
||||
[begin
|
||||
{ok, Pqq} = ?FLU_PC:read_latest_projection(Pxy, private),
|
||||
io:format(user, "At ~w: ~w\n", [Pxy, machi_projection:make_summary(Pqq#projection_v1{dbg2=[]})])
|
||||
end || Pxy <- tl(Proxies)],
|
||||
{_, _, TheEpoch_9b} = ?MGR:trigger_react_to_env(Mb),
|
||||
true = (TheEpoch_9b > TheEpoch_9),
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
io:format(user, "STEP: Start a, and it joins like it ought to\n", []),
|
||||
|
||||
[{ok,_}=machi_flu_psup:start_flu_package(Name, Port, Dir, Opts) ||
|
||||
{Name,Port,Dir} <- [hd(FluInfo)]],
|
||||
Advance(),
|
||||
os:cmd("touch /tmp/moomoo.c"),
|
||||
[begin
|
||||
Qzx = ?MGR:trigger_react_to_env(Mgr),
|
||||
io:format(user, "dbg: ~w: ~w\n", [Mgr, Qzx]),
|
||||
ok
|
||||
end || _ <- lists:seq(1,1),
|
||||
{Mgr,Proxy} <- MgrProxies],
|
||||
[begin
|
||||
{ok, Pqq} = ?FLU_PC:read_latest_projection(Pxy, private),
|
||||
io:format(user, "At ~w: ~w\n", [Pxy, machi_projection:make_summary(Pqq#projection_v1{dbg2=[]})])
|
||||
end || Pxy <- Proxies],
|
||||
[io:format(user, "Unfit @ ~w: ~p\n", [Xii, machi_fitness:get_unfit_list(machi_fitness)]) || Xii <- [a_fitness, b_fitness, c_fitness] ],
|
||||
{ok, {true, {0,_}}} = ?FLU_PC:wedge_status(Proxy_a),
|
||||
{_, _, TheEpoch_9c} = ?MGR:trigger_react_to_env(Ma),
|
||||
{_, _, TheEpoch_9c} = ?MGR:trigger_react_to_env(Mb),
|
||||
{_, _, TheEpoch_9c} = ?MGR:trigger_react_to_env(Mc),
|
||||
[{ok, #projection_v1{upi=[b], repairing=[a,c]}} =
|
||||
{ok, {false, {TheEpoch10,_}}} = ?FLU_PC:wedge_status(Proxy_a),
|
||||
{ok, {false, {TheEpoch10,_}}} = ?FLU_PC:wedge_status(Proxy_b),
|
||||
{ok, {false, {TheEpoch10,_}}} = ?FLU_PC:wedge_status(Proxy_c),
|
||||
[{ok, #projection_v1{upi=[b], repairing=[c,a]}} =
|
||||
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- Proxies],
|
||||
ok
|
||||
after
|
||||
|
|
Loading…
Reference in a new issue