Skip to content

Commit bd037a1

Browse files
Verify previous active consumer is waiting
1 parent 034ef2c commit bd037a1

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

deps/rabbit/test/rabbit_fifo_SUITE.erl

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,8 +1728,7 @@ single_active_consumer_priority_test(Config) ->
17281728
%% add a consumer with a higher priority, assert it becomes active
17291729
{CK2, make_checkout(C2, {auto, {simple_prefetch, 1}}, #{priority => 2})},
17301730
?ASSERT(#rabbit_fifo{consumers = #{CK2 := #consumer{status = up}},
1731-
waiting_consumers = [_]}),
1732-
1731+
waiting_consumers = [{CK1, _}]}),
17331732
%% enqueue a message
17341733
{E1Idx , rabbit_fifo:make_enqueue(Pid1, 1, msg1)},
17351734
?ASSERT(#rabbit_fifo{consumers = #{CK2 := #consumer{next_msg_id = 1,
@@ -1751,10 +1750,27 @@ single_active_consumer_priority_test(Config) ->
17511750
when map_size(Ch) == 0)
17521751

17531752
],
1754-
{_S1, _} = run_log(Config, S0, Entries, fun single_active_invariant/1),
1755-
1756-
ok.
1757-
1753+
{#rabbit_fifo{ cfg = #cfg{resource = Resource}}, StateMachineEvents} = run_log(Config, S0, Entries, fun single_active_invariant/1),
1754+
ModCalls = [ S || S = {mod_call, rabbit_quorum_queue, update_consumer_handler, _} <- StateMachineEvents ],
1755+
1756+
%% C1 should be added as single_active
1757+
assert_update_consumer_handler_state_transition(C1, Resource, true, single_active, lists:nth(1, ModCalls)),
1758+
%% C1 should transition to waiting because ...
1759+
assert_update_consumer_handler_state_transition(C1, Resource, false, waiting, lists:nth(2, ModCalls)),
1760+
%% C2 should become single_active
1761+
assert_update_consumer_handler_state_transition(C2, Resource, true, single_active, lists:nth(3, ModCalls)),
1762+
%% C2 should transition as waiting because ...
1763+
assert_update_consumer_handler_state_transition(C2, Resource, false, waiting, lists:nth(4, ModCalls)),
1764+
%% C3 is added as single_active
1765+
assert_update_consumer_handler_state_transition(C3, Resource, true, single_active, lists:nth(5, ModCalls)),
1766+
1767+
ok.
1768+
1769+
assert_update_consumer_handler_state_transition(ConsumerId, Resource, IsActive, UpdatedState, ModCall) ->
1770+
{mod_call,rabbit_quorum_queue,update_consumer_handler,
1771+
[Resource,
1772+
ConsumerId,
1773+
_,_,_,IsActive,UpdatedState,[]]} = ModCall.
17581774

17591775
single_active_consumer_priority_cancel_active_test(Config) ->
17601776
S0 = init(#{name => ?FUNCTION_NAME,

0 commit comments

Comments
 (0)