@@ -878,34 +878,30 @@ session_expiry(Config) ->
878
878
ok = rpc (Config , application , set_env , [App , Par , DefaultVal ]).
879
879
880
880
non_clean_sess_reconnect_qos1 (Config ) ->
881
- non_clean_sess_reconnect (Config , qos1 ).
881
+ non_clean_sess_reconnect (Config , 1 ).
882
882
883
883
non_clean_sess_reconnect_qos0 (Config ) ->
884
- non_clean_sess_reconnect (Config , qos0 ).
884
+ non_clean_sess_reconnect (Config , 0 ).
885
885
886
886
non_clean_sess_reconnect (Config , SubscriptionQoS ) ->
887
887
Pub = connect (<<" publisher" >>, Config ),
888
888
Topic = ClientId = atom_to_binary (? FUNCTION_NAME ),
889
889
890
890
C1 = connect (ClientId , Config , non_clean_sess_opts ()),
891
- {ok , _ , _ } = emqtt :subscribe (C1 , Topic , SubscriptionQoS ),
892
- ? assertMatch (#{consumers := 1 },
893
- get_global_counters (Config )),
891
+ {ok , _ , [SubscriptionQoS ]} = emqtt :subscribe (C1 , Topic , SubscriptionQoS ),
892
+ ok = await_consumer_count (1 , ClientId , SubscriptionQoS , Config ),
894
893
895
894
ok = emqtt :disconnect (C1 ),
896
- eventually (? _assertMatch (#{consumers := 0 },
897
- get_global_counters (Config ))),
895
+ ok = await_consumer_count (0 , ClientId , SubscriptionQoS , Config ),
898
896
899
- timer :sleep (20 ),
900
897
ok = emqtt :publish (Pub , Topic , <<" msg-3-qos0" >>, qos0 ),
901
898
{ok , _ } = emqtt :publish (Pub , Topic , <<" msg-4-qos1" >>, qos1 ),
902
899
903
900
C2 = connect (ClientId , Config , non_clean_sess_opts ()),
904
901
% % Server should reply in CONNACK that it has session state.
905
902
? assertEqual ({session_present , 1 },
906
903
proplists :lookup (session_present , emqtt :info (C2 ))),
907
- ? assertMatch (#{consumers := 1 },
908
- get_global_counters (Config )),
904
+ ok = await_consumer_count (1 , ClientId , SubscriptionQoS , Config ),
909
905
910
906
ok = emqtt :publish (Pub , Topic , <<" msg-5-qos0" >>, qos0 ),
911
907
{ok , _ } = emqtt :publish (Pub , Topic , <<" msg-6-qos1" >>, qos1 ),
@@ -938,21 +934,20 @@ non_clean_sess_reconnect_qos0_and_qos1(Config) ->
938
934
ClientId = ? FUNCTION_NAME ,
939
935
940
936
C1 = connect (ClientId , Config , non_clean_sess_opts ()),
941
- {ok , _ , [1 , 0 ]} = emqtt :subscribe (C1 , [{Topic1 , qos1 }, {Topic0 , qos0 }]),
942
- ? assertMatch (#{consumers := 1 },
943
- get_global_counters (Config )),
937
+ {ok , _ , [1 , 0 ]} = emqtt :subscribe (C1 , [{Topic1 , qos1 },
938
+ {Topic0 , qos0 }]),
939
+ ok = await_consumer_count (1 , ClientId , 0 , Config ),
940
+ ok = await_consumer_count (1 , ClientId , 1 , Config ),
944
941
945
942
ok = emqtt :disconnect (C1 ),
946
- eventually (? _assertMatch (#{consumers := 0 },
947
- get_global_counters (Config ))),
948
-
943
+ ok = await_consumer_count (0 , ClientId , 0 , Config ),
944
+ ok = await_consumer_count (0 , ClientId , 1 , Config ),
949
945
{ok , _ } = emqtt :publish (Pub , Topic0 , <<" msg-0" >>, qos1 ),
950
946
{ok , _ } = emqtt :publish (Pub , Topic1 , <<" msg-1" >>, qos1 ),
951
947
952
948
C2 = connect (ClientId , Config , non_clean_sess_opts ()),
953
- ? assertMatch (#{consumers := 1 },
954
- get_global_counters (Config )),
955
-
949
+ ok = await_consumer_count (1 , ClientId , 0 , Config ),
950
+ ok = await_consumer_count (1 , ClientId , 1 , Config ),
956
951
ok = expect_publishes (C2 , Topic0 , [<<" msg-0" >>]),
957
952
ok = expect_publishes (C2 , Topic1 , [<<" msg-1" >>]),
958
953
@@ -1868,6 +1863,17 @@ await_confirms_unordered(From, Left) ->
1868
1863
ct :fail (" ~b confirms are missing" , [Left ])
1869
1864
end .
1870
1865
1866
+ await_consumer_count (ConsumerCount , ClientId , QoS , Config ) ->
1867
+ Ch = rabbit_ct_client_helpers :open_channel (Config ),
1868
+ QueueName = rabbit_mqtt_util :queue_name_bin (
1869
+ rabbit_data_coercion :to_binary (ClientId ), QoS ),
1870
+ eventually (
1871
+ ? _assertMatch (
1872
+ # 'queue.declare_ok' {consumer_count = ConsumerCount },
1873
+ amqp_channel :call (Ch , # 'queue.declare' {queue = QueueName ,
1874
+ passive = true })), 500 , 10 ),
1875
+ ok = rabbit_ct_client_helpers :close_channel (Ch ).
1876
+
1871
1877
declare_queue (Ch , QueueName , Args )
1872
1878
when is_pid (Ch ), is_binary (QueueName ), is_list (Args ) ->
1873
1879
# 'queue.declare_ok' {} = amqp_channel :call (
0 commit comments