Skip to content

Commit ca6f270

Browse files
authored
Merge pull request #9006 from rabbitmq/fix-rabbit_stream_queue_SUITE-consume_and_reject-test
rabbit_stream_queue_SUITE: Fix `consume_and_reject` channel close detection
2 parents 42746af + 6c83939 commit ca6f270

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-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,

deps/rabbitmq_ct_client_helpers/src/rabbit_ct_client_helpers.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ open_channel(Config, Node) ->
217217
Pid ! {open_channel, self()},
218218
receive
219219
Ch when is_pid(Ch) -> Ch
220+
after 60_000 ->
221+
ct:fail("Timed out waiting for connection to open")
220222
end.
221223

222224
open_connection_and_channel(Config) ->

0 commit comments

Comments
 (0)