Skip to content

Commit 5c0cf89

Browse files
author
Daniil Fedotov
committed
Move test fixes from unit_inbroker to backing_queue
1 parent 3716131 commit 5c0cf89

File tree

2 files changed

+35
-3164
lines changed

2 files changed

+35
-3164
lines changed

test/backing_queue_SUITE.erl

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
-compile(export_all).
2323

24-
-define(PERSISTENT_MSG_STORE, msg_store_persistent_vhost).
25-
-define(TRANSIENT_MSG_STORE, msg_store_transient_vhost).
24+
-define(PERSISTENT_MSG_STORE, msg_store_persistent).
25+
-define(TRANSIENT_MSG_STORE, msg_store_transient).
2626

2727
-define(TIMEOUT, 30000).
28+
-define(VHOST, <<"/">>).
2829

2930
-define(VARIABLE_QUEUE_TESTCASES, [
3031
variable_queue_dynamic_duration_change,
@@ -253,9 +254,9 @@ msg_store1(_Config) ->
253254
MSCState4 = msg_store_read(MsgIds2ndHalf, MSCState3),
254255
ok = rabbit_msg_store:client_terminate(MSCState4),
255256
%% stop and restart, preserving every other msg in 2nd half
256-
ok = rabbit_variable_queue:stop_msg_store(),
257-
ok = rabbit_variable_queue:start_msg_store(
258-
#{}, {fun ([]) -> finished;
257+
ok = rabbit_variable_queue:stop_msg_store(?VHOST),
258+
ok = rabbit_variable_queue:start_msg_store(?VHOST,
259+
[], {fun ([]) -> finished;
259260
([MsgId|MsgIdsTail])
260261
when length(MsgIdsTail) rem 2 == 0 ->
261262
{MsgId, 1, MsgIdsTail};
@@ -330,8 +331,8 @@ msg_store1(_Config) ->
330331
passed.
331332

332333
restart_msg_store_empty() ->
333-
ok = rabbit_variable_queue:stop_msg_store(),
334-
ok = rabbit_variable_queue:start_msg_store(
334+
ok = rabbit_variable_queue:stop_msg_store(?VHOST),
335+
ok = rabbit_variable_queue:start_msg_store(?VHOST,
335336
undefined, {fun (ok) -> finished end, ok}).
336337

337338
msg_id_bin(X) ->
@@ -376,10 +377,10 @@ on_disk_stop(Pid) ->
376377

377378
msg_store_client_init_capture(MsgStore, Ref) ->
378379
Pid = spawn(fun on_disk_capture/0),
379-
{Pid, rabbit_msg_store_vhost_sup:client_init(
380-
MsgStore, Ref, fun (MsgIds, _ActionTaken) ->
381-
Pid ! {on_disk, MsgIds}
382-
end, undefined, <<"/">>)}.
380+
{Pid, rabbit_vhost_msg_store:client_init(?VHOST, MsgStore, Ref,
381+
fun (MsgIds, _ActionTaken) ->
382+
Pid ! {on_disk, MsgIds}
383+
end, undefined)}.
383384

384385
msg_store_contains(Atom, MsgIds, MSCState) ->
385386
Atom = lists:foldl(
@@ -456,14 +457,16 @@ test_msg_store_confirm_timer() ->
456457
Ref = rabbit_guid:gen(),
457458
MsgId = msg_id_bin(1),
458459
Self = self(),
459-
MSCState = rabbit_msg_store_vhost_sup:client_init(
460-
?PERSISTENT_MSG_STORE, Ref,
461-
fun (MsgIds, _ActionTaken) ->
462-
case gb_sets:is_member(MsgId, MsgIds) of
463-
true -> Self ! on_disk;
464-
false -> ok
465-
end
466-
end, undefined, <<"/">>),
460+
MSCState = rabbit_vhost_msg_store:client_init(
461+
?VHOST,
462+
?PERSISTENT_MSG_STORE,
463+
Ref,
464+
fun (MsgIds, _ActionTaken) ->
465+
case gb_sets:is_member(MsgId, MsgIds) of
466+
true -> Self ! on_disk;
467+
false -> ok
468+
end
469+
end, undefined),
467470
ok = msg_store_write([MsgId], MSCState),
468471
ok = msg_store_keep_busy_until_confirm([msg_id_bin(2)], MSCState, false),
469472
ok = msg_store_remove([MsgId], MSCState),
@@ -651,8 +654,8 @@ bq_queue_index1(_Config) ->
651654
Qi8
652655
end),
653656

654-
ok = rabbit_variable_queue:stop(),
655-
{ok, _} = rabbit_variable_queue:start([]),
657+
ok = rabbit_variable_queue:stop(?VHOST),
658+
{ok, _} = rabbit_variable_queue:start(?VHOST, []),
656659

657660
passed.
658661

@@ -672,8 +675,8 @@ bq_queue_index_props1(_Config) ->
672675
Qi2
673676
end),
674677

675-
ok = rabbit_variable_queue:stop(),
676-
{ok, _} = rabbit_variable_queue:start([]),
678+
ok = rabbit_variable_queue:stop(?VHOST),
679+
{ok, _} = rabbit_variable_queue:start(?VHOST, []),
677680

678681
passed.
679682

@@ -718,16 +721,16 @@ bq_queue_recover1(Config) ->
718721
true, false, [], none, <<"acting-user">>),
719722
publish_and_confirm(Q, <<>>, Count),
720723

721-
SupPid = rabbit_ct_broker_helpers:get_queue_sup_pid(QPid),
724+
SupPid = rabbit_ct_broker_helpers:get_queue_sup_pid(Q),
722725
true = is_pid(SupPid),
723726
exit(SupPid, kill),
724727
exit(QPid, kill),
725728
MRef = erlang:monitor(process, QPid),
726729
receive {'DOWN', MRef, process, QPid, _Info} -> ok
727730
after 10000 -> exit(timeout_waiting_for_queue_death)
728731
end,
729-
rabbit_amqqueue:stop(),
730-
rabbit_amqqueue:start(rabbit_amqqueue:recover()),
732+
rabbit_amqqueue:stop(?VHOST),
733+
rabbit_amqqueue:start(rabbit_amqqueue:recover(?VHOST)),
731734
{ok, Limiter} = rabbit_limiter:start_link(no_id),
732735
rabbit_amqqueue:with_or_die(
733736
QName,
@@ -1275,14 +1278,14 @@ init_test_queue(QName) ->
12751278
Res.
12761279

12771280
restart_test_queue(Qi, QName) ->
1278-
_ = rabbit_queue_index:terminate([], Qi),
1279-
ok = rabbit_variable_queue:stop(),
1280-
{ok, _} = rabbit_variable_queue:start([QName]),
1281+
_ = rabbit_queue_index:terminate(?VHOST, [], Qi),
1282+
ok = rabbit_variable_queue:stop(?VHOST),
1283+
{ok, _} = rabbit_variable_queue:start(?VHOST, [QName]),
12811284
init_test_queue(QName).
12821285

12831286
empty_test_queue(QName) ->
1284-
ok = rabbit_variable_queue:stop(),
1285-
{ok, _} = rabbit_variable_queue:start([]),
1287+
ok = rabbit_variable_queue:stop(?VHOST),
1288+
{ok, _} = rabbit_variable_queue:start(?VHOST, []),
12861289
{0, 0, Qi} = init_test_queue(QName),
12871290
_ = rabbit_queue_index:delete_and_terminate(Qi),
12881291
ok.
@@ -1337,7 +1340,7 @@ nop(_) -> ok.
13371340
nop(_, _) -> ok.
13381341

13391342
msg_store_client_init(MsgStore, Ref) ->
1340-
rabbit_msg_store_vhost_sup:client_init(MsgStore, Ref, undefined, undefined, <<"/">>).
1343+
rabbit_vhost_msg_store:client_init(?VHOST, MsgStore, Ref, undefined, undefined).
13411344

13421345
variable_queue_init(Q, Recover) ->
13431346
rabbit_variable_queue:init(

0 commit comments

Comments
 (0)