Skip to content

Commit 308f690

Browse files
committed
per_vhost_connection_limit_partitions: Check connections count in a loop
It should fix transient failures in CI. (cherry picked from commit 1e2a202)
1 parent 592ca47 commit 308f690

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/per_vhost_connection_limit_partitions_SUITE.erl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ cluster_full_partition_with_autoheal(Config) ->
107107
Conn4 = open_unmanaged_connection(Config, B),
108108
Conn5 = open_unmanaged_connection(Config, C),
109109
Conn6 = open_unmanaged_connection(Config, C),
110-
?assertEqual(6, count_connections_in(Config, VHost)),
110+
wait_for_count_connections_in(Config, VHost, 6, 60000),
111111

112112
%% B drops off the network, non-reachable by either A or C
113113
rabbit_ct_broker_helpers:block_traffic_between(A, B),
114114
rabbit_ct_broker_helpers:block_traffic_between(B, C),
115115
timer:sleep(?DELAY),
116116

117117
%% A and C are still connected, so 4 connections are tracked
118-
?assertEqual(4, count_connections_in(Config, VHost)),
118+
wait_for_count_connections_in(Config, VHost, 4, 60000),
119119

120120
rabbit_ct_broker_helpers:allow_traffic_between(A, B),
121121
rabbit_ct_broker_helpers:allow_traffic_between(B, C),
122122
timer:sleep(?DELAY),
123123

124124
%% during autoheal B's connections were dropped
125-
?assertEqual(4, count_connections_in(Config, VHost)),
125+
wait_for_count_connections_in(Config, VHost, 4, 60000),
126126

127127
lists:foreach(fun (Conn) ->
128128
(catch rabbit_ct_client_helpers:close_connection(Conn))
@@ -131,11 +131,22 @@ cluster_full_partition_with_autoheal(Config) ->
131131

132132
passed.
133133

134-
135134
%% -------------------------------------------------------------------
136135
%% Helpers
137136
%% -------------------------------------------------------------------
138137

138+
wait_for_count_connections_in(Config, VHost, Expected, Time) when Time =< 0 ->
139+
?assertEqual(Expected, count_connections_in(Config, VHost));
140+
wait_for_count_connections_in(Config, VHost, Expected, Time) ->
141+
case count_connections_in(Config, VHost) of
142+
Expected ->
143+
ok;
144+
_ ->
145+
Sleep = 3000,
146+
timer:sleep(Sleep),
147+
wait_for_count_connections_in(Config, VHost, Expected, Time - Sleep)
148+
end.
149+
139150
count_connections_in(Config, VHost) ->
140151
count_connections_in(Config, VHost, 0).
141152
count_connections_in(Config, VHost, NodeIndex) ->

0 commit comments

Comments
 (0)