Skip to content

Commit 4c34155

Browse files
Merge pull request #13947 from rabbitmq/ik-rabbit_ct_hook
Run rabbit_ct_hook before cth_styledout so that removing default logger handler works
2 parents 5ed2fbe + 6b528e2 commit 4c34155

File tree

11 files changed

+28
-27
lines changed

11 files changed

+28
-27
lines changed

deps/rabbit/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ MANPAGES = $(wildcard $(DOCS_DIR)/*.[0-9])
151151
WEB_MANPAGES = $(patsubst %,%.html,$(MANPAGES))
152152
MD_MANPAGES = $(patsubst %,%.md,$(MANPAGES))
153153

154+
CT_HOOKS = rabbit_ct_hook
154155
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
155156
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
156157

@@ -221,8 +222,6 @@ ct-fast:
221222
ct-slow:
222223
$(MAKE) ct CT_SUITES='$(SLOW_CT_SUITES)'
223224

224-
CT_OPTS += -ct_hooks rabbit_ct_hook []
225-
226225
# Parallel CT.
227226
#
228227
# @todo We must ensure that the CT_OPTS also apply to ct-master

deps/rabbit/test/amqp_utils.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ web_amqp(Config) ->
6161
flush(Prefix) ->
6262
receive
6363
Msg ->
64-
ct:pal("~p flushed: ~p~n", [Prefix, Msg]),
64+
ct:log("~p flushed: ~p~n", [Prefix, Msg]),
6565
flush(Prefix)
6666
after 1 ->
6767
ok

deps/rabbit/test/peer_discovery_tmp_hidden_node_SUITE.erl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ long_names_work(_Config) ->
8282
ipv6_works(Config) ->
8383
PrivDir = ?config(priv_dir, Config),
8484
InetrcFilename = filename:join(PrivDir, "inetrc-ipv6.erl"),
85-
ct:pal("Inetrc filename:~n~0p", [InetrcFilename]),
85+
ct:log("Inetrc filename:~n~0p", [InetrcFilename]),
8686
Inetrc = [{inet6, true}],
8787
InetrcContent = [io_lib:format("~p.~n", [Param]) || Param <- Inetrc],
88-
ct:pal("Inetrc file content:~n---8<---~n~s---8<---", [InetrcContent]),
88+
ct:log("Inetrc file content:~n---8<---~n~s---8<---", [InetrcContent]),
8989
ok = file:write_file(InetrcFilename, InetrcContent),
9090
InetrcArg = rabbit_misc:format("~0p", [InetrcFilename]),
9191

@@ -106,10 +106,10 @@ inetrc_file_as_atom_works(_Config) ->
106106
%% might not be defined).
107107
TmpDir = os:getenv("TEMP", os:getenv("TMP", os:getenv("TMPDIR", "/tmp"))),
108108
InetrcFilename = filename:join(TmpDir, "inetrc-ipv6.erl"),
109-
ct:pal("Inetrc filename:~n~0p", [InetrcFilename]),
109+
ct:log("Inetrc filename:~n~0p", [InetrcFilename]),
110110
Inetrc = [{inet6, true}],
111111
InetrcContent = [io_lib:format("~p.~n", [Param]) || Param <- Inetrc],
112-
ct:pal("Inetrc file content:~n---8<---~n~s---8<---", [InetrcContent]),
112+
ct:log("Inetrc file content:~n---8<---~n~s---8<---", [InetrcContent]),
113113
ok = file:write_file(InetrcFilename, InetrcContent),
114114
InetrcArg = rabbit_misc:format("~0p", [list_to_atom(InetrcFilename)]),
115115

@@ -138,27 +138,27 @@ tls_dist_works(Config) ->
138138

139139
PrivDir = ?config(priv_dir, Config),
140140
SslOptFilename = filename:join(PrivDir, "ssl-options.erl"),
141-
ct:pal("SSL options filename:~n~0p", [SslOptFilename]),
141+
ct:log("SSL options filename:~n~0p", [SslOptFilename]),
142142
SslOptContent = rabbit_misc:format("~p.~n", [SslOptions]),
143-
ct:pal("SSL options file content:~n---8<---~n~s---8<---", [SslOptContent]),
143+
ct:log("SSL options file content:~n---8<---~n~s---8<---", [SslOptContent]),
144144
ok = file:write_file(SslOptFilename, SslOptContent),
145145

146146
%% We need to read the certificate's Subject ID to see what hostname is
147147
%% used in the certificate and use the same to start the test Erlang nodes.
148148
%% We also need to pay attention if the name is short or long.
149149
{ok, ServerCertBin} = file:read_file(ServerCert),
150-
ct:pal("ServerCertBin = ~p", [ServerCertBin]),
150+
ct:log("ServerCertBin = ~p", [ServerCertBin]),
151151
[DecodedCert] = public_key:pem_decode(ServerCertBin),
152-
ct:pal("DecodedCert = ~p", [DecodedCert]),
152+
ct:log("DecodedCert = ~p", [DecodedCert]),
153153
DecodedCert1 = element(2, DecodedCert),
154154
{_SerialNr, {rdnSequence, IssuerAttrs}} = public_key:pkix_subject_id(
155155
DecodedCert1),
156-
ct:pal("IssuerAttrs = ~p", [IssuerAttrs]),
156+
ct:log("IssuerAttrs = ~p", [IssuerAttrs]),
157157
[ServerName] = [Value
158158
|| [#'AttributeTypeAndValue'{type = {2, 5, 4, 3},
159159
value = {utf8String, Value}}]
160160
<- IssuerAttrs],
161-
ct:pal("ServerName = ~p", [ServerName]),
161+
ct:log("ServerName = ~p", [ServerName]),
162162
UseLongnames = re:run(ServerName, "\\.", [{capture, none}]) =:= match,
163163

164164
PeerOptions = #{host => binary_to_list(ServerName),
@@ -188,7 +188,7 @@ do_test_query_node_props(Peers) ->
188188
NodeAPid,
189189
rabbit_peer_discovery, query_node_props, [[NodeB]],
190190
infinity),
191-
ct:pal("Discovered nodes properties:~n~p", [Ret]),
191+
ct:log("Discovered nodes properties:~n~p", [Ret]),
192192
?assertMatch([{NodeB, [NodeB], _, false}], Ret),
193193

194194
%% Ensure no connection exists after the query.
@@ -236,23 +236,23 @@ start_test_nodes(Testcase, NodeNumber, NodeCount, PeerOptions, Peers)
236236
_ ->
237237
PeerOptions1
238238
end,
239-
ct:pal("Starting peer with options: ~p", [PeerOptions2]),
239+
ct:log("Starting peer with options: ~p", [PeerOptions2]),
240240
case catch peer:start(PeerOptions2) of
241241
{ok, PeerPid, PeerName} ->
242-
ct:pal("Configuring peer '~ts'", [PeerName]),
242+
ct:log("Configuring peer '~ts'", [PeerName]),
243243
setup_test_node(PeerPid, PeerOptions2),
244244
Peers1 = Peers#{PeerName => PeerPid},
245245
start_test_nodes(
246246
Testcase, NodeNumber + 1, NodeCount, PeerOptions, Peers1);
247247
Error ->
248-
ct:pal("Failed to started peer node:~n"
248+
ct:log("Failed to started peer node:~n"
249249
"Options: ~p~n"
250250
"Error: ~p", [PeerOptions2, Error]),
251251
stop_test_nodes(Peers),
252252
erlang:throw(Error)
253253
end;
254254
start_test_nodes(_Testcase, _NodeNumber, _Count, _PeerOptions, Peers) ->
255-
ct:pal("Peers: ~p", [Peers]),
255+
ct:log("Peers: ~p", [Peers]),
256256
Peers.
257257

258258
setup_test_node(PeerPid, PeerOptions) ->

deps/rabbit/test/policy_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ get_messages(Number, Ch, Q) ->
449449
end.
450450

451451
check_policy_value(Server, QName, Value) ->
452-
ct:pal("QUEUES ~p",
452+
ct:log("QUEUES ~p",
453453
[rpc:call(Server, rabbit_amqqueue, list, [])]),
454454
{ok, Q} = rpc:call(Server, rabbit_amqqueue, lookup, [rabbit_misc:r(<<"/">>, queue, QName)]),
455455
case rpc:call(Server, rabbit_policy, effective_definition, [Q]) of

deps/rabbit_common/mk/rabbitmq-early-plugin.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CT_OPTS += -kernel net_ticktime 5
3838
# This hook will change the output of common_test to something more
3939
# concise and colored.
4040

41-
CT_HOOKS ?= cth_styledout
41+
CT_HOOKS += cth_styledout
4242
TEST_DEPS += cth_styledout
4343

4444
ifdef CONCOURSE

deps/rabbitmq_ct_helpers/src/ct_master_fork.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ run_all([{Node,Run,Skip}|Rest],TSRec=#testspec{label = Labels,
368368
{cover_stop, CoverStop},
369369
{config, ConfigFiles},
370370
{event_handler, EvHandlers},
371-
{ct_hooks, FiltCTHooks},
371+
{ct_hooks, [rabbit_ct_hook, cth_styledout] ++ FiltCTHooks},
372372
% {ct_hooks_order, CTHooksOrder},
373373
{enable_builtin_hooks, EnableBuiltinHooks},
374374
{auto_compile, AutoCompile},

deps/rabbitmq_ct_helpers/src/rabbit_control_helper.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ command_with_output(Command, Node, Args, Opts) ->
4343
Mod = 'Elixir.RabbitMQCtl', %% To silence a Dialyzer warning.
4444
CommandResult = Mod:exec_command(
4545
Formatted, fun(Output,_,_) -> Output end),
46-
ct:pal("Executed command ~tp against node ~tp~nResult: ~tp~n", [Formatted, Node, CommandResult]),
46+
ct:log("Executed command ~tp against node ~tp~nResult: ~tp~n", [Formatted, Node, CommandResult]),
4747
CommandResult.
4848

4949
format_command(Command, Node, Args, Opts) ->

deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ does_use_expected_metadata_store(Config, NodeConfig) ->
944944
true -> khepri;
945945
false -> mnesia
946946
end,
947-
ct:pal(
947+
ct:log(
948948
"Metadata store on ~s: expected=~s, used=~s",
949949
[Nodename, ExpectedMetadataStore, UsedMetadataStore]),
950950
{ExpectedMetadataStore, UsedMetadataStore}.
@@ -975,7 +975,7 @@ cluster_nodes(Config, Nodes) when is_list(Nodes) ->
975975
{value, SecNodeConfig} ->
976976
NodeConfigs1 = NodeConfigs -- [SecNodeConfig],
977977
Nodename = ?config(nodename, SecNodeConfig),
978-
ct:pal(
978+
ct:log(
979979
"Using secondary-umbrella-based node ~s as the cluster seed "
980980
"node",
981981
[Nodename]),
@@ -984,7 +984,7 @@ cluster_nodes(Config, Nodes) when is_list(Nodes) ->
984984
case NodeConfigs of
985985
[NodeConfig, SeedNodeConfig | NodeConfigs1] ->
986986
Nodename = ?config(nodename, SeedNodeConfig),
987-
ct:pal(
987+
ct:log(
988988
"Using node ~s as the cluster seed node",
989989
[Nodename]),
990990
cluster_nodes1(
@@ -1184,7 +1184,7 @@ ra_last_applied(ServerId) ->
11841184

11851185
do_nodes_run_same_ra_machine_version(Config, RaMachineMod) ->
11861186
[MacVer1 | MacVerN] = MacVers = rpc_all(Config, RaMachineMod, version, []),
1187-
ct:pal("Ra machine versions of ~s: ~0p", [RaMachineMod, MacVers]),
1187+
ct:log("Ra machine versions of ~s: ~0p", [RaMachineMod, MacVers]),
11881188
is_integer(MacVer1) andalso
11891189
lists:all(fun(MacVer) -> MacVer =:= MacVer1 end, MacVerN).
11901190

@@ -1403,7 +1403,7 @@ capture_gen_server_termination(
14031403
lists:reverse(Acc), Rest, Count, IgnoredCrashes).
14041404

14051405
found_gen_server_termiation(Message, Lines, Count, IgnoredCrashes) ->
1406-
ct:pal("gen_server termination:~n~n~s", [Message]),
1406+
ct:log("gen_server termination:~n~n~s", [Message]),
14071407
count_gen_server_terminations(Lines, Count + 1, IgnoredCrashes).
14081408

14091409
%% -------------------------------------------------------------------

deps/rabbitmq_management/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ LOCAL_DEPS += ranch ssl crypto public_key
3131
# See rabbitmq-components.mk.
3232
BUILD_DEPS += ranch
3333

34+
CT_HOOKS = rabbit_ct_hook
3435
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
3536
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
3637

deps/rabbitmq_mqtt/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ PLT_APPS += rabbitmq_cli elixir
5050
dep_ct_helper = git https://github.com/extend/ct_helper.git master
5151
dep_emqtt = git https://github.com/emqx/emqtt.git 1.11.0
5252

53+
CT_HOOKS = rabbit_ct_hook
5354
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
5455
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
5556

0 commit comments

Comments
 (0)