77
88all () ->
99 [
10- all_replica_states_includes_nonvoters ,
10+ all_replica_states_includes_alive_nonvoters ,
1111 filter_nonvoters ,
1212 filter_quorum_critical_accounts_nonvoters ,
1313 ra_machine_conf_delivery_limit
@@ -97,27 +97,29 @@ filter_nonvoters(_Config) ->
9797 [Q4 ] = rabbit_quorum_queue :filter_promotable (Qs , Ss ),
9898 ok .
9999
100- all_replica_states_includes_nonvoters (_Config ) ->
100+ all_replica_states_includes_alive_nonvoters (_Config ) ->
101101 ets :new (ra_state , [named_table , public , {write_concurrency , true }]),
102+ QPids = start_qprocs (_AliveQs = [q1 , q2 , q3 , q4 ]),
102103 ets :insert (ra_state , [
103104 {q1 , leader , voter },
104105 {q2 , follower , voter },
105106 {q3 , follower , promotable },
106107 {q4 , init , unknown },
107- % % pre ra-2.7.0
108- {q5 , leader },
109- {q6 , follower }
108+ % % queues in ra_state but not alive
109+ {q5 , leader , voter },
110+ {q6 , follower , noproc }
110111 ]),
111112 {_ , #{
112113 q1 := leader ,
113114 q2 := follower ,
114115 q3 := promotable ,
115- q4 := init ,
116- q5 : = leader ,
117- q6 : = follower
118- }} = rabbit_quorum_queue : all_replica_states ( ),
116+ q4 := init
117+ } = ReplicaStates } = rabbit_quorum_queue : all_replica_states () ,
118+ ? assertNot ( maps : is_key ( q5 , ReplicaStates )),
119+ ? assertNot ( maps : is_key ( q6 , ReplicaStates ) ),
119120
120121 true = ets :delete (ra_state ),
122+ _ = stop_qprocs (QPids ),
121123 ok .
122124
123125make_ra_machine_conf (Q0 , Arg , Pol , OpPol ) ->
@@ -128,3 +130,13 @@ make_ra_machine_conf(Q0, Arg, Pol, OpPol) ->
128130 {definition , [{<<" delivery-limit" >>,OpPol }]}]),
129131 rabbit_quorum_queue :ra_machine_config (Q ).
130132
133+ start_qprocs (Qs ) ->
134+ [begin
135+ QPid = spawn (fun () -> receive done -> ok end end ),
136+ erlang :register (Q , QPid ),
137+ QPid
138+ end || Q <- Qs ].
139+
140+ stop_qprocs (Pids ) ->
141+ [erlang :send (P , done )|| P <- Pids ].
142+
0 commit comments