24
24
25
25
-import (rabbit_ct_broker_helpers ,
26
26
[rabbitmqctl_list /3 ,
27
+ rabbitmqctl /3 ,
27
28
rpc /4 ,
28
29
rpc /5 ,
29
30
rpc_all /4 ,
@@ -125,6 +126,9 @@ cluster_size_1_tests() ->
125
126
,retained_message_conversion
126
127
,bind_exchange_to_exchange
127
128
,bind_exchange_to_exchange_single_message
129
+ ,notify_consumer_classic_queue_deleted
130
+ ,notify_consumer_quorum_queue_deleted
131
+ ,notify_consumer_qos0_queue_deleted
128
132
].
129
133
130
134
cluster_size_3_tests () ->
@@ -167,8 +171,8 @@ init_per_suite(Config) ->
167
171
end_per_suite (Config ) ->
168
172
rabbit_ct_helpers :run_teardown_steps (Config ).
169
173
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 });
172
176
init_per_group (Group , Config )
173
177
when Group =:= v3 ;
174
178
Group =:= v4 ;
@@ -208,7 +212,8 @@ init_per_testcase(T, Config)
208
212
init_per_testcase (T , Config )
209
213
when T =:= clean_session_disconnect_client ;
210
214
T =:= clean_session_node_restart ;
211
- T =:= clean_session_node_kill ->
215
+ T =:= clean_session_node_kill ;
216
+ T =:= notify_consumer_qos0_queue_deleted ->
212
217
ok = rpc (Config , rabbit_registry , register , [queue , <<" qos0" >>, rabbit_mqtt_qos0_queue ]),
213
218
init_per_testcase0 (T , Config );
214
219
init_per_testcase (Testcase , Config ) ->
@@ -225,7 +230,8 @@ end_per_testcase(T, Config)
225
230
end_per_testcase (T , Config )
226
231
when T =:= clean_session_disconnect_client ;
227
232
T =:= clean_session_node_restart ;
228
- T =:= clean_session_node_kill ->
233
+ T =:= clean_session_node_kill ;
234
+ T =:= notify_consumer_qos0_queue_deleted ->
229
235
ok = rpc (Config , rabbit_registry , unregister , [queue , <<" qos0" >>]),
230
236
end_per_testcase0 (T , Config );
231
237
end_per_testcase (Testcase , Config ) ->
@@ -324,9 +330,7 @@ will_without_disconnect(Config) ->
324
330
% % Test that an MQTT connection decodes the AMQP 0.9.1 'P_basic' properties.
325
331
% % see https://github.com/rabbitmq/rabbitmq-server/discussions/8252
326
332
decode_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 ),
330
334
ClientId = Topic = Payload = atom_to_binary (? FUNCTION_NAME ),
331
335
C1 = connect (ClientId , Config , non_clean_sess_opts ()),
332
336
{ok , _ , [1 ]} = emqtt :subscribe (C1 , Topic , qos1 ),
@@ -340,7 +344,7 @@ decode_basic_properties(Config) ->
340
344
ok = emqtt :disconnect (C1 ),
341
345
C2 = connect (ClientId , Config , [{clean_start , true }]),
342
346
ok = emqtt :disconnect (C2 ),
343
- ok = rpc (Config , application , unset_env , [ App , Par ] ),
347
+ unset_durable_queue_type (Config ),
344
348
ok = rabbit_ct_client_helpers :close_connection_and_channel (Conn , Ch ).
345
349
346
350
quorum_queue_rejects (Config ) ->
@@ -1955,6 +1959,35 @@ bind_exchange_to_exchange_single_message(Config) ->
1955
1959
ok = emqtt :disconnect (C ),
1956
1960
ok = rabbit_ct_client_helpers :close_connection_and_channel (Conn , Ch ).
1957
1961
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
+
1958
1991
% % -------------------------------------------------------------------
1959
1992
% % Internal helpers
1960
1993
% % -------------------------------------------------------------------
@@ -1985,7 +2018,7 @@ await_confirms_unordered(From, Left) ->
1985
2018
end .
1986
2019
1987
2020
await_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 ),
1989
2022
QueueName = rabbit_mqtt_util :queue_name_bin (
1990
2023
rabbit_data_coercion :to_binary (ClientId ), QoS ),
1991
2024
eventually (
@@ -2030,3 +2063,9 @@ assert_v5_disconnect_reason_code(Config, ReasonCode) ->
2030
2063
after ? TIMEOUT -> ct :fail (" missing DISCONNECT packet from server" )
2031
2064
end
2032
2065
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