Skip to content

Commit 6084055

Browse files
committed
amqp_client_SUITE: Ensure idle_time_out_on_server restores heartbeat value
[Why] If the testcase fails, it was leaving the low heartbeat value in place, leading to many subsequent tests to fail.
1 parent 603ad0d commit 6084055

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

deps/rabbit/test/amqp_client_SUITE.erl

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,43 +4610,45 @@ plugin(Config) ->
46104610
idle_time_out_on_server(Config) ->
46114611
App = rabbit,
46124612
Par = heartbeat,
4613-
{ok, DefaultVal} = rpc(Config, application, get_env, [App, Par]),
4614-
%% Configure RabbitMQ to use an idle-time-out of 1 second.
4615-
ok = rpc(Config, application, set_env, [App, Par, 1]),
4616-
4617-
OpnConf = connection_config(Config),
4618-
{ok, Connection} = amqp10_client:open_connection(OpnConf),
4619-
receive {amqp10_event, {connection, Connection, opened}} -> ok
4620-
after 30000 -> ct:fail({missing_event, ?LINE})
4621-
end,
4622-
4623-
%% Mock the server socket to not have received any bytes.
4624-
rabbit_ct_broker_helpers:setup_meck(Config),
46254613
Mod = rabbit_net,
4626-
ok = rpc(Config, meck, new, [Mod, [no_link, passthrough]]),
4627-
ok = rpc(Config, meck, expect, [Mod, getstat, fun(_Sock, [recv_oct]) ->
4628-
{ok, [{recv_oct, 999}]};
4629-
(Sock, Opts) ->
4630-
meck:passthrough([Sock, Opts])
4631-
end]),
4632-
4633-
%% The server "SHOULD try to gracefully close the connection using a close
4634-
%% frame with an error explaining why" [2.4.5].
4635-
%% Since we chose a heartbeat value of 1 second, the server should easily
4636-
%% close the connection within 5 seconds.
4637-
receive
4638-
{amqp10_event,
4639-
{connection, Connection,
4640-
{closed,
4641-
{resource_limit_exceeded,
4642-
<<"no frame received from client within idle timeout threshold">>}}}} -> ok
4643-
after 30000 ->
4644-
ct:fail({missing_event, ?LINE})
4645-
end,
4646-
4647-
?assert(rpc(Config, meck, validate, [Mod])),
4648-
ok = rpc(Config, meck, unload, [Mod]),
4649-
ok = rpc(Config, application, set_env, [App, Par, DefaultVal]).
4614+
{ok, DefaultVal} = rpc(Config, application, get_env, [App, Par]),
4615+
try
4616+
%% Configure RabbitMQ to use an idle-time-out of 1 second.
4617+
ok = rpc(Config, application, set_env, [App, Par, 1]),
4618+
4619+
OpnConf = connection_config(Config),
4620+
{ok, Connection} = amqp10_client:open_connection(OpnConf),
4621+
receive {amqp10_event, {connection, Connection, opened}} -> ok
4622+
after 30000 -> ct:fail({missing_event, ?LINE})
4623+
end,
4624+
4625+
%% Mock the server socket to not have received any bytes.
4626+
rabbit_ct_broker_helpers:setup_meck(Config),
4627+
ok = rpc(Config, meck, new, [Mod, [no_link, passthrough]]),
4628+
ok = rpc(Config, meck, expect, [Mod, getstat, fun(_Sock, [recv_oct]) ->
4629+
{ok, [{recv_oct, 999}]};
4630+
(Sock, Opts) ->
4631+
meck:passthrough([Sock, Opts])
4632+
end]),
4633+
4634+
%% The server "SHOULD try to gracefully close the connection using a close
4635+
%% frame with an error explaining why" [2.4.5].
4636+
%% Since we chose a heartbeat value of 1 second, the server should easily
4637+
%% close the connection within 5 seconds.
4638+
receive
4639+
{amqp10_event,
4640+
{connection, Connection,
4641+
{closed,
4642+
{resource_limit_exceeded,
4643+
<<"no frame received from client within idle timeout threshold">>}}}} -> ok
4644+
after 30000 ->
4645+
ct:fail({missing_event, ?LINE})
4646+
end
4647+
after
4648+
?assert(rpc(Config, meck, validate, [Mod])),
4649+
ok = rpc(Config, meck, unload, [Mod]),
4650+
ok = rpc(Config, application, set_env, [App, Par, DefaultVal])
4651+
end.
46504652

46514653
%% Test that the idle timeout threshold is exceeded on the client
46524654
%% when no frames are sent from server to client.

0 commit comments

Comments
 (0)