From 297d29c79bc7f9e817abd24f5fa670599862cd38 Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Tue, 7 Jul 2015 23:03:14 +0900 Subject: [PATCH] Finish fixups to the chmgr state transition checking --- test/machi_chain_manager1_converge_demo.erl | 2 +- test/machi_chain_manager1_pulse.erl | 43 +++++++++++++-------- test/machi_chain_manager1_test.erl | 13 +++---- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/test/machi_chain_manager1_converge_demo.erl b/test/machi_chain_manager1_converge_demo.erl index 2ddeb30..37b2889 100644 --- a/test/machi_chain_manager1_converge_demo.erl +++ b/test/machi_chain_manager1_converge_demo.erl @@ -154,7 +154,7 @@ convergence_demo_testfun(NumFLUs, MgrOpts0) -> %% Faster test startup, commented: timer:sleep(3000), TcpPort = 62877, - ok = filelib:ensure_dir("/tmp/c/data.a"), + ok = filelib:ensure_dir("/tmp/c/not-used"), FluInfo = [{a,TcpPort+0,"/tmp/c/data.a"}, {b,TcpPort+1,"/tmp/c/data.b"}, {c,TcpPort+2,"/tmp/c/data.c"}, {d,TcpPort+3,"/tmp/c/data.d"}, {e,TcpPort+4,"/tmp/c/data.e"}, {f,TcpPort+5,"/tmp/c/data.f"}], diff --git a/test/machi_chain_manager1_pulse.erl b/test/machi_chain_manager1_pulse.erl index 968be5c..48a0062 100644 --- a/test/machi_chain_manager1_pulse.erl +++ b/test/machi_chain_manager1_pulse.erl @@ -106,15 +106,15 @@ postcondition(_S, {call, _, _Func, _Args}, _Res) -> all_list_extra() -> [ %% Genenerators assume that this list is at least 2 items {#p_srvr{name=a, address="localhost", port=7400, - props=[{chmgr, a_chmgr}]}, "./data.pulse.a"} + props=[{chmgr, a_chmgr}]}, "/tmp/c/data.pulse.a"} , {#p_srvr{name=b, address="localhost", port=7401, - props=[{chmgr, b_chmgr}]}, "./data.pulse.b"} + props=[{chmgr, b_chmgr}]}, "/tmp/c/data.pulse.b"} , {#p_srvr{name=c, address="localhost", port=7402, - props=[{chmgr, c_chmgr}]}, "./data.pulse.c"} + props=[{chmgr, c_chmgr}]}, "/tmp/c//data.pulse.c"} , {#p_srvr{name=d, address="localhost", port=7403, - props=[{chmgr, d_chmgr}]}, "./data.pulse.d"} + props=[{chmgr, d_chmgr}]}, "/tmp/c/data.pulse.d"} , {#p_srvr{name=e, address="localhost", port=7404, - props=[{chmgr, e_chmgr}]}, "./data.pulse.e"} + props=[{chmgr, e_chmgr}]}, "/tmp/c/data.pulse.e"} ]. all_list() -> @@ -126,7 +126,10 @@ setup(Num, Seed) -> All_list = lists:sublist(all_list(), Num), All_listE = lists:sublist(all_list_extra(), Num), %% shutdown_hard() has taken care of killing all relevant procs. - [machi_flu1_test:clean_up_data_dir(Dir) || {_P, Dir} <- All_listE], + [begin + machi_flu1_test:clean_up_data_dir(Dir), + filelib:ensure_dir(Dir ++ "/not-used") + end || {_P, Dir} <- All_listE], ?QC_FMT(",z~w", [?LINE]), %% Start partition simulator @@ -318,7 +321,11 @@ prop_pulse() -> %% written during any given epoch, confirm that all chain %% members appear in only one unique chain, i.e., the sets of %% unique chains are disjoint. - AllDisjointP = ?MGRTEST:all_reports_are_disjoint(Report), + {AllDisjointP, AllDisjointDetail} = + case ?MGRTEST:all_reports_are_disjoint(Report) of + true -> {true, true}; + Else -> {false, Else} + end, %% For each chain transition experienced by a particular FLU, %% confirm that each state transition is OK. @@ -331,29 +338,31 @@ prop_pulse() -> {_LastEpoch, {ok_disjoint, LastRepXs}} = lists:last(Report), %% TODO: Check that we've converged to a single chain with no repairs. - SingleChainNoRepair = case LastRepXs of - [{_UPI,[]}] -> - true; - _ -> - false - end, + {SingleChainNoRepair_p, SingleChainNoRepairDetail} = + case LastRepXs of + [LastUPI] when length(LastUPI) == S2#state.num_pids -> + {true, true}; + _ -> + {false, LastRepXs} + end, ok = shutdown_hard(), ?WHENFAIL( begin + ?QC_FMT("PrivProjs = ~p\n", [PrivProjs]), + ?QC_FMT("Report = ~p\n", [Report]), ?QC_FMT("Cmds = ~p\n", [Cmds]), ?QC_FMT("Res = ~p\n", [Res]), ?QC_FMT("Diag = ~s\n", [Diag]), - ?QC_FMT("Report = ~p\n", [Report]), - ?QC_FMT("PrivProjs = ~p\n", [PrivProjs]), ?QC_FMT("Sane = ~p\n", [Sane]), - ?QC_FMT("SingleChainNoRepair failure =\n ~p\n", [SingleChainNoRepair]) + ?QC_FMT("AllDisjointDetail = ~p\n", [AllDisjointDetail]), + ?QC_FMT("SingleChainNoRepair failure = ~p\n", [SingleChainNoRepairDetail]) %% ,erlang:halt(0) end, conjunction([{res, Res == true orelse Res == ok}, {all_disjoint, AllDisjointP}, {sane, SaneP}, - {single_chain_no_repair, SingleChainNoRepair} + {single_chain_no_repair, SingleChainNoRepair_p} ])) end)). diff --git a/test/machi_chain_manager1_test.erl b/test/machi_chain_manager1_test.erl index a7265aa..6a774b0 100644 --- a/test/machi_chain_manager1_test.erl +++ b/test/machi_chain_manager1_test.erl @@ -54,7 +54,7 @@ %% {'bummer_NOT_DISJOINT', {flat(), summaries()} %% unique_upi_repair_lists(): list(upi_and_repair_lists_concatenated()) %% flat(): debugging term; any duplicate in this list is an invalid FLU. -%% summaries(): list(ProjectionSummary:string()) +%% summaries(): list({FLU, ProjectionSummary:string() | 'not_in_this_epoch'}) %% %% Example: %% @@ -98,15 +98,14 @@ unanimous_report2(FLU_Projs) -> Proj#projection_v1.epoch_csum} || {_FLUname, Proj} <- FLU_Projs, is_record(Proj, projection_v1)], - UniqueUPIsRepairs = lists:usort([{UPI,Repairing} || - {UPI, Repairing, _CSum} <- UPI_R_Sums]), - if length(UniqueUPIsRepairs) =< 1 -> - {ok_disjoint, UniqueUPIsRepairs}; + UniqueUPIs = lists:usort([UPI || {UPI, _Repairing, _CSum} <- UPI_R_Sums]), + if length(UniqueUPIs) =< 1 -> + {ok_disjoint, UniqueUPIs}; true -> - Flat = lists:flatten([UPI++Rep || {UPI,Rep} <- UniqueUPIsRepairs]), + Flat = lists:flatten(UniqueUPIs), case lists:usort(Flat) == lists:sort(Flat) of true -> - {ok_disjoint, UniqueUPIsRepairs}; + {ok_disjoint, UniqueUPIs}; false -> {bummer_NOT_DISJOINT, {lists:sort(Flat), ProjsSumms}} end