Skip to content

Commit

Permalink
Merge pull request #12775 from rabbitmq/fix-flakes
Browse files Browse the repository at this point in the history
Fixes for test flakes
  • Loading branch information
dcorbacho authored Nov 25, 2024
2 parents ad2354b + 4a925f9 commit 1fa4fe2
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 164 deletions.
13 changes: 4 additions & 9 deletions deps/oauth2_client/test/system_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ init_per_group(https, Config) ->
CertsDir = ?config(rmq_certsdir, Config0),
CaCertFile = filename:join([CertsDir, "testca", "cacert.pem"]),
WrongCaCertFile = filename:join([CertsDir, "server", "server.pem"]),
[{group, https},
[{group, https},
{oauth_provider_id, <<"uaa">>},
{oauth_provider, build_https_oauth_provider(<<"uaa">>, CaCertFile)},
{oauth_provider_with_issuer, keep_only_issuer_and_ssl_options(
Expand All @@ -122,7 +122,7 @@ init_per_group(https_down, Config) ->

[{issuer, build_issuer("https")},
{oauth_provider_id, <<"uaa">>},
{oauth_provider, build_https_oauth_provider(<<"uaa">>, CaCertFile)} | Config];
{oauth_provider, build_https_oauth_provider(<<"uaa">>, CaCertFile)} | Config0];

init_per_group(openid_configuration_with_path, Config) ->
[{use_openid_configuration_with_path, true} | Config];
Expand All @@ -134,7 +134,7 @@ init_per_group(with_all_oauth_provider_settings, Config) ->

[{with_all_oauth_provider_settings, true},
{oauth_provider_id, <<"uaa">>},
{oauth_provider, build_https_oauth_provider(<<"uaa">>, CaCertFile)} | Config];
{oauth_provider, build_https_oauth_provider(<<"uaa">>, CaCertFile)} | Config0];

init_per_group(without_all_oauth_providers_settings, Config) ->
Config0 = rabbit_ct_helpers:run_setup_steps(Config),
Expand All @@ -144,7 +144,7 @@ init_per_group(without_all_oauth_providers_settings, Config) ->
[{with_all_oauth_provider_settings, false},
{oauth_provider_id, <<"uaa">>},
{oauth_provider, keep_only_issuer_and_ssl_options(
build_https_oauth_provider(<<"uaa">>, CaCertFile))} | Config];
build_https_oauth_provider(<<"uaa">>, CaCertFile))} | Config0];

init_per_group(with_default_oauth_provider, Config) ->
OAuthProvider = ?config(oauth_provider, Config),
Expand Down Expand Up @@ -283,9 +283,6 @@ init_per_testcase(TestCase, Config0) ->
https ->
start_https_oauth_server(?AUTH_PORT, ?config(rmq_certsdir, Config),
ListOfExpectations);
without_all_oauth_providers_settings ->
start_https_oauth_server(?AUTH_PORT, ?config(rmq_certsdir, Config),
ListOfExpectations);
_ ->
do_nothing
end,
Expand All @@ -302,8 +299,6 @@ end_per_testcase(_, Config) ->
case ?config(group, Config) of
https ->
stop_https_auth_server();
without_all_oauth_providers_settings ->
stop_https_auth_server();
_ ->
do_nothing
end,
Expand Down
5 changes: 5 additions & 0 deletions deps/rabbit/test/amqp_client_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ init_per_testcase(Testcase, Config) ->

end_per_testcase(Testcase, Config) ->
%% Assert that every testcase cleaned up.
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, delete_queues, []),
eventually(?_assertEqual([], rpc(Config, rabbit_amqqueue, list, []))),
%% Wait for sessions to terminate before starting the next test case.
eventually(?_assertEqual([], rpc(Config, rabbit_amqp_session, list_local, []))),
Expand All @@ -350,6 +351,10 @@ end_per_testcase(Testcase, Config) ->
get_global_counters(Config))),
rabbit_ct_helpers:testcase_finished(Config, Testcase).

delete_queues() ->
[rabbit_amqqueue:delete(Q, false, false, <<"dummy">>)
|| Q <- rabbit_amqqueue:list()].

reliable_send_receive_with_outcomes_classic_queue(Config) ->
reliable_send_receive_with_outcomes(<<"classic">>, Config).

Expand Down
28 changes: 17 additions & 11 deletions deps/rabbit/test/amqp_filtex_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ properties_section(Config) ->
ok = amqp10_client:flow_link_credit(Receiver1, 10, never),
receive {amqp10_msg, Receiver1, R1M1} ->
?assertEqual([<<"m1">>], amqp10_msg:body(R1M1))
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
ok = assert_no_msg_received(?LINE),
ok = detach_link_sync(Receiver1),
Expand All @@ -183,7 +183,7 @@ properties_section(Config) ->
Session, <<"receiver 3">>, Address,
unsettled, configuration, Filter3),
receive {amqp10_event, {link, Receiver3, {attached, #'v1_0.attach'{}}}} -> ok
after 5000 -> ct:fail({missing_event, ?LINE})
after 30000 -> ct:fail({missing_event, ?LINE})
end,
ok = amqp10_client:flow_link_credit(Receiver3, 10, never),
ok = assert_no_msg_received(?LINE),
Expand All @@ -205,7 +205,7 @@ properties_section(Config) ->
source = #'v1_0.source'{filter = {map, ActualFilter}}}}}} ->
?assertMatch([{{symbol,<<"rabbitmq:stream-offset-spec">>}, _}],
ActualFilter)
after 5000 -> ct:fail({missing_event, ?LINE})
after 30000 -> ct:fail({missing_event, ?LINE})
end,
{ok, R4M1} = amqp10_client:get_msg(Receiver4),
{ok, R4M2} = amqp10_client:get_msg(Receiver4),
Expand Down Expand Up @@ -271,6 +271,12 @@ application_properties_section(Config) ->
{ok, Receiver0} = amqp10_client:attach_receiver_link(
Session, <<"receiver 0">>, Address,
unsettled, configuration, Filter0),
%% Wait for the attach so the detach command won't fail
receive {amqp10_event,
{link, Receiver0, {attached, #'v1_0.attach'{}}}} ->
ok
after 30000 -> ct:fail({missing_event, ?LINE})
end,
ok = amqp10_client:flow_link_credit(Receiver0, 10, never),
ok = assert_no_msg_received(?LINE),
ok = detach_link_sync(Receiver0),
Expand Down Expand Up @@ -298,12 +304,12 @@ application_properties_section(Config) ->
{{utf8, <<"k3">>}, false}
]}},
proplists:get_value({symbol, ?DESCRIPTOR_NAME_APPLICATION_PROPERTIES_FILTER}, ActualFilter1))
after 5000 -> ct:fail({missing_event, ?LINE})
after 30000 -> ct:fail({missing_event, ?LINE})
end,
ok = amqp10_client:flow_link_credit(Receiver1, 10, never),
receive {amqp10_msg, Receiver1, R1M1} ->
?assertEqual([<<"m1">>], amqp10_msg:body(R1M1))
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
ok = assert_no_msg_received(?LINE),
ok = detach_link_sync(Receiver1),
Expand Down Expand Up @@ -358,7 +364,7 @@ application_properties_section(Config) ->
source = #'v1_0.source'{filter = {map, ActualFilter4}}}}}} ->
?assertMatch([{{symbol,<<"rabbitmq:stream-offset-spec">>}, _}],
ActualFilter4)
after 5000 -> ct:fail({missing_event, ?LINE})
after 30000 -> ct:fail({missing_event, ?LINE})
end,
{ok, R4M1} = amqp10_client:get_msg(Receiver4),
{ok, R4M2} = amqp10_client:get_msg(Receiver4),
Expand Down Expand Up @@ -498,12 +504,12 @@ filter_few_messages_from_many(Config) ->
receive {amqp10_msg, Receiver, M1} ->
?assertEqual([<<"first msg">>], amqp10_msg:body(M1)),
ok = amqp10_client:accept_msg(Receiver, M1)
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
receive {amqp10_msg, Receiver, M2} ->
?assertEqual([<<"last msg">>], amqp10_msg:body(M2)),
ok = amqp10_client:accept_msg(Receiver, M2)
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
ok = detach_link_sync(Receiver),

Expand Down Expand Up @@ -576,7 +582,7 @@ string_modifier(Config) ->
ok = amqp10_client:flow_link_credit(Receiver1, 10, never),
receive {amqp10_msg, Receiver1, R1M1} ->
?assertEqual([<<"m1">>], amqp10_msg:body(R1M1))
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
ok = assert_no_msg_received(?LINE),
ok = detach_link_sync(Receiver1),
Expand Down Expand Up @@ -604,11 +610,11 @@ string_modifier(Config) ->
ok = amqp10_client:flow_link_credit(Receiver3, 10, never),
receive {amqp10_msg, Receiver3, R3M1} ->
?assertEqual([<<"m1">>], amqp10_msg:body(R3M1))
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
receive {amqp10_msg, Receiver3, R3M3} ->
?assertEqual([<<"m3">>], amqp10_msg:body(R3M3))
after 5000 -> ct:fail({missing_msg, ?LINE})
after 30000 -> ct:fail({missing_msg, ?LINE})
end,
ok = detach_link_sync(Receiver3),

Expand Down
7 changes: 6 additions & 1 deletion deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,14 @@ ensure_rabbitmq_queues_cmd(Config) ->

ensure_ssl_certs(Config) ->
SrcDir = ?config(rabbitmq_ct_helpers_srcdir, Config),
UniqueDir = io_lib:format(
"~s2-~p",
[node(), erlang:unique_integer([positive,monotonic])]),
CertsMakeDir = filename:join([SrcDir, "tools", "tls-certs"]),
PrivDir = ?config(priv_dir, Config),
CertsDir = filename:join(PrivDir, "certs"),
CertsDir = filename:join([PrivDir, UniqueDir, "certs"]),
_ = filelib:ensure_dir(CertsDir),
_ = file:make_dir(CertsDir),
CertsPwd = proplists:get_value(rmq_certspwd, Config, ?SSL_CERT_PASSWORD),
Cmd = [
"PASSWORD=" ++ CertsPwd,
Expand Down
Loading

0 comments on commit 1fa4fe2

Please sign in to comment.