Skip to content

Commit 84c59b7

Browse files
committed
channel_source_SUITE: Wait for channel termination
... which could take some time after connection close. This is mostly a guess, based on the transient failures I see in CI. Hopefully it will help there.
1 parent 265ddce commit 84c59b7

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

test/channel_source_SUITE.erl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
-module(channel_source_SUITE).
1818

1919
-include_lib("amqp_client/include/amqp_client.hrl").
20+
-include_lib("eunit/include/eunit.hrl").
2021

2122
-compile(export_all).
2223

@@ -85,7 +86,7 @@ network_rabbit_reader_channel_source1(Config) ->
8586
[{source, ?MODULE}] = rabbit_channel:info(ServerCh, [source]),
8687
amqp_channel:close(ClientCh),
8788
amqp_connection:close(Conn),
88-
{error, channel_terminated} = rabbit_channel:source(ServerCh, ?MODULE),
89+
wait_for_channel_termination(ServerCh, 60),
8990
passed.
9091

9192
network_arbitrary_channel_source(Config) ->
@@ -108,7 +109,7 @@ network_arbitrary_channel_source1(Config) ->
108109
[{source, ?MODULE}] = rabbit_channel:info(Ch, [source]),
109110
[exit(P, normal) || P <- [Writer, Limiter, Collector, Ch]],
110111
amqp_connection:close(Conn),
111-
{error, channel_terminated} = rabbit_channel:source(Ch, ?MODULE),
112+
wait_for_channel_termination(Ch, 60),
112113
passed.
113114

114115
direct_channel_source(Config) ->
@@ -125,9 +126,22 @@ direct_channel_source1(Config) ->
125126
[{source, ?MODULE}] = rabbit_channel:info(ServerCh, [source]),
126127
amqp_channel:close(ClientCh),
127128
amqp_connection:close(Conn),
128-
{error, channel_terminated} = rabbit_channel:source(ServerCh, ?MODULE),
129+
wait_for_channel_termination(ServerCh, 60),
129130
passed.
130131

132+
wait_for_channel_termination(Ch, 0) ->
133+
?assertEqual(
134+
{error, channel_terminated},
135+
rabbit_channel:source(Ch, ?MODULE));
136+
wait_for_channel_termination(Ch, Attempts) ->
137+
case rabbit_channel:source(Ch, ?MODULE) of
138+
{error, channel_terminated} ->
139+
ok;
140+
_ ->
141+
timer:sleep(1000),
142+
wait_for_channel_termination(Ch, Attempts - 1)
143+
end.
144+
131145
undefined_channel_source(Config) ->
132146
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
133147
?MODULE, undefined_channel_source1, [Config]).
@@ -142,7 +156,7 @@ undefined_channel_source1(_Config) ->
142156
passed.
143157

144158
wait_for_server_channel(ExistingChannels, ServerCh, 0) ->
145-
[ServerCh] = rabbit_channel:list() -- ExistingChannels;
159+
?assertEqual([ServerCh], rabbit_channel:list() -- ExistingChannels);
146160
wait_for_server_channel(ExistingChannels, ServerCh, Attempts) ->
147161
case rabbit_channel:list() -- ExistingChannels of
148162
[ServerCh] ->

0 commit comments

Comments
 (0)