Skip to content

Commit cf9fd54

Browse files
committed
auth_SUITE: Wait for connection tracking to be up-to-date
... when testing vhost limits [Why] The tracking is aynchronous, thus the third MQTT connection might be opened before the tracking is up-to-date, which the testcase doesn't expect.
1 parent 825824c commit cf9fd54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

deps/rabbitmq_mqtt/test/auth_SUITE.erl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
-include_lib("common_test/include/ct.hrl").
1212
-include_lib("eunit/include/eunit.hrl").
13+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1314

1415
%% not defined in v3
1516
-define(SUBACK_FAILURE, 16#80).
@@ -1246,6 +1247,7 @@ vhost_connection_limit(Config) ->
12461247
{ok, _} = emqtt:connect(C1),
12471248
{ok, C2} = connect_anonymous(Config, <<"client2">>),
12481249
{ok, _} = emqtt:connect(C2),
1250+
?awaitMatch(2, count_connections_per_vhost(Config), 30000),
12491251
{ok, C3} = connect_anonymous(Config, <<"client3">>),
12501252
ExpectedError = expected_connection_limit_error(Config),
12511253
unlink(C3),
@@ -1254,6 +1256,13 @@ vhost_connection_limit(Config) ->
12541256
ok = emqtt:disconnect(C2),
12551257
ok = rabbit_ct_broker_helpers:clear_vhost_limit(Config, 0, <<"/">>).
12561258

1259+
count_connections_per_vhost(Config) ->
1260+
NodeConfig = rabbit_ct_broker_helpers:get_node_config(Config, 0),
1261+
rabbit_ct_broker_helpers:rpc(
1262+
Config, 0,
1263+
rabbit_connection_tracking, count_local_tracked_items_in_vhost,
1264+
[<<"/">>]).
1265+
12571266
vhost_queue_limit(Config) ->
12581267
ok = rabbit_ct_broker_helpers:set_vhost_limit(Config, 0, <<"/">>, max_queues, 1),
12591268
{ok, C} = connect_anonymous(Config),

0 commit comments

Comments
 (0)