@@ -71,6 +71,7 @@ cluster_size_1_tests() ->
7171 session_expiry_reconnect_non_zero ,
7272 session_expiry_reconnect_zero ,
7373 session_expiry_reconnect_infinity_to_zero ,
74+ zero_session_expiry_disconnect_autodeletes_qos0_queue ,
7475 client_publish_qos2 ,
7576 client_rejects_publish ,
7677 client_receive_maximum_min ,
@@ -188,6 +189,12 @@ init_per_testcase(T, Config)
188189 ok = rpc (Config , application , set_env , [? APP , Par , infinity ]),
189190 Config1 = rabbit_ct_helpers :set_config (Config , {Par , Default }),
190191 init_per_testcase0 (T , Config1 );
192+
193+ init_per_testcase (T , Config )
194+ when T =:= zero_session_expiry_disconnect_autodeletes_qos0_queue ->
195+ rpc (Config , rabbit_registry , register , [queue , <<" qos0" >>, rabbit_mqtt_qos0_queue ]),
196+ init_per_testcase0 (T , Config );
197+
191198init_per_testcase (T , Config ) ->
192199 init_per_testcase0 (T , Config ).
193200
@@ -202,6 +209,11 @@ end_per_testcase(T, Config)
202209 Default = ? config (Par , Config ),
203210 ok = rpc (Config , application , set_env , [? APP , Par , Default ]),
204211 end_per_testcase0 (T , Config );
212+ end_per_testcase (T , Config )
213+ when T =:= zero_session_expiry_disconnect_autodeletes_qos0_queue ->
214+ ok = rpc (Config , rabbit_registry , unregister , [queue , <<" qos0" >>]),
215+ init_per_testcase0 (T , Config );
216+
205217end_per_testcase (T , Config ) ->
206218 end_per_testcase0 (T , Config ).
207219
@@ -389,6 +401,22 @@ session_expiry_quorum_queue_disconnect_decrease(Config) ->
389401 ok = session_expiry_disconnect_decrease (rabbit_quorum_queue , Config ),
390402 ok = rpc (Config , application , unset_env , [? APP , durable_queue_type ]).
391403
404+ zero_session_expiry_disconnect_autodeletes_qos0_queue (Config ) ->
405+ ClientId = ? FUNCTION_NAME ,
406+ C = connect (ClientId , Config , [
407+ {clean_start , false },
408+ {properties , #{'Session-Expiry-Interval' => 0 }}]),
409+ {ok , _ , _ } = emqtt :subscribe (C , <<" topic0" >>, qos0 ),
410+ QsQos0 = rpc (Config , rabbit_amqqueue , list_by_type , [rabbit_mqtt_qos0_queue ]),
411+ ? assertEqual (1 , length (QsQos0 )),
412+
413+ ok = emqtt :disconnect (C ),
414+ % % After terminating a clean session, we expect any session state to be cleaned up on the server.
415+ % % Give the node some time to clean up the MQTT QoS 0 queue.
416+ timer :sleep (200 ),
417+ L = rpc (Config , rabbit_amqqueue , list , []),
418+ ? assertEqual (0 , length (L )).
419+
392420session_expiry_disconnect_decrease (QueueType , Config ) ->
393421 ClientId = ? FUNCTION_NAME ,
394422 C1 = connect (ClientId , Config , [{properties , #{'Session-Expiry-Interval' => 100 }}]),
0 commit comments