|
|
|
@ -332,7 +332,11 @@ smoke1_test2() ->
|
|
|
|
|
ok = machi_partition_simulator:stop()
|
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
nonunanimous_setup_and_fix_test() ->
|
|
|
|
|
nonunanimous_setup_and_fix_test_() ->
|
|
|
|
|
os:cmd("rm -f /tmp/moomoo.*"),
|
|
|
|
|
{timeout, 1*60, fun() -> nonunanimous_setup_and_fix_test2() end}.
|
|
|
|
|
|
|
|
|
|
nonunanimous_setup_and_fix_test2() ->
|
|
|
|
|
machi_partition_simulator:start_link({1,2,3}, 100, 0),
|
|
|
|
|
TcpPort = 62877,
|
|
|
|
|
FluInfo = [{a,TcpPort+0,"./data.a"}, {b,TcpPort+1,"./data.b"},
|
|
|
|
@ -342,8 +346,7 @@ nonunanimous_setup_and_fix_test() ->
|
|
|
|
|
|
|
|
|
|
[machi_flu1_test:clean_up_data_dir(Dir) || {_,_,Dir} <- FluInfo],
|
|
|
|
|
{ok, SupPid} = machi_flu_sup:start_link(),
|
|
|
|
|
Opts = [{active_mode, false}],
|
|
|
|
|
%% {ok, Mb} = ?MGR:start_link(b, MembersDict, [{active_mode, false}]++XX),
|
|
|
|
|
Opts = [{active_mode, false}, {initial_wedged, true}],
|
|
|
|
|
[{ok,_}=machi_flu_psup:start_flu_package(Name, Port, Dir, Opts) ||
|
|
|
|
|
{Name,Port,Dir} <- FluInfo],
|
|
|
|
|
Proxies = [Proxy_a, Proxy_b, Proxy_c] =
|
|
|
|
@ -351,8 +354,17 @@ nonunanimous_setup_and_fix_test() ->
|
|
|
|
|
%% MembersDict = machi_projection:make_members_dict(P_s),
|
|
|
|
|
MembersDict = machi_projection:make_members_dict(lists:sublist(P_s, 2)),
|
|
|
|
|
Mgrs = [Ma,Mb,Mc] = [a_chmgr, b_chmgr, c_chmgr],
|
|
|
|
|
MgrProxies = [{Ma, Proxy_a}, {Mb, Proxy_b}, {Mc, Proxy_c}],
|
|
|
|
|
Advance = fun() ->
|
|
|
|
|
[begin
|
|
|
|
|
catch ?MGR:trigger_react_to_env(Mgr),
|
|
|
|
|
ok
|
|
|
|
|
end || _ <- lists:seq(1, 7),
|
|
|
|
|
{Mgr,Proxy} <- MgrProxies]
|
|
|
|
|
end,
|
|
|
|
|
ok = machi_chain_manager1:set_chain_members(Ma, MembersDict),
|
|
|
|
|
ok = machi_chain_manager1:set_chain_members(Mb, MembersDict),
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{ok, P1} = ?MGR:test_calc_projection(Ma, false),
|
|
|
|
|
|
|
|
|
@ -390,18 +402,14 @@ nonunanimous_setup_and_fix_test() ->
|
|
|
|
|
P2 = P2pb#projection_v1{dbg2=[]},
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
%% io:format(user, "\n+ Add a 3rd member to the chain.\n", []),
|
|
|
|
|
%% io:format(user, "\nSTEP: Add a 3rd member to the chain.\n", []),
|
|
|
|
|
io:format(user, "\nNOTE: One INFO REPORT will follow.\n", []),
|
|
|
|
|
|
|
|
|
|
MembersDict3 = machi_projection:make_members_dict(P_s),
|
|
|
|
|
ok = machi_chain_manager1:set_chain_members(
|
|
|
|
|
Ma, ch_not_def_yet, EpochNum_a, ap_mode, MembersDict3, []),
|
|
|
|
|
|
|
|
|
|
[begin
|
|
|
|
|
{_rr1, _rr2, TheEpoch} = ?MGR:trigger_react_to_env(Mgr),
|
|
|
|
|
ok
|
|
|
|
|
end || _ <- lists:seq(1, 7),
|
|
|
|
|
{Mgr,Proxy} <- [{Ma, Proxy_a}, {Mb, Proxy_b}, {Mc, Proxy_c}]],
|
|
|
|
|
Advance(),
|
|
|
|
|
{_, _, TheEpoch_3} = ?MGR:trigger_react_to_env(Ma),
|
|
|
|
|
{_, _, TheEpoch_3} = ?MGR:trigger_react_to_env(Mb),
|
|
|
|
|
{_, _, TheEpoch_3} = ?MGR:trigger_react_to_env(Mc),
|
|
|
|
@ -409,42 +417,114 @@ nonunanimous_setup_and_fix_test() ->
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- Proxies],
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
%% io:format(user, "\n+ Remove 'a' from the chain.\n", []),
|
|
|
|
|
%% io:format(user, "STEP: Remove 'a' from the chain.\n", []),
|
|
|
|
|
io:format(user, "NOTE: One INFO REPORT will follow.\n", []),
|
|
|
|
|
|
|
|
|
|
MembersDict4 = machi_projection:make_members_dict(tl(P_s)),
|
|
|
|
|
ok = machi_chain_manager1:set_chain_members(
|
|
|
|
|
Mb, ch_not_def_yet, TheEpoch_3, ap_mode, MembersDict4, []),
|
|
|
|
|
|
|
|
|
|
[begin
|
|
|
|
|
_ = ?MGR:trigger_react_to_env(Mgr),
|
|
|
|
|
ok
|
|
|
|
|
end || _ <- lists:seq(1, 7),
|
|
|
|
|
{Mgr,Proxy} <- [{Ma, Proxy_a}, {Mb, Proxy_b}, {Mc, Proxy_c}]],
|
|
|
|
|
%% {_, _, TheEpoch_4} = ?MGR:trigger_react_to_env(Ma),
|
|
|
|
|
Advance(),
|
|
|
|
|
{ok, {true, _}} = ?FLU_PC:wedge_status(Proxy_a),
|
|
|
|
|
{_, _, TheEpoch_4} = ?MGR:trigger_react_to_env(Mb),
|
|
|
|
|
{_, _, TheEpoch_4} = ?MGR:trigger_react_to_env(Mc),
|
|
|
|
|
[{ok, #projection_v1{upi=[b], repairing=[c]}} =
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- tl(Proxies)],
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
%% io:format(user, "\n+ Add a to the chain again.\n", []),
|
|
|
|
|
%% io:format(user, "STEP: Add a to the chain again (a is running).\n", []),
|
|
|
|
|
|
|
|
|
|
MembersDict5 = machi_projection:make_members_dict(P_s),
|
|
|
|
|
ok = machi_chain_manager1:set_chain_members(
|
|
|
|
|
Mb, ch_not_def_yet, TheEpoch_4, ap_mode, MembersDict5, []),
|
|
|
|
|
|
|
|
|
|
[begin
|
|
|
|
|
{_rr1, _rr2, TheEpoch} = ?MGR:trigger_react_to_env(Mgr),
|
|
|
|
|
ok
|
|
|
|
|
end || _ <- lists:seq(1, 7),
|
|
|
|
|
{Mgr,Proxy} <- [{Ma, Proxy_a}, {Mb, Proxy_b}, {Mc, Proxy_c}]],
|
|
|
|
|
Advance(),
|
|
|
|
|
{_, _, TheEpoch_5} = ?MGR:trigger_react_to_env(Ma),
|
|
|
|
|
{_, _, TheEpoch_5} = ?MGR:trigger_react_to_env(Mb),
|
|
|
|
|
{_, _, TheEpoch_5} = ?MGR:trigger_react_to_env(Mc),
|
|
|
|
|
[{ok, #projection_v1{upi=[b], repairing=[a,c]}} =
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- Proxies],
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
io:format(user, "STEP: Stop a while a chain member, advance b&c.\n", []),
|
|
|
|
|
|
|
|
|
|
ok = machi_flu_psup:stop_flu_package(a),
|
|
|
|
|
Advance(),
|
|
|
|
|
{_, _, TheEpoch_6} = ?MGR:trigger_react_to_env(Mb),
|
|
|
|
|
{_, _, TheEpoch_6} = ?MGR:trigger_react_to_env(Mc),
|
|
|
|
|
[{ok, #projection_v1{upi=[b], repairing=[c]}} =
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- tl(Proxies)],
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
io:format(user, "STEP: Remove 'a' from the chain.\n", []),
|
|
|
|
|
io:format(user, "NOTE: One INFO REPORT will follow.\n", []),
|
|
|
|
|
|
|
|
|
|
MembersDict7 = machi_projection:make_members_dict(tl(P_s)),
|
|
|
|
|
ok = machi_chain_manager1:set_chain_members(
|
|
|
|
|
Mb, ch_not_def_yet, TheEpoch_6, ap_mode, MembersDict7, []),
|
|
|
|
|
|
|
|
|
|
Advance(),
|
|
|
|
|
{_, _, TheEpoch_7} = ?MGR:trigger_react_to_env(Mb),
|
|
|
|
|
{_, _, TheEpoch_7} = ?MGR:trigger_react_to_env(Mc),
|
|
|
|
|
[{ok, #projection_v1{upi=[b], repairing=[c]}} =
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- tl(Proxies)],
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
io:format(user, "STEP: Start a, advance.\n", []),
|
|
|
|
|
|
|
|
|
|
[{ok,_}=machi_flu_psup:start_flu_package(Name, Port, Dir, Opts) ||
|
|
|
|
|
{Name,Port,Dir} <- [hd(FluInfo)]],
|
|
|
|
|
Advance(),
|
|
|
|
|
{ok, {true, _}} = ?FLU_PC:wedge_status(Proxy_a),
|
|
|
|
|
{ok, {false, EpochID_8}} = ?FLU_PC:wedge_status(Proxy_b),
|
|
|
|
|
{ok, {false, EpochID_8}} = ?FLU_PC:wedge_status(Proxy_c),
|
|
|
|
|
[{ok, #projection_v1{upi=[b], repairing=[c]}} =
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- tl(Proxies)],
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
io:format(user, "STEP: Stop a, delete a's data, leave it stopped\n", []),
|
|
|
|
|
ok = machi_flu_psup:stop_flu_package(a),
|
|
|
|
|
Advance(),
|
|
|
|
|
{_,_,Dir_a} = hd(FluInfo),
|
|
|
|
|
[machi_flu1_test:clean_up_data_dir(Dir) || {_,_,Dir} <- [hd(FluInfo)]],
|
|
|
|
|
{ok, {false, _}} = ?FLU_PC:wedge_status(Proxy_b),
|
|
|
|
|
{ok, {false, _}} = ?FLU_PC:wedge_status(Proxy_c),
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
io:format(user, "STEP: Add a to the chain again (a is stopped).\n", []),
|
|
|
|
|
|
|
|
|
|
MembersDict9 = machi_projection:make_members_dict(P_s),
|
|
|
|
|
{_, _, TheEpoch_9} = ?MGR:trigger_react_to_env(Mb),
|
|
|
|
|
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),
|
|
|
|
|
[{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]}} =
|
|
|
|
|
?FLU_PC:read_latest_projection(Pxy, private) || Pxy <- Proxies],
|
|
|
|
|
ok
|
|
|
|
|
after
|
|
|
|
|
exit(SupPid, normal),
|
|
|
|
|