Skip to content

Commit

Permalink
Add a unit test for rabbit_amqqueue:mark_local_durable_queues_stopped/1
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Mar 14, 2024
1 parent 091d74c commit 0ade88e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions deps/rabbit/test/rabbit_db_queue_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ all_tests() ->
get_durable,
get_many_durable,
update_durable,
mark_local_durable_queues_stopped,
foreach_durable,
internal_delete
].
Expand Down Expand Up @@ -463,6 +464,26 @@ update_durable1(_Config) ->
?assertMatch(my_policy, amqqueue:get_policy(Q0)),
passed.

mark_local_durable_queues_stopped(Config) ->
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
?MODULE, mark_local_durable_queues_stopped1, [Config]).

mark_local_durable_queues_stopped1(_Config) ->
DurableQName = rabbit_misc:r(?VHOST, queue, <<"test-queue1">>),
TransientQName = rabbit_misc:r(?VHOST, queue, <<"test-queue2">>),
DurableQ = new_queue(DurableQName, rabbit_classic_queue),
TransientQ = new_queue(TransientQName, rabbit_classic_queue),
%% Set Q1's pid to a dead process
RecoverableQ = amqqueue:set_pid(DurableQ, spawn(fun() -> ok end)),
?assertEqual(ok, rabbit_db_queue:set(RecoverableQ)),
?assertEqual(ok, rabbit_db_queue:set_dirty(TransientQ)),
?assertEqual(ok, rabbit_amqqueue:mark_local_durable_queues_stopped(?VHOST)),
{ok, StoppedQ} = rabbit_db_queue:get_durable(DurableQName),
?assertEqual(stopped, amqqueue:get_state(StoppedQ)),
{ok, LiveQ} = rabbit_db_queue:get(TransientQName),
?assertEqual(live, amqqueue:get_state(LiveQ)),
passed.

foreach_durable(Config) ->
passed = rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, foreach_durable1, [Config]).

Expand Down

0 comments on commit 0ade88e

Please sign in to comment.