Add missing test cleanups #40

Merged
shino merged 3 commits from ss/missing-test-cleanups into master 2015-11-05 07:16:40 +00:00
4 changed files with 28 additions and 14 deletions

View file

@ -8,6 +8,7 @@ ifeq ($(REBAR),)
REBAR = $(BASE_DIR)/rebar REBAR = $(BASE_DIR)/rebar
endif endif
OVERLAY_VARS ?= OVERLAY_VARS ?=
EUNIT_OPTS = -v
.PHONY: rel deps package pkgclean edoc .PHONY: rel deps package pkgclean edoc

View file

@ -265,7 +265,8 @@ init([P_srvr_list, Opts]) ->
handle_call({req, Req}, From, S) -> handle_call({req, Req}, From, S) ->
handle_call2(Req, From, update_proj(S)); handle_call2(Req, From, update_proj(S));
handle_call(quit, _From, S) -> handle_call(quit, _From, #state{members_dict=MembersDict}=S) ->
?FLU_PC:stop_proxies(MembersDict),
{stop, normal, ok, S}; {stop, normal, ok, S};
handle_call(_Request, _From, S) -> handle_call(_Request, _From, S) ->
Reply = whaaaaaaaaaaaaaaaaaaaa, Reply = whaaaaaaaaaaaaaaaaaaaa,

View file

@ -233,6 +233,7 @@ prop_repair(Verbose) ->
?V("==== Start post operations, stabilize and confirm results~n", []), ?V("==== Start post operations, stabilize and confirm results~n", []),
{_Res2, S2} = stabilize(commands_len(Cmds), SetupState), {_Res2, S2} = stabilize(commands_len(Cmds), SetupState),
{Dataloss, Critical} = confirm_result(S2), {Dataloss, Critical} = confirm_result(S2),
_ = cleanup(SetupState),
pretty_commands( pretty_commands(
?MODULE, Cmds, {H, S1, Res}, ?MODULE, Cmds, {H, S1, Res},
aggregate(with_title(cmds), command_names(Cmds), aggregate(with_title(cmds), command_names(Cmds),
@ -270,6 +271,9 @@ prop_repair_par(Verbose) ->
?V("Res=~w~n", [Res]), ?V("Res=~w~n", [Res]),
{undefined, undefined} {undefined, undefined}
end, end,
_ = cleanup(SetupState),
%% Process is leaking? This log line can be removed after fix.
?V("process_count=~w~n", [erlang:system_info(process_count)]),
pretty_commands( pretty_commands(
?MODULE, Cmds, {Seq, Par, Res}, ?MODULE, Cmds, {Seq, Par, Res},
aggregate(with_title(cmds), command_names(Cmds), aggregate(with_title(cmds), command_names(Cmds),
@ -352,16 +356,18 @@ setup_chain(Num, Seed, Verbose) ->
%% Don't wait for complete chain. Even partialy completed, the chain %% Don't wait for complete chain. Even partialy completed, the chain
%% should work fine. Right? %% should work fine. Right?
wait_until_stable(chain_state_all_ok(FLUNames), FLUNames, MgrNames, wait_until_stable(chain_state_all_ok(FLUNames), FLUNames, MgrNames,
State#state.fc_list, 20), State#state.fc_list, 20, Verbose),
State. State.
%% Post commands %% Post commands
stabilize(0, S) -> stabilize(0, S) ->
{ok, S}; {ok, S};
stabilize(_CmdsLen, #state{flu_names=FLUNames, mgr_names=MgrNames, fc_list=FCList}=S) -> stabilize(_CmdsLen, #state{flu_names=FLUNames, mgr_names=MgrNames,
fc_list=FCList, verbose=Verbose}=S) ->
machi_partition_simulator:no_partitions(), machi_partition_simulator:no_partitions(),
wait_until_stable(chain_state_all_ok(FLUNames), FLUNames, MgrNames, FCList, 100), wait_until_stable(chain_state_all_ok(FLUNames), FLUNames, MgrNames,
FCList, 100, Verbose),
{ok, S}. {ok, S}.
chain_state_all_ok(FLUNames) -> chain_state_all_ok(FLUNames) ->
@ -420,6 +426,11 @@ assert_chunk(C, {Off, Len, FileName}=Key, Bin) ->
{error, Other} {error, Other}
end. end.
cleanup(#state{fc_list=FCList, cr_list=CRList}=_S) ->
[catch machi_proxy_flu1_client:quit(FC) || FC <- FCList],
[catch machi_cr_client:quit(CR) || CR <- CRList],
_ = shutdown_hard().
%% Internal utilities %% Internal utilities
eqc_verbose() -> eqc_verbose() ->
@ -505,26 +516,26 @@ tick_fun(FLUNames, MgrNames, Parent) ->
end || {ThePid, M_name} <- Pids] end || {ThePid, M_name} <- Pids]
end. end.
wait_until_stable(ExpectedChainState, FLUNames, MgrNames, FCList) -> wait_until_stable(ExpectedChainState, FLUNames, MgrNames, FCList, Verbose) ->
wait_until_stable(ExpectedChainState, FLUNames, MgrNames, FCList, 20). wait_until_stable(ExpectedChainState, FLUNames, MgrNames, FCList, 20, Verbose).
wait_until_stable(ExpectedChainState, FLUNames, MgrNames, FCList, Retries) -> wait_until_stable(ExpectedChainState, FLUNames, MgrNames, FCList, Retries, Verbose) ->
TickFun = tick_fun(FLUNames, MgrNames, self()), TickFun = tick_fun(FLUNames, MgrNames, self()),
wait_until_stable1(ExpectedChainState, TickFun, FCList, Retries). wait_until_stable1(ExpectedChainState, TickFun, FCList, Retries, Verbose).
wait_until_stable1(_ExpectedChainState, _TickFun, FCList, 0) -> wait_until_stable1(_ExpectedChainState, _TickFun, FCList, 0, _Verbose) ->
?V(" [ERROR] wait_until_stable failed.... : ~p~n", [chain_state(FCList)]), ?V(" [ERROR] wait_until_stable failed.... : ~p~n", [chain_state(FCList)]),
false; false;
wait_until_stable1(ExpectedChainState, TickFun, FCList, Reties) -> wait_until_stable1(ExpectedChainState, TickFun, FCList, Reties, Verbose) ->
[TickFun(3, 0, 100) || _ <- lists:seq(1, 3)], [TickFun(3, 0, 100) || _ <- lists:seq(1, 3)],
Normalized = normalize_chain_state(chain_state(FCList)), Normalized = normalize_chain_state(chain_state(FCList)),
case Normalized of case Normalized of
ExpectedChainState -> ExpectedChainState ->
?V(" Got stable chain: ~w~n", [chain_state(FCList)]), [?V(" Got stable chain: ~w~n", [chain_state(FCList)]) || Verbose],
true; true;
_ -> _ ->
?V(" NOT YET stable chain: ~w~n", [chain_state(FCList)]), [?V(" NOT YET stable chain: ~w~n", [chain_state(FCList)]) || Verbose],
wait_until_stable1(ExpectedChainState, TickFun, FCList, Reties-1) wait_until_stable1(ExpectedChainState, TickFun, FCList, Reties-1, Verbose)
end. end.
normalize_chain_state(ChainState) -> normalize_chain_state(ChainState) ->

View file

@ -27,6 +27,7 @@
REBAR ?= ./rebar REBAR ?= ./rebar
REVISION ?= $(shell git rev-parse --short HEAD) REVISION ?= $(shell git rev-parse --short HEAD)
PROJECT ?= $(shell basename `find src -name "*.app.src"` .app.src) PROJECT ?= $(shell basename `find src -name "*.app.src"` .app.src)
EUNIT_OPTS ?=
.PHONY: compile-no-deps test docs xref dialyzer-run dialyzer-quick dialyzer \ .PHONY: compile-no-deps test docs xref dialyzer-run dialyzer-quick dialyzer \
cleanplt upload-docs cleanplt upload-docs
@ -35,7 +36,7 @@ compile-no-deps:
${REBAR} compile skip_deps=true ${REBAR} compile skip_deps=true
test: compile test: compile
${REBAR} eunit skip_deps=true ${REBAR} ${EUNIT_OPTS} eunit skip_deps=true
upload-docs: docs upload-docs: docs
@if [ -z "${BUCKET}" -o -z "${PROJECT}" -o -z "${REVISION}" ]; then \ @if [ -z "${BUCKET}" -o -z "${PROJECT}" -o -z "${REVISION}" ]; then \