Skip to content

Commit dec93d8

Browse files
Merge pull request #15971 from rabbitmq/mergify/bp/v4.3.x/pr-15970
Test flake chase (Apr 8, 2026) (encore, round 2) (backport #15970)
2 parents 15b06bc + b405d79 commit dec93d8

5 files changed

Lines changed: 58 additions & 28 deletions

File tree

deps/rabbitmq_cli/test/test_helper.exs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,16 @@ defmodule TestHelper do
947947
file
948948
end
949949

950+
do_wait_for_log_message(message, log_file, attempts)
951+
end
952+
953+
defp do_wait_for_log_message(message, log_file, 0) do
954+
flunk(
955+
"Ran out of attempts waiting for #{inspect(message)} to appear in #{inspect(log_file)}"
956+
)
957+
end
958+
959+
defp do_wait_for_log_message(message, log_file, attempts) do
950960
case File.read(log_file) do
951961
{:ok, data} ->
952962
case String.match?(data, Regex.compile!(message)) do
@@ -955,12 +965,12 @@ defmodule TestHelper do
955965

956966
false ->
957967
:timer.sleep(100)
958-
wait_for_log_message(message, log_file, attempts - 1)
968+
do_wait_for_log_message(message, log_file, attempts - 1)
959969
end
960970

961971
_ ->
962972
:timer.sleep(100)
963-
wait_for_log_message(message, log_file, attempts - 1)
973+
do_wait_for_log_message(message, log_file, attempts - 1)
964974
end
965975
end
966976
end

deps/rabbitmq_stomp/test/command_SUITE.erl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
-include_lib("common_test/include/ct.hrl").
1212
-include_lib("eunit/include/eunit.hrl").
1313
-include_lib("amqp_client/include/amqp_client.hrl").
14+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1415
-include("rabbit_stomp.hrl").
1516

1617

@@ -74,17 +75,16 @@ run(Config) ->
7475
StompPort = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_stomp),
7576

7677
{ok, _Client} = rabbit_stomp_client:connect(StompPort),
77-
ct:sleep(100),
78-
79-
[[{session_id, _}]] =
80-
'Elixir.Enum':to_list(?COMMAND:run([<<"session_id">>], Opts)),
81-
78+
%% STOMP connection registration is asynchronous; wait for it to be
79+
%% readable (as in consistency).
80+
?awaitMatch([[{session_id, _}]],
81+
'Elixir.Enum':to_list(?COMMAND:run([<<"session_id">>], Opts)),
82+
30_000),
8283

8384
{ok, _Client2} = rabbit_stomp_client:connect(StompPort),
84-
ct:sleep(100),
85-
86-
[[{session_id, _}], [{session_id, _}]] =
87-
'Elixir.Enum':to_list(?COMMAND:run([<<"session_id">>], Opts)),
85+
?awaitMatch([[{session_id, _}], [{session_id, _}]],
86+
'Elixir.Enum':to_list(?COMMAND:run([<<"session_id">>], Opts)),
87+
30_000),
8888

8989
Port = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp),
9090
start_amqp_connection(network, Node, Port),

deps/rabbitmq_stomp/test/connections_SUITE.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ messages_not_dropped_on_disconnect(Config) ->
9898
StompPort = get_stomp_port(Config),
9999
N = count_connections(Config),
100100
{ok, Client} = rabbit_stomp_client:connect(StompPort),
101+
%% STOMP connection registration is asynchronous; wait for it to be
102+
%% readable (as in consistency).
101103
N1 = N + 1,
102-
N1 = count_connections(Config),
104+
?awaitMatch(N1, count_connections(Config), 30_000),
103105
[rabbit_stomp_client:send(
104106
Client, "SEND", [{"destination", ?DESTINATION}],
105107
[integer_to_list(Count)]) || Count <- lists:seq(1, 1000)],

deps/rabbitmq_stomp/test/proxy_protocol_SUITE.erl

Lines changed: 26 additions & 13 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
-define(TIMEOUT, 5000).
1516

@@ -70,9 +71,8 @@ proxy_protocol_v1(Config) ->
7071
ok = inet:send(Socket, "PROXY TCP4 192.168.1.1 192.168.1.2 80 81\r\n"),
7172
ok = inet:send(Socket, stomp_connect_frame()),
7273
{ok, _Packet} = gen_tcp:recv(Socket, 0, ?TIMEOUT),
73-
ConnectionName = rabbit_ct_broker_helpers:rpc(Config, 0,
74-
?MODULE, connection_name, []),
75-
match = re:run(ConnectionName, <<"^192.168.1.1:80 -> 192.168.1.2:81$">>, [{capture, none}]),
74+
await_connection_name_match(
75+
Config, <<"^192.168.1.1:80 -> 192.168.1.2:81$">>),
7676
gen_tcp:close(Socket),
7777
ok.
7878

@@ -85,9 +85,8 @@ proxy_protocol_v1_tls(Config) ->
8585
{ok, SslSocket} = ssl:connect(Socket, [{verify, verify_none}], ?TIMEOUT),
8686
ok = ssl:send(SslSocket, stomp_connect_frame()),
8787
{ok, _Packet} = ssl:recv(SslSocket, 0, ?TIMEOUT),
88-
ConnectionName = rabbit_ct_broker_helpers:rpc(Config, 0,
89-
?MODULE, connection_name, []),
90-
match = re:run(ConnectionName, <<"^192.168.1.1:80 -> 192.168.1.2:81$">>, [{capture, none}]),
88+
await_connection_name_match(
89+
Config, <<"^192.168.1.1:80 -> 192.168.1.2:81$">>),
9190
gen_tcp:close(Socket),
9291
ok.
9392

@@ -102,17 +101,31 @@ proxy_protocol_v2_local(Config) ->
102101
ok = inet:send(Socket, ranch_proxy_header:header(ProxyInfo)),
103102
ok = inet:send(Socket, stomp_connect_frame()),
104103
{ok, _Packet} = gen_tcp:recv(Socket, 0, ?TIMEOUT),
105-
ConnectionName = rabbit_ct_broker_helpers:rpc(Config, 0,
106-
?MODULE, connection_name, []),
107-
match = re:run(ConnectionName, <<"^127.0.0.1:\\d+ -> 127.0.0.1:\\d+$">>, [{capture, none}]),
104+
await_connection_name_match(
105+
Config, <<"^127.0.0.1:\\d+ -> 127.0.0.1:\\d+$">>),
108106
gen_tcp:close(Socket),
109107
ok.
110108

111-
connection_name() ->
109+
%% The `connection_created' ETS table is populated asynchronously by
110+
%% the management agent; wait for an entry whose `name' matches the
111+
%% pattern.
112+
await_connection_name_match(Config, Pattern) ->
113+
?awaitMatch(true,
114+
rabbit_ct_broker_helpers:rpc(
115+
Config, 0, ?MODULE, has_connection_name_matching, [Pattern]),
116+
30_000).
117+
118+
has_connection_name_matching(Pattern) ->
112119
Connections = ets:tab2list(connection_created),
113-
{_Key, Values} = lists:nth(1, Connections),
114-
{_, Name} = lists:keyfind(name, 1, Values),
115-
Name.
120+
lists:any(
121+
fun({_Key, Values}) ->
122+
case lists:keyfind(name, 1, Values) of
123+
{_, Name} ->
124+
re:run(Name, Pattern, [{capture, none}]) =:= match;
125+
false ->
126+
false
127+
end
128+
end, Connections).
116129

117130
merge_app_env(StompConfig, Config) ->
118131
rabbit_ct_helpers:merge_app_env(Config, StompConfig).

deps/rabbitmq_stomp/test/topic_SUITE.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
-include_lib("common_test/include/ct.hrl").
1313
-include_lib("eunit/include/eunit.hrl").
1414
-include_lib("amqp_client/include/amqp_client.hrl").
15+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1516
-include("rabbit_stomp.hrl").
1617
-include("rabbit_stomp_frame.hrl").
1718
all() ->
@@ -191,9 +192,13 @@ change_default_topic_exchange(Config) ->
191192
{"id", "s0"},
192193
{"durable", "true"}]),
193194

194-
timer:sleep(500),
195-
196-
1 = length(rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_binding, list_for_source, [#resource{virtual_host= <<"/">>, kind = exchange, name = Ex}])),
195+
%% STOMP SUBSCRIBE creates the binding asynchronously; wait for it
196+
%% to be readable (as in consistency).
197+
?awaitMatch(1,
198+
length(rabbit_ct_broker_helpers:rpc(
199+
Config, 0, rabbit_binding, list_for_source,
200+
[#resource{virtual_host = <<"/">>, kind = exchange, name = Ex}])),
201+
30_000),
197202

198203
rabbit_stomp_client:send(
199204
ClientFoo, "SEND", [{"destination", AuthorisedTopic}], ["ohai there"]),

0 commit comments

Comments
 (0)