Skip to content

Commit 8dfe26c

Browse files
committed
per_node_limit_SUITE: Wait for the channel count to be up-to-date
[Why] In the `node_channel_limit` testcase, we open several channels and verify the count of opened channels in all places but one: after the first connection failure, when we try to open 3 channels. Opening 3 channels in a row might not be tracked in time to reject the third channel because the counter is updated asynchronously. [How] We simply wait for the counter to reach 5 before opening the third channel. We change all checks to use `?awaitMatch/3` in the process to be more robust with timing issues.
1 parent bb89366 commit 8dfe26c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

deps/rabbit/test/per_node_limit_SUITE.erl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
-include_lib("common_test/include/ct.hrl").
1111
-include_lib("amqp_client/include/amqp_client.hrl").
1212
-include_lib("eunit/include/eunit.hrl").
13+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1314

1415
-compile(export_all).
1516

@@ -120,27 +121,28 @@ node_channel_limit(Config) ->
120121
ok = rabbit_ct_broker_helpers:set_full_permissions(Config, User, VHost),
121122
Conn1 = rabbit_ct_client_helpers:open_unmanaged_connection(Config, 0, VHost),
122123
Conn2 = rabbit_ct_client_helpers:open_unmanaged_connection(Config, 0, VHost),
123-
0 = count_channels_per_node(Config),
124+
?awaitMatch(0, count_channels_per_node(Config), 30000),
124125

125126
lists:foreach(fun(N) when (N band 1) == 1 -> {ok, _} = open_channel(Conn1);
126127
(_) -> {ok,_ } = open_channel(Conn2)
127128
end, lists:seq(1, 5)),
128129

129-
5 = count_channels_per_node(Config),
130+
?awaitMatch(5, count_channels_per_node(Config), 30000),
130131
%% In total 5 channels are open on this node, so a new one, regardless of
131132
%% connection, will not be allowed. It will terminate the connection with
132133
%% its channels too. So
133134
{error, not_allowed_crash} = open_channel(Conn2),
134-
3 = count_channels_per_node(Config),
135+
?awaitMatch(3, count_channels_per_node(Config), 30000),
135136
%% As the connection is dead, so are the 2 channels, so we should be able to
136137
%% create 2 more on Conn1
137138
{ok , _} = open_channel(Conn1),
138139
{ok , _} = open_channel(Conn1),
140+
?awaitMatch(5, count_channels_per_node(Config), 30000),
139141
%% But not a third
140142
{error, not_allowed_crash} = open_channel(Conn1),
141143

142144
%% Now all connections are closed, so there should be 0 open connections
143-
0 = count_channels_per_node(Config),
145+
?awaitMatch(0, count_channels_per_node(Config), 30000),
144146
close_all_connections([Conn1, Conn2]),
145147

146148
rabbit_ct_broker_helpers:delete_vhost(Config, VHost),

0 commit comments

Comments
 (0)