per_user_connection_tracking_SUITE: Wait for the expected list of connections

[Why]
In CI, we sometimes observe two tracked connections in the return value.
I don't know yet what they are. Could it be a client that reopened its
crashed connection and because stats are updated asynchronously, we get
two tracked connections for a short period of time?
This commit is contained in:
Jean-Sébastien Pédron 2025-08-05 17:38:47 +02:00
parent 53d0b14726
commit ed1cdb5987
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 21 additions and 7 deletions

View File

@ -115,28 +115,42 @@ single_node_list_of_user(Config) ->
[Conn1] = open_connections(Config, [{0, Username1}]), [Conn1] = open_connections(Config, [{0, Username1}]),
?awaitMatch(1, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT), ?awaitMatch(1, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT),
[#tracked_connection{username = Username1}] = connections_in(Config, Username1), ?awaitMatch(
[#tracked_connection{username = Username1}],
connections_in(Config, Username1),
?AWAIT_TIMEOUT),
close_connections([Conn1]), close_connections([Conn1]),
?awaitMatch(0, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT), ?awaitMatch(0, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT),
[Conn2] = open_connections(Config, [{0, Username2}]), [Conn2] = open_connections(Config, [{0, Username2}]),
?awaitMatch(1, count_connections_in(Config, Username2), ?AWAIT_TIMEOUT), ?awaitMatch(1, count_connections_in(Config, Username2), ?AWAIT_TIMEOUT),
[#tracked_connection{username = Username2}] = connections_in(Config, Username2), ?awaitMatch(
[#tracked_connection{username = Username2}],
connections_in(Config, Username2),
?AWAIT_TIMEOUT),
[Conn3] = open_connections(Config, [{0, Username1}]), [Conn3] = open_connections(Config, [{0, Username1}]),
?awaitMatch(1, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT), ?awaitMatch(1, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT),
[#tracked_connection{username = Username1}] = connections_in(Config, Username1), ?awaitMatch(
[#tracked_connection{username = Username1}],
connections_in(Config, Username1),
?AWAIT_TIMEOUT),
[Conn4] = open_connections(Config, [{0, Username1}]), [Conn4] = open_connections(Config, [{0, Username1}]),
kill_connections([Conn4]), kill_connections([Conn4]),
?awaitMatch(1, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT), ?awaitMatch(1, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT),
[#tracked_connection{username = Username1}] = connections_in(Config, Username1), ?awaitMatch(
[#tracked_connection{username = Username1}],
connections_in(Config, Username1),
?AWAIT_TIMEOUT),
[Conn5] = open_connections(Config, [{0, Username1}]), [Conn5] = open_connections(Config, [{0, Username1}]),
?awaitMatch(2, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT), ?awaitMatch(2, count_connections_in(Config, Username1), ?AWAIT_TIMEOUT),
[Username1, Username1] = ?awaitMatch(
lists:map(fun (#tracked_connection{username = U}) -> U end, [Username1, Username1],
connections_in(Config, Username1)), lists:map(fun (#tracked_connection{username = U}) -> U end,
connections_in(Config, Username1)),
?AWAIT_TIMEOUT),
close_connections([Conn2, Conn3, Conn5]), close_connections([Conn2, Conn3, Conn5]),
rabbit_ct_broker_helpers:delete_user(Config, Username2), rabbit_ct_broker_helpers:delete_user(Config, Username2),