Skip to content

Commit 26218f2

Browse files
committed
Skip binding_args if ff rabbitmq_4.2.0 is not enabled
Prior to this commit, this test case failed in 4.2 <-> 4.1 mixed version mode because the different nodes register different projections. Specifically, the old projection of the 4.1 node was registered. Independent of the test case, even when a rolling upgrade from 4.1 to this commit's branch completes, the old projection is still registered. It seems, what's missing is a Khepri machine version migration where the projection will be migrated from old to new. But that's outside the scope of this bug fix. We can add this mechanism separately.
1 parent 6786e31 commit 26218f2

File tree

1 file changed

+55
-51
lines changed

1 file changed

+55
-51
lines changed

deps/rabbit/test/bindings_SUITE.erl

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1414

1515
-compile([nowarn_export_all, export_all]).
16-
-compile(export_all).
1716

1817
suite() ->
1918
[{timetrap, 5 * 60000}].
@@ -37,7 +36,6 @@ groups() ->
3736
all_tests() ->
3837
[
3938
%% Queue bindings
40-
binding_args,
4139
bind_and_unbind,
4240
bind_and_delete,
4341
bind_and_delete_source_exchange,
@@ -50,6 +48,7 @@ all_tests() ->
5048
list_with_multiple_vhosts,
5149
list_with_multiple_arguments,
5250
bind_to_unknown_queue,
51+
binding_args,
5352
%% Exchange bindings
5453
bind_and_unbind_exchange,
5554
bind_and_delete_exchange_source,
@@ -118,55 +117,6 @@ end_per_testcase(Testcase, Config) ->
118117
%% Testcases.
119118
%% -------------------------------------------------------------------
120119

121-
binding_args(Config) ->
122-
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
123-
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
124-
Q = ?config(queue_name, Config),
125-
?assertEqual({'queue.declare_ok', Q, 0, 0}, declare(Ch, Q, [])),
126-
127-
#'confirm.select_ok'{} = amqp_channel:call(Ch, #'confirm.select'{}),
128-
amqp_channel:register_confirm_handler(Ch, self()),
129-
130-
%% Create two bindings that differ only in their binding arguments.
131-
Exchange = <<"amq.direct">>,
132-
RoutingKey = <<"some-key">>,
133-
BindingArgs1 = [{<<"app">>, longstr, <<"app-1">>}],
134-
BindingArgs2 = [{<<"app">>, longstr, <<"app-2">>}],
135-
#'queue.bind_ok'{} = amqp_channel:call(Ch, #'queue.bind'{exchange = Exchange,
136-
routing_key = RoutingKey,
137-
queue = Q,
138-
arguments = BindingArgs1}),
139-
#'queue.bind_ok'{} = amqp_channel:call(Ch, #'queue.bind'{exchange = Exchange,
140-
routing_key = RoutingKey,
141-
queue = Q,
142-
arguments = BindingArgs2}),
143-
ok = amqp_channel:cast(Ch,
144-
#'basic.publish'{exchange = Exchange,
145-
routing_key = RoutingKey},
146-
#amqp_msg{payload = <<"m1">>}),
147-
receive #'basic.ack'{} -> ok
148-
after 9000 -> ct:fail(confirm_timeout)
149-
end,
150-
151-
?assertMatch({#'basic.get_ok'{}, #amqp_msg{payload = <<"m1">>}},
152-
amqp_channel:call(Ch, #'basic.get'{queue = Q, no_ack = true})),
153-
154-
%% If we delete the 1st binding, we expect RabbitMQ to still route via the 2nd binding.
155-
#'queue.unbind_ok'{} = amqp_channel:call(Ch, #'queue.unbind'{exchange = Exchange,
156-
routing_key = RoutingKey,
157-
queue = Q,
158-
arguments = BindingArgs1}),
159-
ok = amqp_channel:cast(Ch,
160-
#'basic.publish'{exchange = Exchange,
161-
routing_key = RoutingKey},
162-
#amqp_msg{payload = <<"m2">>}),
163-
receive #'basic.ack'{} -> ok
164-
after 9000 -> ct:fail(confirm_timeout)
165-
end,
166-
167-
?assertMatch({#'basic.get_ok'{}, #amqp_msg{payload = <<"m2">>}},
168-
amqp_channel:call(Ch, #'basic.get'{queue = Q, no_ack = true})).
169-
170120
bind_and_unbind(Config) ->
171121
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
172122

@@ -748,6 +698,60 @@ bind_to_unknown_queue(Config) ->
748698
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_binding, list, [<<"/">>])),
749699
ok.
750700

701+
binding_args(Config) ->
702+
case rabbit_ct_broker_helpers:enable_feature_flag(Config, 'rabbitmq_4.2.0') of
703+
{skip, _} = Skip ->
704+
Skip;
705+
ok ->
706+
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
707+
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
708+
Q = ?config(queue_name, Config),
709+
?assertEqual({'queue.declare_ok', Q, 0, 0}, declare(Ch, Q, [])),
710+
711+
#'confirm.select_ok'{} = amqp_channel:call(Ch, #'confirm.select'{}),
712+
amqp_channel:register_confirm_handler(Ch, self()),
713+
714+
%% Create two bindings that differ only in their binding arguments.
715+
Exchange = <<"amq.direct">>,
716+
RoutingKey = <<"some-key">>,
717+
BindingArgs1 = [{<<"app">>, longstr, <<"app-1">>}],
718+
BindingArgs2 = [{<<"app">>, longstr, <<"app-2">>}],
719+
#'queue.bind_ok'{} = amqp_channel:call(Ch, #'queue.bind'{exchange = Exchange,
720+
routing_key = RoutingKey,
721+
queue = Q,
722+
arguments = BindingArgs1}),
723+
#'queue.bind_ok'{} = amqp_channel:call(Ch, #'queue.bind'{exchange = Exchange,
724+
routing_key = RoutingKey,
725+
queue = Q,
726+
arguments = BindingArgs2}),
727+
ok = amqp_channel:cast(Ch,
728+
#'basic.publish'{exchange = Exchange,
729+
routing_key = RoutingKey},
730+
#amqp_msg{payload = <<"m1">>}),
731+
receive #'basic.ack'{} -> ok
732+
after 9000 -> ct:fail(confirm_timeout)
733+
end,
734+
735+
?assertMatch({#'basic.get_ok'{}, #amqp_msg{payload = <<"m1">>}},
736+
amqp_channel:call(Ch, #'basic.get'{queue = Q, no_ack = true})),
737+
738+
%% If we delete the 1st binding, we expect RabbitMQ to still route via the 2nd binding.
739+
#'queue.unbind_ok'{} = amqp_channel:call(Ch, #'queue.unbind'{exchange = Exchange,
740+
routing_key = RoutingKey,
741+
queue = Q,
742+
arguments = BindingArgs1}),
743+
ok = amqp_channel:cast(Ch,
744+
#'basic.publish'{exchange = Exchange,
745+
routing_key = RoutingKey},
746+
#amqp_msg{payload = <<"m2">>}),
747+
receive #'basic.ack'{} -> ok
748+
after 9000 -> ct:fail(confirm_timeout)
749+
end,
750+
751+
?assertMatch({#'basic.get_ok'{}, #amqp_msg{payload = <<"m2">>}},
752+
amqp_channel:call(Ch, #'basic.get'{queue = Q, no_ack = true}))
753+
end.
754+
751755
bind_and_unbind_exchange(Config) ->
752756
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
753757

0 commit comments

Comments
 (0)