Skip to content

Commit 7d283b3

Browse files
committed
Add test enabling all feature flags with exchange logger
Add a test enabling all stable feature flags with exchange logging enabled. This is a more general test case for #11652 that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message. Relates #11652 #14069 #14796
1 parent b7f9504 commit 7d283b3

1 file changed

Lines changed: 52 additions & 7 deletions

File tree

deps/rabbit/test/logging_SUITE.erl

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
logging_to_exchange_works/1,
5555
update_log_exchange_config/1,
5656
use_exchange_logger_when_enabling_khepri_db/1,
57+
use_exchange_logger_when_enabling_all_feature_flags/1,
5758

5859
logging_to_syslog_works/1]).
5960

@@ -101,7 +102,8 @@ groups() ->
101102
{exchange_output, [],
102103
[logging_to_exchange_works,
103104
update_log_exchange_config,
104-
use_exchange_logger_when_enabling_khepri_db]},
105+
use_exchange_logger_when_enabling_khepri_db,
106+
use_exchange_logger_when_enabling_all_feature_flags]},
105107

106108
{syslog_output, [],
107109
[logging_to_syslog_works]}
@@ -151,8 +153,6 @@ init_per_testcase(Testcase, Config) ->
151153
%% The exchange output requires RabbitMQ to run. All testcases in this
152154
%% group will run in the context of that RabbitMQ node.
153155
exchange_output ->
154-
ExchProps = [{enabled, true},
155-
{level, debug}],
156156
Config1 = rabbit_ct_helpers:set_config(
157157
Config,
158158
[{rmq_nodename_suffix, Testcase}]),
@@ -162,15 +162,29 @@ init_per_testcase(Testcase, Config) ->
162162
Config1,
163163
[{rmq_nodes_count, 3},
164164
{metadata_store, mnesia}]);
165+
use_exchange_logger_when_enabling_all_feature_flags ->
166+
rabbit_ct_helpers:set_config(
167+
Config1,
168+
[{rmq_nodes_count, 3}]);
165169
_ ->
166170
rabbit_ct_helpers:set_config(
167171
Config1,
168172
[{rmq_nodes_count, 1}])
169173
end,
170-
Config3 = rabbit_ct_helpers:merge_app_env(
171-
Config2,
172-
{rabbit, [{log, [{exchange, ExchProps},
173-
{file, [{level, debug}]}]}]}),
174+
LogCfg = {log, [
175+
{exchange, [{enabled, true}, {level, debug}]},
176+
{file, [{level, debug}]}
177+
]},
178+
Config3 = case Testcase of
179+
use_exchange_logger_when_enabling_all_feature_flags ->
180+
rabbit_ct_helpers:merge_app_env(
181+
Config2, {rabbit, [LogCfg,
182+
{forced_feature_flags_on_init, []}
183+
]});
184+
_ ->
185+
rabbit_ct_helpers:merge_app_env(
186+
Config2, {rabbit, [LogCfg]})
187+
end,
174188
rabbit_ct_helpers:run_steps(
175189
Config3,
176190
rabbit_ct_broker_helpers:setup_steps() ++
@@ -1122,6 +1136,37 @@ use_exchange_logger_when_enabling_khepri_db(Config) ->
11221136
ok,
11231137
rabbit_ct_broker_helpers:enable_feature_flag(Config, khepri_db)).
11241138

1139+
%% Test case for https://github.com/rabbitmq/rabbitmq-server/discussions/11652
1140+
use_exchange_logger_when_enabling_all_feature_flags(Config) ->
1141+
{_Conn, Chan} = rabbit_ct_client_helpers:open_connection_and_channel(Config),
1142+
QNames = [<<"cq">>, <<"qq">>, <<"sq">>],
1143+
1144+
#'queue.declare_ok'{} = amqp_channel:call(
1145+
Chan, #'queue.declare'{queue = <<"cq">>,
1146+
durable = true,
1147+
arguments = [{<<"x-queue-type">>, longstr, <<"classic">>}]
1148+
}),
1149+
#'queue.declare_ok'{} = amqp_channel:call(
1150+
Chan, #'queue.declare'{queue = <<"qq">>,
1151+
durable = true,
1152+
arguments = [{<<"x-queue-type">>, longstr, <<"quorum">>}]
1153+
}),
1154+
#'queue.declare_ok'{} = amqp_channel:call(
1155+
Chan, #'queue.declare'{queue = <<"sq">>,
1156+
durable = true,
1157+
arguments = [{<<"x-queue-type">>, longstr, <<"stream">>}]
1158+
}),
1159+
[#'queue.bind_ok'{} = amqp_channel:call(
1160+
Chan, #'queue.bind'{queue = QName,
1161+
exchange = <<"amq.rabbitmq.log">>,
1162+
routing_key = <<"#">>}) ||
1163+
QName <- QNames],
1164+
1165+
?assertEqual(ok, rabbit_ct_broker_helpers:rpc(Config, rabbit_feature_flags, enable_all, [])),
1166+
1167+
%% Sanity check that at least one log message ended up in the queues.
1168+
[ok = queue_utils:wait_for_min_messages(Config, QName, 1) || QName <- QNames].
1169+
11251170
logging_to_syslog_works(Config) ->
11261171
Context = default_context(Config),
11271172
ok = application:set_env(

0 commit comments

Comments
 (0)