Skip to content

Commit c7e6e6d

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 fbf18f1 commit c7e6e6d

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

deps/rabbit/test/amqp_client_SUITE.erl

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4670,43 +4670,45 @@ plugin(Config) ->
46704670
idle_time_out_on_server(Config) ->
46714671
App = rabbit,
46724672
Par = heartbeat,
4673+
Mod = rabbit_net,
46734674
{ok, DefaultVal} = rpc(Config, application, get_env, [App, Par]),
4674-
%% Configure RabbitMQ to use an idle-time-out of 1 second.
4675-
ok = rpc(Config, application, set_env, [App, Par, 1]),
4676-
4677-
OpnConf = connection_config(Config),
4678-
{ok, Connection} = amqp10_client:open_connection(OpnConf),
4679-
receive {amqp10_event, {connection, Connection, opened}} -> ok
4680-
after 30000 -> ct:fail({missing_event, ?LINE})
4681-
end,
4675+
try
4676+
%% Configure RabbitMQ to use an idle-time-out of 1 second.
4677+
ok = rpc(Config, application, set_env, [App, Par, 1]),
46824678

4683-
%% Mock the server socket to not have received any bytes.
4684-
rabbit_ct_broker_helpers:setup_meck(Config),
4685-
Mod = rabbit_net,
4686-
ok = rpc(Config, meck, new, [Mod, [no_link, passthrough]]),
4687-
ok = rpc(Config, meck, expect, [Mod, getstat, fun(_Sock, [recv_oct]) ->
4688-
{ok, [{recv_oct, 999}]};
4689-
(Sock, Opts) ->
4690-
meck:passthrough([Sock, Opts])
4691-
end]),
4692-
4693-
%% The server "SHOULD try to gracefully close the connection using a close
4694-
%% frame with an error explaining why" [2.4.5].
4695-
%% Since we chose a heartbeat value of 1 second, the server should easily
4696-
%% close the connection within 5 seconds.
4697-
receive
4698-
{amqp10_event,
4699-
{connection, Connection,
4700-
{closed,
4701-
{resource_limit_exceeded,
4702-
<<"no frame received from client within idle timeout threshold">>}}}} -> ok
4703-
after 30000 ->
4704-
ct:fail({missing_event, ?LINE})
4705-
end,
4679+
OpnConf = connection_config(Config),
4680+
{ok, Connection} = amqp10_client:open_connection(OpnConf),
4681+
receive {amqp10_event, {connection, Connection, opened}} -> ok
4682+
after 30000 -> ct:fail({missing_event, ?LINE})
4683+
end,
47064684

4707-
?assert(rpc(Config, meck, validate, [Mod])),
4708-
ok = rpc(Config, meck, unload, [Mod]),
4709-
ok = rpc(Config, application, set_env, [App, Par, DefaultVal]).
4685+
%% Mock the server socket to not have received any bytes.
4686+
rabbit_ct_broker_helpers:setup_meck(Config),
4687+
ok = rpc(Config, meck, new, [Mod, [no_link, passthrough]]),
4688+
ok = rpc(Config, meck, expect, [Mod, getstat, fun(_Sock, [recv_oct]) ->
4689+
{ok, [{recv_oct, 999}]};
4690+
(Sock, Opts) ->
4691+
meck:passthrough([Sock, Opts])
4692+
end]),
4693+
4694+
%% The server "SHOULD try to gracefully close the connection using a close
4695+
%% frame with an error explaining why" [2.4.5].
4696+
%% Since we chose a heartbeat value of 1 second, the server should easily
4697+
%% close the connection within 5 seconds.
4698+
receive
4699+
{amqp10_event,
4700+
{connection, Connection,
4701+
{closed,
4702+
{resource_limit_exceeded,
4703+
<<"no frame received from client within idle timeout threshold">>}}}} -> ok
4704+
after 30000 ->
4705+
ct:fail({missing_event, ?LINE})
4706+
end
4707+
after
4708+
?assert(rpc(Config, meck, validate, [Mod])),
4709+
ok = rpc(Config, meck, unload, [Mod]),
4710+
ok = rpc(Config, application, set_env, [App, Par, DefaultVal])
4711+
end.
47104712

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

0 commit comments

Comments
 (0)