Skip to content

Commit

Permalink
Make CI: Have ct_master return the test results
Browse files Browse the repository at this point in the history
Instead of having a CT hook just to know whether our tests failed.
  • Loading branch information
lhoguin committed Oct 15, 2024
1 parent c681878 commit e37e6b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 58 deletions.
22 changes: 7 additions & 15 deletions deps/rabbit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))]}.
Expand Down
10 changes: 5 additions & 5 deletions deps/rabbitmq_ct_helpers/src/ct_master_fork.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 0 additions & 23 deletions deps/rabbitmq_ct_helpers/src/cth_parallel_ct_detect_failure.erl

This file was deleted.

22 changes: 7 additions & 15 deletions deps/rabbitmq_mqtt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))]}.
Expand Down

0 comments on commit e37e6b6

Please sign in to comment.