Make CI: Have ct_master return the test results
Instead of having a CT hook just to know whether our tests failed.
This commit is contained in:
		
							parent
							
								
									dddf917378
								
							
						
					
					
						commit
						655caf6d1a
					
				| 
						 | 
				
			
			@ -239,22 +239,16 @@ define ct_master.erl
 | 
			
		|||
	peer:call(Pid2, persistent_term, put, [rabbit_ct_tcp_port_base, 25000]),
 | 
			
		||||
	peer:call(Pid3, persistent_term, put, [rabbit_ct_tcp_port_base, 27000]),
 | 
			
		||||
	peer:call(Pid4, persistent_term, put, [rabbit_ct_tcp_port_base, 29000]),
 | 
			
		||||
	ct_master_fork:run("$1"),
 | 
			
		||||
	Fail1 = peer:call(Pid1, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	Fail2 = peer:call(Pid2, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	Fail3 = peer:call(Pid3, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	Fail4 = peer:call(Pid4, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	[{[_], {ok, Results}}] = ct_master_fork:run("$1"),
 | 
			
		||||
	peer:stop(Pid4),
 | 
			
		||||
	peer:stop(Pid3),
 | 
			
		||||
	peer:stop(Pid2),
 | 
			
		||||
	peer:stop(Pid1),
 | 
			
		||||
	if
 | 
			
		||||
		Fail1 -> halt(1);
 | 
			
		||||
		Fail2 -> halt(2);
 | 
			
		||||
		Fail3 -> halt(3);
 | 
			
		||||
		Fail4 -> halt(4);
 | 
			
		||||
		true -> halt(0)
 | 
			
		||||
	end
 | 
			
		||||
	lists:foldl(fun
 | 
			
		||||
		({_, {_, 0, {_, 0}}}, Err) -> Err + 1;
 | 
			
		||||
		(What, Peer) -> halt(Peer)
 | 
			
		||||
	end, 1, Results),
 | 
			
		||||
	halt(0)
 | 
			
		||||
endef
 | 
			
		||||
 | 
			
		||||
PARALLEL_CT_SET_1_A = amqp_client unit_cluster_formation_locking_mocks unit_cluster_formation_sort_nodes unit_collections unit_config_value_encryption unit_connection_tracking
 | 
			
		||||
| 
						 | 
				
			
			@ -293,15 +287,13 @@ define tpl_parallel_ct_test_spec
 | 
			
		|||
{logdir, "$(CT_LOGS_DIR)"}.
 | 
			
		||||
{logdir, master, "$(CT_LOGS_DIR)"}.
 | 
			
		||||
{create_priv_dir, all_nodes, auto_per_run}.
 | 
			
		||||
{auto_compile, false}.
 | 
			
		||||
 | 
			
		||||
{node, shard1, 'rabbit_shard1@localhost'}.
 | 
			
		||||
{node, shard2, 'rabbit_shard2@localhost'}.
 | 
			
		||||
{node, shard3, 'rabbit_shard3@localhost'}.
 | 
			
		||||
{node, shard4, 'rabbit_shard4@localhost'}.
 | 
			
		||||
 | 
			
		||||
{auto_compile, false}.
 | 
			
		||||
{ct_hooks, [cth_parallel_ct_detect_failure]}.
 | 
			
		||||
 | 
			
		||||
{define, 'Set1', [$(call comma_list,$(addsuffix _SUITE,$1))]}.
 | 
			
		||||
{define, 'Set2', [$(call comma_list,$(addsuffix _SUITE,$2))]}.
 | 
			
		||||
{define, 'Set3', [$(call comma_list,$(addsuffix _SUITE,$3))]}.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -392,8 +392,7 @@ run_all([],#testspec{
 | 
			
		|||
		   end,
 | 
			
		||||
    log(tty,"Master Logdir","~ts",[MasterLogDir]),
 | 
			
		||||
    start_master(lists:reverse(NodeOpts),Handlers,MasterLogDir,
 | 
			
		||||
		 LogDirsRun,InitOptions,Specs),
 | 
			
		||||
    ok.
 | 
			
		||||
		 LogDirsRun,InitOptions,Specs).
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
%-doc """
 | 
			
		||||
| 
						 | 
				
			
			@ -581,18 +580,19 @@ init_master2(Parent,NodeOptsList,LogDirs) ->
 | 
			
		|||
    Parent ! {self(),Result}.
 | 
			
		||||
 | 
			
		||||
master_loop(#state{node_ctrl_pids=[],
 | 
			
		||||
		   results=Finished}) ->
 | 
			
		||||
		   results=Finished0}) ->
 | 
			
		||||
    Finished = lists:sort(Finished0),
 | 
			
		||||
    Str =
 | 
			
		||||
	lists:map(fun({Node,Result}) ->
 | 
			
		||||
			  io_lib:format("~-40.40.*ts~tp\n",
 | 
			
		||||
					[$_,atom_to_list(Node),Result])
 | 
			
		||||
		  end,lists:sort(Finished)),
 | 
			
		||||
		  end,Finished),
 | 
			
		||||
    log(all,"TEST RESULTS","~ts", [Str]),
 | 
			
		||||
    log(all,"Info","Updating log files",[]),
 | 
			
		||||
 | 
			
		||||
    ct_master_event_fork:stop(),
 | 
			
		||||
    ct_master_logs_fork:stop(),
 | 
			
		||||
    ok;
 | 
			
		||||
    {ok, Finished};
 | 
			
		||||
 | 
			
		||||
master_loop(State=#state{node_ctrl_pids=NodeCtrlPids,
 | 
			
		||||
			 results=Results,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,23 +0,0 @@
 | 
			
		|||
-module(cth_parallel_ct_detect_failure).
 | 
			
		||||
 | 
			
		||||
-export([init/2]).
 | 
			
		||||
-export([on_tc_fail/4]).
 | 
			
		||||
-export([has_failures/0]).
 | 
			
		||||
 | 
			
		||||
init(_Id, _Opts) ->
 | 
			
		||||
    {ok, undefined}.
 | 
			
		||||
 | 
			
		||||
%% We silence failures in end_per_suite/end_per_group
 | 
			
		||||
%% to mirror the default behavior. It should be modified
 | 
			
		||||
%% so that they are configured failures as well, but can
 | 
			
		||||
%% be done at a later time.
 | 
			
		||||
on_tc_fail(_SuiteName, end_per_suite, _Reason, CTHState) ->
 | 
			
		||||
    CTHState;
 | 
			
		||||
on_tc_fail(_SuiteName, {end_per_group, _GroupName}, _Reason, CTHState) ->
 | 
			
		||||
    CTHState;
 | 
			
		||||
on_tc_fail(_SuiteName, _TestName, _Reason, CTHState) ->
 | 
			
		||||
    persistent_term:put(?MODULE, true),
 | 
			
		||||
    CTHState.
 | 
			
		||||
 | 
			
		||||
has_failures() ->
 | 
			
		||||
    persistent_term:get(?MODULE, false).
 | 
			
		||||
| 
						 | 
				
			
			@ -82,22 +82,16 @@ define ct_master.erl
 | 
			
		|||
	peer:call(Pid2, persistent_term, put, [rabbit_ct_tcp_port_base, 25000]),
 | 
			
		||||
	peer:call(Pid3, persistent_term, put, [rabbit_ct_tcp_port_base, 27000]),
 | 
			
		||||
	peer:call(Pid4, persistent_term, put, [rabbit_ct_tcp_port_base, 29000]),
 | 
			
		||||
	ct_master_fork:run("$1"),
 | 
			
		||||
	Fail1 = peer:call(Pid1, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	Fail2 = peer:call(Pid2, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	Fail3 = peer:call(Pid3, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	Fail4 = peer:call(Pid4, cth_parallel_ct_detect_failure, has_failures, []),
 | 
			
		||||
	[{[_], {ok, Results}}] = ct_master_fork:run("$1"),
 | 
			
		||||
	peer:stop(Pid4),
 | 
			
		||||
	peer:stop(Pid3),
 | 
			
		||||
	peer:stop(Pid2),
 | 
			
		||||
	peer:stop(Pid1),
 | 
			
		||||
	if
 | 
			
		||||
		Fail1 -> halt(1);
 | 
			
		||||
		Fail2 -> halt(2);
 | 
			
		||||
		Fail3 -> halt(3);
 | 
			
		||||
		Fail4 -> halt(4);
 | 
			
		||||
		true -> halt(0)
 | 
			
		||||
	end
 | 
			
		||||
	lists:foldl(fun
 | 
			
		||||
		({_, {_, 0, {_, 0}}}, Err) -> Err + 1;
 | 
			
		||||
		(What, Peer) -> halt(Peer)
 | 
			
		||||
	end, 1, Results),
 | 
			
		||||
	halt(0)
 | 
			
		||||
endef
 | 
			
		||||
 | 
			
		||||
PARALLEL_CT_SET_1_A = auth retainer
 | 
			
		||||
| 
						 | 
				
			
			@ -116,15 +110,13 @@ define tpl_parallel_ct_test_spec
 | 
			
		|||
{logdir, "$(CT_LOGS_DIR)"}.
 | 
			
		||||
{logdir, master, "$(CT_LOGS_DIR)"}.
 | 
			
		||||
{create_priv_dir, all_nodes, auto_per_run}.
 | 
			
		||||
{auto_compile, false}.
 | 
			
		||||
 | 
			
		||||
{node, shard1, 'rabbit_shard1@localhost'}.
 | 
			
		||||
{node, shard2, 'rabbit_shard2@localhost'}.
 | 
			
		||||
{node, shard3, 'rabbit_shard3@localhost'}.
 | 
			
		||||
{node, shard4, 'rabbit_shard4@localhost'}.
 | 
			
		||||
 | 
			
		||||
{auto_compile, false}.
 | 
			
		||||
{ct_hooks, [cth_parallel_ct_detect_failure]}.
 | 
			
		||||
 | 
			
		||||
{define, 'Set1', [$(call comma_list,$(addsuffix _SUITE,$1))]}.
 | 
			
		||||
{define, 'Set2', [$(call comma_list,$(addsuffix _SUITE,$2))]}.
 | 
			
		||||
{define, 'Set3', [$(call comma_list,$(addsuffix _SUITE,$3))]}.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue