diff options
author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2019-08-14 15:49:04 +0200 |
---|---|---|
committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2019-08-14 15:49:04 +0200 |
commit | 84c59b76fd50998635a23c44c9c78872520c512c (patch) | |
tree | bf8002aa386c2e0606d46fe0e5275f153c2917a3 | |
parent | 265ddce2158a9ef3110751182ba32710fffcad1c (diff) | |
download | rabbitmq-server-git-84c59b76fd50998635a23c44c9c78872520c512c.tar.gz |
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.
-rw-r--r-- | test/channel_source_SUITE.erl | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/channel_source_SUITE.erl b/test/channel_source_SUITE.erl index d56e9fed0f..8ee865925d 100644 --- a/test/channel_source_SUITE.erl +++ b/test/channel_source_SUITE.erl @@ -17,6 +17,7 @@ -module(channel_source_SUITE). -include_lib("amqp_client/include/amqp_client.hrl"). +-include_lib("eunit/include/eunit.hrl"). -compile(export_all). @@ -85,7 +86,7 @@ network_rabbit_reader_channel_source1(Config) -> [{source, ?MODULE}] = rabbit_channel:info(ServerCh, [source]), amqp_channel:close(ClientCh), amqp_connection:close(Conn), - {error, channel_terminated} = rabbit_channel:source(ServerCh, ?MODULE), + wait_for_channel_termination(ServerCh, 60), passed. network_arbitrary_channel_source(Config) -> @@ -108,7 +109,7 @@ network_arbitrary_channel_source1(Config) -> [{source, ?MODULE}] = rabbit_channel:info(Ch, [source]), [exit(P, normal) || P <- [Writer, Limiter, Collector, Ch]], amqp_connection:close(Conn), - {error, channel_terminated} = rabbit_channel:source(Ch, ?MODULE), + wait_for_channel_termination(Ch, 60), passed. direct_channel_source(Config) -> @@ -125,9 +126,22 @@ direct_channel_source1(Config) -> [{source, ?MODULE}] = rabbit_channel:info(ServerCh, [source]), amqp_channel:close(ClientCh), amqp_connection:close(Conn), - {error, channel_terminated} = rabbit_channel:source(ServerCh, ?MODULE), + wait_for_channel_termination(ServerCh, 60), passed. +wait_for_channel_termination(Ch, 0) -> + ?assertEqual( + {error, channel_terminated}, + rabbit_channel:source(Ch, ?MODULE)); +wait_for_channel_termination(Ch, Attempts) -> + case rabbit_channel:source(Ch, ?MODULE) of + {error, channel_terminated} -> + ok; + _ -> + timer:sleep(1000), + wait_for_channel_termination(Ch, Attempts - 1) + end. + undefined_channel_source(Config) -> passed = rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, undefined_channel_source1, [Config]). @@ -142,7 +156,7 @@ undefined_channel_source1(_Config) -> passed. wait_for_server_channel(ExistingChannels, ServerCh, 0) -> - [ServerCh] = rabbit_channel:list() -- ExistingChannels; + ?assertEqual([ServerCh], rabbit_channel:list() -- ExistingChannels); wait_for_server_channel(ExistingChannels, ServerCh, Attempts) -> case rabbit_channel:list() -- ExistingChannels of [ServerCh] -> |