Skip to content

Commit 653ae36

Browse files
committed
queue_type_SUITE, rabbit_stream_queue_SUITE: Be explicit about connection open+close
[Why] The tests relied on `rabbit_ct_client_helpers` connection and channel manager which doesn't seem to be robust. It causes more harm than helps so far. Hopefully, this will fix some test flakes in CI.
1 parent 916ccca commit 653ae36

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

deps/rabbit/test/queue_type_SUITE.erl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ end_per_testcase(Testcase, Config) ->
111111

112112
smoke(Config) ->
113113
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
114-
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
114+
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, Server),
115115
QName = ?config(queue_name, Config),
116116
?assertEqual({'queue.declare_ok', QName, 0, 0},
117117
declare(Ch, QName, [{<<"x-queue-type">>, longstr,
@@ -191,7 +191,7 @@ smoke(Config) ->
191191
}, ProtocolQueueTypeCounters),
192192

193193

194-
ok = rabbit_ct_client_helpers:close_channel(Ch),
194+
ok = rabbit_ct_client_helpers:close_connection_and_channel(Conn, Ch),
195195

196196
?assertMatch(
197197
#{consumers := 0,
@@ -202,7 +202,7 @@ smoke(Config) ->
202202

203203
ack_after_queue_delete(Config) ->
204204
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
205-
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
205+
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, Server),
206206
QName = ?config(queue_name, Config),
207207
?assertEqual({'queue.declare_ok', QName, 0, 0},
208208
declare(Ch, QName, [{<<"x-queue-type">>, longstr,
@@ -223,12 +223,13 @@ ack_after_queue_delete(Config) ->
223223
after 1000 ->
224224
ok
225225
end,
226+
ok = rabbit_ct_client_helpers:close_connection_and_channel(Conn, Ch),
226227
flush(),
227228
ok.
228229

229230
stream(Config) ->
230231
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
231-
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
232+
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, Server),
232233
QName = ?config(queue_name, Config),
233234
?assertEqual({'queue.declare_ok', QName, 0, 0},
234235
declare(Ch, QName, [{<<"x-queue-type">>, longstr,
@@ -238,7 +239,7 @@ stream(Config) ->
238239
publish_and_confirm(Ch, QName, <<"msg1">>),
239240
Args = [{<<"x-stream-offset">>, longstr, <<"last">>}],
240241

241-
SubCh = rabbit_ct_client_helpers:open_channel(Config, 2),
242+
{SubConn, SubCh} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 2),
242243
qos(SubCh, 10, false),
243244
ok = queue_utils:wait_for_local_stream_member(2, <<"/">>, QName, Config),
244245

@@ -262,6 +263,8 @@ stream(Config) ->
262263
exit(Err)
263264
end,
264265

266+
ok = rabbit_ct_client_helpers:close_connection_and_channel(SubConn, SubCh),
267+
ok = rabbit_ct_client_helpers:close_connection_and_channel(Conn, Ch),
265268

266269
ok.
267270

deps/rabbit/test/rabbit_stream_queue_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,10 +2729,10 @@ retry_if_coordinator_unavailable(Config, Server, Cmd) ->
27292729
retry_if_coordinator_unavailable(_, _, _, 0) ->
27302730
exit(coordinator_unavailable);
27312731
retry_if_coordinator_unavailable(Config, Server, Cmd, Retry) ->
2732-
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
2732+
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, Server),
27332733
try
27342734
Reply = amqp_channel:call(Ch, Cmd),
2735-
rabbit_ct_client_helpers:close_channel(Ch),
2735+
rabbit_ct_client_helpers:close_connection_and_channel(Conn, Ch),
27362736
Reply
27372737
catch
27382738
exit:{{shutdown, {connection_closing, {server_initiated_close, _, Msg}}}, _} = Error ->

0 commit comments

Comments
 (0)