Skip to content

Commit 32356ee

Browse files
committed
rabbit_stream_queue_SUITE: Fix consume_and_reject channel close detection
[Why] The previous detection was based on a reuse of the channel to get the error from an exit exception. The problem is that it is very dependent on the timing: if the channel process exits before it is reused, the test fails for two possible reasons: 1. The channel and connection processes exit before they are reused and the channel manager opens a new pair. The problem is that the declare suceeds but the test expected a failure. 2. The channel and connection processes exit during the reuse and `rabbit_ct_client_helpers:open_channel` in `retry_if_coordinator_unavailable()` waits a response from the channel manager forever (this is probably a weakness of the channel manager in rabbitmq_ct_client_helpers). This indefinite wait causes the testcase to timeout. [How] A simpler solution is to monitor the exit reason of the channel process that triggers the error on the server side.
1 parent 42746af commit 32356ee

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

deps/rabbit/test/rabbit_stream_queue_SUITE.erl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,13 +1351,22 @@ consume_and_reject(Config) ->
13511351
subscribe(Ch1, Q, false, 0),
13521352
receive
13531353
{#'basic.deliver'{delivery_tag = DeliveryTag}, _} ->
1354+
MRef = erlang:monitor(process, Ch1),
13541355
ok = amqp_channel:cast(Ch1, #'basic.reject'{delivery_tag = DeliveryTag,
13551356
requeue = true}),
1356-
%% Reject will throw a not implemented exception. As it is a cast operation,
1357-
%% we'll detect the conneciton/channel closure on the next call.
1358-
%% Let's try to redeclare and see what happens
1359-
?assertExit({{shutdown, {connection_closing, {server_initiated_close, 540, _}}}, _},
1360-
declare(Config, Server, Q, [{<<"x-queue-type">>, longstr, <<"stream">>}]))
1357+
%% Reject will throw a not implemented exception. As it is a cast
1358+
%% operation, we detect the connection error from the channel
1359+
%% process exit reason.
1360+
receive
1361+
{'DOWN', MRef, _, _, Reason} ->
1362+
?assertMatch(
1363+
{shutdown,
1364+
{connection_closing,
1365+
{server_initiated_close, 540, _}}},
1366+
Reason)
1367+
after 10000 ->
1368+
exit(timeout)
1369+
end
13611370
after 10000 ->
13621371
exit(timeout)
13631372
end,

0 commit comments

Comments
 (0)