2424
2525-import (rabbit_ct_broker_helpers ,
2626 [rabbitmqctl_list /3 ,
27+ rabbitmqctl /3 ,
2728 rpc /4 ,
2829 rpc /5 ,
2930 rpc_all /4 ,
@@ -125,6 +126,9 @@ cluster_size_1_tests() ->
125126 ,retained_message_conversion
126127 ,bind_exchange_to_exchange
127128 ,bind_exchange_to_exchange_single_message
129+ ,notify_consumer_classic_queue_deleted
130+ ,notify_consumer_quorum_queue_deleted
131+ ,notify_consumer_qos0_queue_deleted
128132 ].
129133
130134cluster_size_3_tests () ->
@@ -167,8 +171,8 @@ init_per_suite(Config) ->
167171end_per_suite (Config ) ->
168172 rabbit_ct_helpers :run_teardown_steps (Config ).
169173
170- init_per_group (mqtt , Config ) ->
171- rabbit_ct_helpers :set_config (Config , {websocket , false });
174+ init_per_group (mqtt , Config0 ) ->
175+ rabbit_ct_helpers :set_config (Config0 , {websocket , false });
172176init_per_group (Group , Config )
173177 when Group =:= v3 ;
174178 Group =:= v4 ;
@@ -208,7 +212,8 @@ init_per_testcase(T, Config)
208212init_per_testcase (T , Config )
209213 when T =:= clean_session_disconnect_client ;
210214 T =:= clean_session_node_restart ;
211- T =:= clean_session_node_kill ->
215+ T =:= clean_session_node_kill ;
216+ T =:= notify_consumer_qos0_queue_deleted ->
212217 ok = rpc (Config , rabbit_registry , register , [queue , <<" qos0" >>, rabbit_mqtt_qos0_queue ]),
213218 init_per_testcase0 (T , Config );
214219init_per_testcase (Testcase , Config ) ->
@@ -225,7 +230,8 @@ end_per_testcase(T, Config)
225230end_per_testcase (T , Config )
226231 when T =:= clean_session_disconnect_client ;
227232 T =:= clean_session_node_restart ;
228- T =:= clean_session_node_kill ->
233+ T =:= clean_session_node_kill ;
234+ T =:= notify_consumer_qos0_queue_deleted ->
229235 ok = rpc (Config , rabbit_registry , unregister , [queue , <<" qos0" >>]),
230236 end_per_testcase0 (T , Config );
231237end_per_testcase (Testcase , Config ) ->
@@ -324,9 +330,7 @@ will_without_disconnect(Config) ->
324330% % Test that an MQTT connection decodes the AMQP 0.9.1 'P_basic' properties.
325331% % see https://github.com/rabbitmq/rabbitmq-server/discussions/8252
326332decode_basic_properties (Config ) ->
327- App = rabbitmq_mqtt ,
328- Par = durable_queue_type ,
329- ok = rpc (Config , application , set_env , [App , Par , quorum ]),
333+ set_durable_queue_type (Config ),
330334 ClientId = Topic = Payload = atom_to_binary (? FUNCTION_NAME ),
331335 C1 = connect (ClientId , Config , non_clean_sess_opts ()),
332336 {ok , _ , [1 ]} = emqtt :subscribe (C1 , Topic , qos1 ),
@@ -340,7 +344,7 @@ decode_basic_properties(Config) ->
340344 ok = emqtt :disconnect (C1 ),
341345 C2 = connect (ClientId , Config , [{clean_start , true }]),
342346 ok = emqtt :disconnect (C2 ),
343- ok = rpc (Config , application , unset_env , [ App , Par ] ),
347+ unset_durable_queue_type (Config ),
344348 ok = rabbit_ct_client_helpers :close_connection_and_channel (Conn , Ch ).
345349
346350quorum_queue_rejects (Config ) ->
@@ -1955,6 +1959,35 @@ bind_exchange_to_exchange_single_message(Config) ->
19551959 ok = emqtt :disconnect (C ),
19561960 ok = rabbit_ct_client_helpers :close_connection_and_channel (Conn , Ch ).
19571961
1962+ notify_consumer_qos0_queue_deleted (Config ) ->
1963+ Topic = atom_to_binary (? FUNCTION_NAME ),
1964+ notify_consumer_queue_deleted (Config , Topic , <<" MQTT QoS 0" >>, [{retry_interval , 1 }], qos0 ).
1965+
1966+ notify_consumer_classic_queue_deleted (Config ) ->
1967+ Topic = atom_to_binary (? FUNCTION_NAME ),
1968+ notify_consumer_queue_deleted (Config , Topic , <<" classic" >>, non_clean_sess_opts (), qos0 ).
1969+
1970+ notify_consumer_quorum_queue_deleted (Config ) ->
1971+ set_durable_queue_type (Config ),
1972+ Topic = atom_to_binary (? FUNCTION_NAME ),
1973+ notify_consumer_queue_deleted (Config , Topic , <<" quorum" >>, non_clean_sess_opts (), qos1 ),
1974+ unset_durable_queue_type (Config ).
1975+
1976+ notify_consumer_queue_deleted (Config , Name = Topic , ExpectedType , ConnOpts , Qos ) ->
1977+ C = connect (Name , Config , ConnOpts ),
1978+ {ok , _ , _ } = emqtt :subscribe (C , Topic , Qos ),
1979+ {ok , #{reason_code_name := success }} = emqtt :publish (C , Name , <<" m1" >>, qos1 ),
1980+ {ok , #{reason_code_name := success }} = emqtt :publish (C , Name , <<" m2" >>, qos1 ),
1981+ ok = expect_publishes (C , Topic , [<<" m1" >>, <<" m2" >>]),
1982+
1983+ [[QName , Type ]] = rabbitmqctl_list (Config , 0 , [" list_queues" , " name" , " type" , " --no-table-headers" ]),
1984+ ? assertMatch (ExpectedType , Type ),
1985+
1986+ process_flag (trap_exit , true ),
1987+ {ok , _ } = rabbitmqctl (Config , 0 , [" delete_queue" , QName ]),
1988+
1989+ await_exit (C ).
1990+
19581991% % -------------------------------------------------------------------
19591992% % Internal helpers
19601993% % -------------------------------------------------------------------
@@ -1985,7 +2018,7 @@ await_confirms_unordered(From, Left) ->
19852018 end .
19862019
19872020await_consumer_count (ConsumerCount , ClientId , QoS , Config ) ->
1988- {Conn , Ch } = rabbit_ct_client_helpers :open_connection_and_channel (Config ),
2021+ {_Conn , Ch } = rabbit_ct_client_helpers :open_connection_and_channel (Config ),
19892022 QueueName = rabbit_mqtt_util :queue_name_bin (
19902023 rabbit_data_coercion :to_binary (ClientId ), QoS ),
19912024 eventually (
@@ -2030,3 +2063,9 @@ assert_v5_disconnect_reason_code(Config, ReasonCode) ->
20302063 after ? TIMEOUT -> ct :fail (" missing DISCONNECT packet from server" )
20312064 end
20322065 end .
2066+
2067+ set_durable_queue_type (Config ) ->
2068+ ok = rpc (Config , application , set_env , [rabbitmq_mqtt , durable_queue_type , quorum ]).
2069+
2070+ unset_durable_queue_type (Config ) ->
2071+ ok = rpc (Config , application , unset_env , [rabbitmq_mqtt , durable_queue_type ]).
0 commit comments