Skip to content

Commit

Permalink
Merge pull request #9140 from rabbitmq/logging_SUITE-improvements
Browse files Browse the repository at this point in the history
Improvements to the `logging_SUITE` testsuite
  • Loading branch information
dumbbell authored Aug 18, 2023
2 parents 4789606 + df416eb commit 21fa2d1
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions deps/rabbit/test/logging_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ init_per_testcase(Testcase, Config) ->
%% group will run in the context of that RabbitMQ node.
exchange_output ->
ExchProps = [{enabled, true},
{level, info}] ,
{level, debug}] ,
Config1 = rabbit_ct_helpers:set_config(
Config,
[{rmq_nodes_count, 1},
{rmq_nodename_suffix, Testcase}]),
Config2 = rabbit_ct_helpers:merge_app_env(
Config1,
{rabbit, [{log, [{exchange, ExchProps},
{file, [{level, info}]}]}]}),
{file, [{level, debug}]}]}]}),
rabbit_ct_helpers:run_steps(
Config2,
rabbit_ct_broker_helpers:setup_steps() ++
Expand Down Expand Up @@ -910,29 +910,30 @@ logging_to_exchange_works(Config) ->
ExchangeHandler = get_handler_by_id(Handlers, rmq_1_exchange),
?assertNotEqual(undefined, ExchangeHandler),
?assertMatch(
#{level := info,
#{level := debug,
module := rabbit_logger_exchange_h,
filter_default := log,
filters := [{progress_reports, {_, stop}},
{rmqlog_filter, {_, #{global := info}}}],
filters := [{progress_reports, {_, log}},
{rmqlog_filter, {_, #{global := debug}}}],
formatter := {rabbit_logger_text_fmt, _},
config := #{exchange := _}},
ExchangeHandler),
#{config :=
#{exchange := #resource{name = XName} = Exchange}} = ExchangeHandler,

%% Wait for the expected exchange to be automatically declared.
lists:any(
fun(_) ->
Ret = rabbit_ct_broker_helpers:rpc(
Config, 0,
rabbit_exchange, lookup, [Exchange]),
case Ret of
{ok, _} -> true;
_ -> timer:sleep(500),
false
end
end, lists:seq(1, 20)),
?assert(
lists:any(
fun(_) ->
Ret = rabbit_ct_broker_helpers:rpc(
Config, 0,
rabbit_exchange, lookup, [Exchange]),
case Ret of
{ok, _} -> true;
_ -> timer:sleep(500),
false
end
end, lists:seq(1, 20))),

%% Declare a queue to collect all logged messages.
{Conn, Chan} = rabbit_ct_client_helpers:open_connection_and_channel(
Expand All @@ -941,7 +942,7 @@ logging_to_exchange_works(Config) ->
?assertMatch(
#'queue.declare_ok'{},
amqp_channel:call(Chan, #'queue.declare'{queue = QName,
durable = false})),
durable = true})),
?assertMatch(
#'queue.bind_ok'{},
amqp_channel:call(Chan, #'queue.bind'{queue = QName,
Expand Down

0 comments on commit 21fa2d1

Please sign in to comment.