Make test start up more reliable
This commit is contained in:
parent
d9ede473dd
commit
5926cef44a
3 changed files with 87 additions and 38 deletions
|
@ -39,10 +39,10 @@ clean_up_data_dir(DataDir) ->
|
||||||
_ = file:del_dir(DataDir),
|
_ = file:del_dir(DataDir),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
setup_test_flu(RegName, TcpPort, DataDir) ->
|
xxx_setup_test_flu(RegName, TcpPort, DataDir) ->
|
||||||
setup_test_flu(RegName, TcpPort, DataDir, []).
|
xxx_setup_test_flu(RegName, TcpPort, DataDir, []).
|
||||||
|
|
||||||
setup_test_flu(RegName, TcpPort, DataDir, Props) ->
|
xxx_setup_test_flu(RegName, TcpPort, DataDir, Props) ->
|
||||||
case proplists:get_value(save_data_dir, Props) of
|
case proplists:get_value(save_data_dir, Props) of
|
||||||
true ->
|
true ->
|
||||||
ok;
|
ok;
|
||||||
|
@ -57,6 +57,38 @@ setup_test_flu(RegName, TcpPort, DataDir, Props) ->
|
||||||
timer:sleep(10),
|
timer:sleep(10),
|
||||||
FLU1.
|
FLU1.
|
||||||
|
|
||||||
|
start_flu_package(RegName, TcpPort, DataDir) ->
|
||||||
|
start_flu_package(RegName, TcpPort, DataDir, []).
|
||||||
|
|
||||||
|
start_flu_package(RegName, TcpPort, DataDir, Props) ->
|
||||||
|
case proplists:get_value(save_data_dir, Props) of
|
||||||
|
true ->
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
clean_up_data_dir(DataDir)
|
||||||
|
end,
|
||||||
|
|
||||||
|
maybe_start_sup(),
|
||||||
|
machi_flu_psup:start_flu_package(RegName, TcpPort, DataDir, Props).
|
||||||
|
|
||||||
|
stop_flu_package(FluName) ->
|
||||||
|
machi_flu_psup:stop_flu_package(FluName),
|
||||||
|
Pid = whereis(machi_sup),
|
||||||
|
exit(Pid, normal),
|
||||||
|
%% evil but we have to let stuff shutdown
|
||||||
|
timer:sleep(10).
|
||||||
|
|
||||||
|
maybe_start_sup() ->
|
||||||
|
case whereis(machi_sup) of
|
||||||
|
undefined ->
|
||||||
|
machi_sup:start_link(),
|
||||||
|
%% evil but we have to let stuff start up
|
||||||
|
timer:sleep(10),
|
||||||
|
maybe_start_sup();
|
||||||
|
Pid -> Pid
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
-ifndef(PULSE).
|
-ifndef(PULSE).
|
||||||
|
|
||||||
flu_smoke_test() ->
|
flu_smoke_test() ->
|
||||||
|
@ -67,7 +99,7 @@ flu_smoke_test() ->
|
||||||
BadPrefix = BadFile = "no/good",
|
BadPrefix = BadFile = "no/good",
|
||||||
|
|
||||||
W_props = [{initial_wedged, false}],
|
W_props = [{initial_wedged, false}],
|
||||||
FLU1 = setup_test_flu(smoke_flu, TcpPort, DataDir, W_props),
|
start_flu_package(smoke_flu, TcpPort, DataDir, W_props),
|
||||||
try
|
try
|
||||||
Msg = "Hello, world!",
|
Msg = "Hello, world!",
|
||||||
Msg = ?FLU_C:echo(Host, TcpPort, Msg),
|
Msg = ?FLU_C:echo(Host, TcpPort, Msg),
|
||||||
|
@ -158,7 +190,7 @@ flu_smoke_test() ->
|
||||||
ok = ?FLU_C:quit(?FLU_C:connect(#p_srvr{address=Host,
|
ok = ?FLU_C:quit(?FLU_C:connect(#p_srvr{address=Host,
|
||||||
port=TcpPort}))
|
port=TcpPort}))
|
||||||
after
|
after
|
||||||
ok = ?FLU:stop(FLU1)
|
stop_flu_package(smoke_flu)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
flu_projection_smoke_test() ->
|
flu_projection_smoke_test() ->
|
||||||
|
@ -166,14 +198,14 @@ flu_projection_smoke_test() ->
|
||||||
TcpPort = 32959,
|
TcpPort = 32959,
|
||||||
DataDir = "./data",
|
DataDir = "./data",
|
||||||
|
|
||||||
FLU1 = setup_test_flu(projection_test_flu, TcpPort, DataDir),
|
start_flu_package(projection_test_flu, TcpPort, DataDir),
|
||||||
try
|
try
|
||||||
[ok = flu_projection_common(Host, TcpPort, T) ||
|
[ok = flu_projection_common(Host, TcpPort, T) ||
|
||||||
T <- [public, private] ]
|
T <- [public, private] ]
|
||||||
%% , {ok, {false, EpochID1}} = ?FLU_C:wedge_status(Host, TcpPort),
|
%% , {ok, {false, EpochID1}} = ?FLU_C:wedge_status(Host, TcpPort),
|
||||||
%% io:format(user, "EpochID1 ~p\n", [EpochID1])
|
%% io:format(user, "EpochID1 ~p\n", [EpochID1])
|
||||||
after
|
after
|
||||||
ok = ?FLU:stop(FLU1)
|
stop_flu_package(projection_test_flu)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
flu_projection_common(Host, TcpPort, T) ->
|
flu_projection_common(Host, TcpPort, T) ->
|
||||||
|
@ -204,7 +236,7 @@ bad_checksum_test() ->
|
||||||
DataDir = "./data",
|
DataDir = "./data",
|
||||||
|
|
||||||
Opts = [{initial_wedged, false}],
|
Opts = [{initial_wedged, false}],
|
||||||
FLU1 = setup_test_flu(projection_test_flu, TcpPort, DataDir, Opts),
|
start_flu_package(projection_test_flu, TcpPort, DataDir, Opts),
|
||||||
try
|
try
|
||||||
Prefix = <<"some prefix">>,
|
Prefix = <<"some prefix">>,
|
||||||
Chunk1 = <<"yo yo yo">>,
|
Chunk1 = <<"yo yo yo">>,
|
||||||
|
@ -214,7 +246,7 @@ bad_checksum_test() ->
|
||||||
Prefix, Chunk1_badcs),
|
Prefix, Chunk1_badcs),
|
||||||
ok
|
ok
|
||||||
after
|
after
|
||||||
ok = ?FLU:stop(FLU1)
|
stop_flu_package(projection_test_flu)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
witness_test() ->
|
witness_test() ->
|
||||||
|
@ -223,7 +255,7 @@ witness_test() ->
|
||||||
DataDir = "./data",
|
DataDir = "./data",
|
||||||
|
|
||||||
Opts = [{initial_wedged, false}, {witness_mode, true}],
|
Opts = [{initial_wedged, false}, {witness_mode, true}],
|
||||||
FLU1 = setup_test_flu(projection_test_flu, TcpPort, DataDir, Opts),
|
start_flu_package(projection_test_flu, TcpPort, DataDir, Opts),
|
||||||
try
|
try
|
||||||
Prefix = <<"some prefix">>,
|
Prefix = <<"some prefix">>,
|
||||||
Chunk1 = <<"yo yo yo">>,
|
Chunk1 = <<"yo yo yo">>,
|
||||||
|
@ -255,7 +287,7 @@ witness_test() ->
|
||||||
|
|
||||||
ok
|
ok
|
||||||
after
|
after
|
||||||
ok = ?FLU:stop(FLU1)
|
stop_flu_package(projection_test_flu)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% The purpose of timing_pb_encoding_test_ and timing_bif_encoding_test_ is
|
%% The purpose of timing_pb_encoding_test_ and timing_bif_encoding_test_ is
|
||||||
|
|
|
@ -29,12 +29,11 @@
|
||||||
-include("machi_projection.hrl").
|
-include("machi_projection.hrl").
|
||||||
|
|
||||||
smoke_test() ->
|
smoke_test() ->
|
||||||
{ok, SupPid} = machi_flu_sup:start_link(),
|
|
||||||
PortBase = 64820,
|
PortBase = 64820,
|
||||||
Dir = "./data.a",
|
Dir = "./data.a",
|
||||||
Os = [{ignore_stability_time, true}, {active_mode, false}],
|
Os = [{ignore_stability_time, true}, {active_mode, false}],
|
||||||
os:cmd("rm -rf " ++ Dir),
|
os:cmd("rm -rf " ++ Dir),
|
||||||
{ok,Yo}=machi_flu_psup:start_flu_package(a, PortBase, "./data.a", Os),
|
machi_flu1_test:start_flu_package(a, PortBase, "./data.a", Os),
|
||||||
|
|
||||||
try
|
try
|
||||||
P1 = machi_projection:new(1, a, [], [], [], [], []),
|
P1 = machi_projection:new(1, a, [], [], [], [], []),
|
||||||
|
@ -59,9 +58,7 @@ smoke_test() ->
|
||||||
|
|
||||||
ok
|
ok
|
||||||
after
|
after
|
||||||
machi_flu_psup:stop_flu_package(a),
|
machi_flu1_test:stop_flu_package(a)
|
||||||
exit(SupPid, normal),
|
|
||||||
timer:sleep(10)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-endif. % !PULSE
|
-endif. % !PULSE
|
||||||
|
|
|
@ -37,9 +37,8 @@ api_smoke_test() ->
|
||||||
DataDir = "./data.api_smoke_flu",
|
DataDir = "./data.api_smoke_flu",
|
||||||
W_props = [{initial_wedged, false}],
|
W_props = [{initial_wedged, false}],
|
||||||
Prefix = <<"prefix">>,
|
Prefix = <<"prefix">>,
|
||||||
FLU1 = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
|
||||||
W_props),
|
machi_flu1_test:start_flu_package(RegName, TcpPort, DataDir, W_props),
|
||||||
erase(flu_pid),
|
|
||||||
|
|
||||||
try
|
try
|
||||||
I = #p_srvr{name=RegName, address=Host, port=TcpPort},
|
I = #p_srvr{name=RegName, address=Host, port=TcpPort},
|
||||||
|
@ -50,14 +49,13 @@ api_smoke_test() ->
|
||||||
FakeEpoch, Prefix, <<"data">>,
|
FakeEpoch, Prefix, <<"data">>,
|
||||||
infinity) || _ <- lists:seq(1,5)],
|
infinity) || _ <- lists:seq(1,5)],
|
||||||
%% Stop the FLU, what happens?
|
%% Stop the FLU, what happens?
|
||||||
machi_flu1:stop(FLU1),
|
machi_flu1_test:stop_flu_package(RegName),
|
||||||
[{error,partition} = ?MUT:append_chunk(Prox1,
|
[{error,partition} = ?MUT:append_chunk(Prox1,
|
||||||
FakeEpoch, Prefix, <<"data-stopped1">>,
|
FakeEpoch, Prefix, <<"data-stopped1">>,
|
||||||
infinity) || _ <- lists:seq(1,3)],
|
infinity) || _ <- lists:seq(1,3)],
|
||||||
%% Start the FLU again, we should be able to do stuff immediately
|
%% Start the FLU again, we should be able to do stuff immediately
|
||||||
FLU1b = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
machi_flu1_test:start_flu_package(RegName, TcpPort, DataDir,
|
||||||
[save_data_dir|W_props]),
|
[save_data_dir|W_props]),
|
||||||
put(flu_pid, FLU1b),
|
|
||||||
MyChunk = <<"my chunk data">>,
|
MyChunk = <<"my chunk data">>,
|
||||||
{ok, {MyOff,MySize,MyFile}} =
|
{ok, {MyOff,MySize,MyFile}} =
|
||||||
?MUT:append_chunk(Prox1, FakeEpoch, Prefix, MyChunk,
|
?MUT:append_chunk(Prox1, FakeEpoch, Prefix, MyChunk,
|
||||||
|
@ -85,23 +83,50 @@ api_smoke_test() ->
|
||||||
{error, no_such_file} = ?MUT:checksum_list(Prox1, FakeEpoch, BadFile),
|
{error, no_such_file} = ?MUT:checksum_list(Prox1, FakeEpoch, BadFile),
|
||||||
{ok, [_|_]} = ?MUT:list_files(Prox1, FakeEpoch),
|
{ok, [_|_]} = ?MUT:list_files(Prox1, FakeEpoch),
|
||||||
{ok, {false, _}} = ?MUT:wedge_status(Prox1),
|
{ok, {false, _}} = ?MUT:wedge_status(Prox1),
|
||||||
{ok, FakeEpoch} = ?MUT:get_latest_epochid(Prox1, public),
|
%% Per Scott, comment this out until he can take a look
|
||||||
{error, not_written} = ?MUT:read_latest_projection(Prox1, public),
|
%%
|
||||||
|
%% machi_proxy_flu1_client_test: api_smoke_test...*failed*
|
||||||
|
%% in function machi_proxy_flu1_client_test:api_smoke_test/0 (test/machi_proxy_flu1_client_test.erl, line 88)
|
||||||
|
%% **error:{badmatch,{ok,{0,<<55,96,141,95,149,143,223,4,14,235,88,15,47,...>>}}}
|
||||||
|
%%
|
||||||
|
%% {ok, FakeEpoch} = ?MUT:get_latest_epochid(Prox1, public),
|
||||||
|
%% in function machi_proxy_flu1_client_test:api_smoke_test/0 (test/machi_proxy_flu1_client_test.erl, line 89)
|
||||||
|
%% **error:{badmatch,{ok,{projection_v1,0,
|
||||||
|
%% <<55,96,141,95,149,143,223,4,14,235,88,15,...>>,
|
||||||
|
%% api_smoke_flu,[],[],
|
||||||
|
%% {1444,330495,507785},
|
||||||
|
%% ap_mode,[],[],[],[],[],[]}}}
|
||||||
|
%% {error, not_written} = ?MUT:read_latest_projection(Prox1, public),
|
||||||
{error, not_written} = ?MUT:read_projection(Prox1, public, 44),
|
{error, not_written} = ?MUT:read_projection(Prox1, public, 44),
|
||||||
P_a = #p_srvr{name=a, address="localhost", port=6622},
|
P_a = #p_srvr{name=a, address="localhost", port=6622},
|
||||||
P1 = machi_projection:new(1, a, [P_a], [], [a], [], []),
|
P1 = machi_projection:new(1, a, [P_a], [], [a], [], []),
|
||||||
ok = ?MUT:write_projection(Prox1, public, P1),
|
ok = ?MUT:write_projection(Prox1, public, P1),
|
||||||
{ok, P1} = ?MUT:read_projection(Prox1, public, 1),
|
{ok, P1} = ?MUT:read_projection(Prox1, public, 1),
|
||||||
{ok, [P1]} = ?MUT:get_all_projections(Prox1, public),
|
%%
|
||||||
{ok, [1]} = ?MUT:list_all_projections(Prox1, public),
|
%% in function machi_proxy_flu1_client_test:api_smoke_test/0 (test/machi_proxy_flu1_client_test.erl, line 107)
|
||||||
|
%% **error:{badmatch,{ok,[{projection_v1,0,
|
||||||
|
%% <<55,96,141,95,149,143,223,4,14,235,88,...>>,
|
||||||
|
%% api_smoke_flu,[],[],
|
||||||
|
%% {1444,330601,749713},
|
||||||
|
%% ap_mode,[],[],[],[],[],[]},
|
||||||
|
%% {projection_v1,1,
|
||||||
|
%% <<156,33,125,69,126,173,34,245,78,95,...>>,
|
||||||
|
%% a,
|
||||||
|
%% [a],
|
||||||
|
%% [],
|
||||||
|
%% {1444,330601,820732},
|
||||||
|
%% ap_mode,
|
||||||
|
%% [a],
|
||||||
|
%% [],[],[],[],...}]}}
|
||||||
|
%% {ok, [P1]} = ?MUT:get_all_projections(Prox1, public),
|
||||||
|
%% {ok, [1]} = ?MUT:list_all_projections(Prox1, public),
|
||||||
|
|
||||||
ok
|
ok
|
||||||
after
|
after
|
||||||
_ = (catch ?MUT:quit(Prox1))
|
_ = (catch ?MUT:quit(Prox1))
|
||||||
end
|
end
|
||||||
after
|
after
|
||||||
(catch machi_flu1:stop(FLU1)),
|
(catch machi_flu1_test:stop_flu_package(RegName))
|
||||||
(catch machi_flu1:stop(get(flu_pid)))
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
flu_restart_test() ->
|
flu_restart_test() ->
|
||||||
|
@ -110,11 +135,7 @@ flu_restart_test() ->
|
||||||
TcpPort = 57125,
|
TcpPort = 57125,
|
||||||
DataDir = "./data.api_smoke_flu2",
|
DataDir = "./data.api_smoke_flu2",
|
||||||
W_props = [{initial_wedged, false}],
|
W_props = [{initial_wedged, false}],
|
||||||
erase(flu_pid),
|
machi_flu1_test:start_flu_package(RegName, TcpPort, DataDir, W_props),
|
||||||
put(flu_pid, []),
|
|
||||||
FLU1 = machi_flu1_test:setup_test_flu(RegName, TcpPort, DataDir,
|
|
||||||
W_props),
|
|
||||||
put(flu_pid, [FLU1|get(flu_pid)]),
|
|
||||||
|
|
||||||
try
|
try
|
||||||
I = #p_srvr{name=RegName, address=Host, port=TcpPort},
|
I = #p_srvr{name=RegName, address=Host, port=TcpPort},
|
||||||
|
@ -137,7 +158,7 @@ flu_restart_test() ->
|
||||||
{ok, EpochID} = ?MUT:get_epoch_id(Prox1),
|
{ok, EpochID} = ?MUT:get_epoch_id(Prox1),
|
||||||
{ok, EpochID} = ?MUT:get_latest_epochid(Prox1, public),
|
{ok, EpochID} = ?MUT:get_latest_epochid(Prox1, public),
|
||||||
{ok, EpochID} = ?MUT:get_latest_epochid(Prox1, private),
|
{ok, EpochID} = ?MUT:get_latest_epochid(Prox1, private),
|
||||||
ok = machi_flu1:stop(FLU1), timer:sleep(50),
|
ok = machi_flu1_test:stop_flu_package(RegName), timer:sleep(50),
|
||||||
|
|
||||||
%% Now that the last proxy op was successful and only
|
%% Now that the last proxy op was successful and only
|
||||||
%% after did we stop the FLU, let's check that both the
|
%% after did we stop the FLU, let's check that both the
|
||||||
|
@ -295,14 +316,13 @@ flu_restart_test() ->
|
||||||
],
|
],
|
||||||
|
|
||||||
[begin
|
[begin
|
||||||
FLU2 = machi_flu1_test:setup_test_flu(
|
machi_flu1_test:start_flu_package(
|
||||||
RegName, TcpPort, DataDir,
|
RegName, TcpPort, DataDir,
|
||||||
[save_data_dir|W_props]),
|
[save_data_dir|W_props]),
|
||||||
put(flu_pid, [FLU2|get(flu_pid)]),
|
|
||||||
_ = Fun(line),
|
_ = Fun(line),
|
||||||
ok = Fun(run),
|
ok = Fun(run),
|
||||||
ok = Fun(run),
|
ok = Fun(run),
|
||||||
ok = machi_flu1:stop(FLU2),
|
ok = machi_flu1_test:stop_flu_package(RegName),
|
||||||
{error, partition} = Fun(stop),
|
{error, partition} = Fun(stop),
|
||||||
{error, partition} = Fun(stop),
|
{error, partition} = Fun(stop),
|
||||||
ok
|
ok
|
||||||
|
@ -312,7 +332,7 @@ flu_restart_test() ->
|
||||||
_ = (catch ?MUT:quit(Prox1))
|
_ = (catch ?MUT:quit(Prox1))
|
||||||
end
|
end
|
||||||
after
|
after
|
||||||
[catch machi_flu1:stop(Pid) || Pid <- get(flu_pid)]
|
(catch machi_flu1_test:stop_flu_package(RegName))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-endif. % !PULSE
|
-endif. % !PULSE
|
||||||
|
|
Loading…
Reference in a new issue