Skip to content

Commit

Permalink
Update unit_quorum_queue_SUITE to use temporary alive & registered
Browse files Browse the repository at this point in the history
test queue processes (since we now check/return only alive members
when fetching replica states)
  • Loading branch information
Ayanda-D committed Nov 15, 2024
1 parent 19cc2d0 commit ebc0387
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions deps/rabbit/test/unit_quorum_queue_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

all() ->
[
all_replica_states_includes_nonvoters,
all_replica_states_includes_alive_nonvoters,
filter_nonvoters,
filter_quorum_critical_accounts_nonvoters,
ra_machine_conf_delivery_limit
Expand Down Expand Up @@ -97,27 +97,29 @@ filter_nonvoters(_Config) ->
[Q4] = rabbit_quorum_queue:filter_promotable(Qs, Ss),
ok.

all_replica_states_includes_nonvoters(_Config) ->
all_replica_states_includes_alive_nonvoters(_Config) ->
ets:new(ra_state, [named_table, public, {write_concurrency, true}]),
QPids = start_qprocs(_AliveQs = [q1, q2, q3, q4]),
ets:insert(ra_state, [
{q1, leader, voter},
{q2, follower, voter},
{q3, follower, promotable},
{q4, init, unknown},
%% pre ra-2.7.0
{q5, leader},
{q6, follower}
%% queues in ra_state but not alive
{q5, leader, voter},
{q6, follower, noproc}
]),
{_, #{
q1 := leader,
q2 := follower,
q3 := promotable,
q4 := init,
q5 := leader,
q6 := follower
}} = rabbit_quorum_queue:all_replica_states(),
q4 := init
} = ReplicaStates} = rabbit_quorum_queue:all_replica_states(),
?assertNot(maps:is_key(q5, ReplicaStates)),
?assertNot(maps:is_key(q6, ReplicaStates)),

true = ets:delete(ra_state),
_ = stop_qprocs(QPids),
ok.

make_ra_machine_conf(Q0, Arg, Pol, OpPol) ->
Expand All @@ -128,3 +130,13 @@ make_ra_machine_conf(Q0, Arg, Pol, OpPol) ->
{definition, [{<<"delivery-limit">>,OpPol}]}]),
rabbit_quorum_queue:ra_machine_config(Q).

start_qprocs(Qs) ->
[begin
QPid = spawn(fun() -> receive done -> ok end end),
erlang:register(Q, QPid),
QPid
end || Q <- Qs].

stop_qprocs(Pids) ->
[erlang:send(P, done)|| P <- Pids].

0 comments on commit ebc0387

Please sign in to comment.