@@ -298,50 +298,76 @@ start_cluster_minority(Config) ->
298298send_local_msg (Config ) ->
299299 PrivDir = ? config (data_dir , Config ),
300300 ClusterName = ? config (cluster_name , Config ),
301- NodeIds = [{ClusterName , start_follower (N , PrivDir )} || N <- [s1 ,s2 ,s3 ]],
301+ [A , B , NonVoter ] = [{ClusterName , start_follower (N , PrivDir )} || N <- [s1 ,s2 ,s3 ]],
302+ NodeIds = [A , B ],
302303 Machine = {module , ? MODULE , #{}},
303304 {ok , Started , []} = ra :start_cluster (? SYS , ClusterName , Machine , NodeIds ),
304305 % assert all were said to be started
305306 [] = Started -- NodeIds ,
306- % % spawn a receiver process on one node
307+ % add permanent non-voter
307308 {ok , _ , Leader } = ra :members (hd (NodeIds )),
309+ {ok , _ , _ } = ra :process_command (Leader , banana ),
310+ New = #{id => NonVoter ,
311+ voter_status => {nonvoter , #{nvid => <<" test" >>, target => 999 }},
312+ non_voter_id => <<" test" >>},
313+ {ok , _ , _ } = ra :add_member (A , New ),
314+ ok = ra :start_server (? SYS , ClusterName , New , Machine , NodeIds ),
308315 % % select a non-leader node to spawn on
309316 [{_ , N } | _ ] = lists :delete (Leader , NodeIds ),
310317 test_local_msg (Leader , N , N , send_local_msg , local ),
311318 test_local_msg (Leader , N , N , send_local_msg , [local , ra_event ]),
312319 test_local_msg (Leader , N , N , send_local_msg , [local , cast ]),
313320 test_local_msg (Leader , N , N , send_local_msg , [local , cast , ra_event ]),
314321 {_ , LeaderNode } = Leader ,
322+ % % test the same but for a local pid (non-member)
315323 test_local_msg (Leader , node (), LeaderNode , send_local_msg , local ),
316324 test_local_msg (Leader , node (), LeaderNode , send_local_msg , [local , ra_event ]),
317325 test_local_msg (Leader , node (), LeaderNode , send_local_msg , [local , cast ]),
318326 test_local_msg (Leader , node (), LeaderNode , send_local_msg , [local , cast , ra_event ]),
319- % % test the same but for a local pid (non-member)
327+ % % same for non-voter
328+ {_ , NonVoterNode } = NonVoter ,
329+ test_local_msg (Leader , NonVoterNode , LeaderNode , send_local_msg , local ),
330+ test_local_msg (Leader , NonVoterNode , LeaderNode , send_local_msg , [local , ra_event ]),
331+ test_local_msg (Leader , NonVoterNode , LeaderNode , send_local_msg , [local , cast ]),
332+ test_local_msg (Leader , NonVoterNode , LeaderNode , send_local_msg , [local , cast , ra_event ]),
320333 [ok = slave :stop (S ) || {_ , S } <- NodeIds ],
321334 ok .
322335
323336local_log_effect (Config ) ->
324337 PrivDir = ? config (data_dir , Config ),
325338 ClusterName = ? config (cluster_name , Config ),
326- NodeIds = [{ClusterName , start_follower (N , PrivDir )} || N <- [s1 ,s2 ,s3 ]],
339+ [A , B , NonVoter ] = [{ClusterName , start_follower (N , PrivDir )} || N <- [s1 ,s2 ,s3 ]],
340+ NodeIds = [A , B ],
327341 Machine = {module , ? MODULE , #{}},
328342 {ok , Started , []} = ra :start_cluster (? SYS , ClusterName , Machine , NodeIds ),
329343 % assert all were said to be started
330344 [] = Started -- NodeIds ,
331- % % spawn a receiver process on one node
345+ % add permanent non-voter
332346 {ok , _ , Leader } = ra :members (hd (NodeIds )),
347+ {ok , _ , _ } = ra :process_command (Leader , banana ),
348+ New = #{id => NonVoter ,
349+ voter_status => {nonvoter , #{nvid => <<" test" >>, target => 999 }},
350+ non_voter_id => <<" test" >>},
351+ {ok , _ , _ } = ra :add_member (A , New ),
352+ ok = ra :start_server (? SYS , ClusterName , New , Machine , NodeIds ),
333353 % % select a non-leader node to spawn on
334354 [{_ , N } | _ ] = lists :delete (Leader , NodeIds ),
335355 test_local_msg (Leader , N , N , do_local_log , local ),
336356 test_local_msg (Leader , N , N , do_local_log , [local , ra_event ]),
337357 test_local_msg (Leader , N , N , do_local_log , [local , cast ]),
338358 test_local_msg (Leader , N , N , do_local_log , [local , cast , ra_event ]),
359+ % % test the same but for a local pid (non-member)
339360 {_ , LeaderNode } = Leader ,
340361 test_local_msg (Leader , node (), LeaderNode , do_local_log , local ),
341362 test_local_msg (Leader , node (), LeaderNode , do_local_log , [local , ra_event ]),
342363 test_local_msg (Leader , node (), LeaderNode , do_local_log , [local , cast ]),
343364 test_local_msg (Leader , node (), LeaderNode , do_local_log , [local , cast , ra_event ]),
344- % % test the same but for a local pid (non-member)
365+ % % same for non-voter
366+ {_ , NonVoterNode } = NonVoter ,
367+ test_local_msg (Leader , NonVoterNode , LeaderNode , do_local_log , local ),
368+ test_local_msg (Leader , NonVoterNode , LeaderNode , do_local_log , [local , ra_event ]),
369+ test_local_msg (Leader , NonVoterNode , LeaderNode , do_local_log , [local , cast ]),
370+ test_local_msg (Leader , NonVoterNode , LeaderNode , do_local_log , [local , cast , ra_event ]),
345371 [ok = slave :stop (S ) || {_ , S } <- NodeIds ],
346372 ok .
347373
@@ -408,7 +434,7 @@ nonvoter_catches_up(Config) ->
408434 || N <- lists :seq (1 , 10000 )],
409435 {ok , _ , _ } = ra :process_command (Leader , banana ),
410436
411- New = #{id => C , init_non_voter => <<" test" >>},
437+ New = #{id => C , non_voter_id => <<" test" >>},
412438 {ok , _ , _ } = ra :add_member (A , New ),
413439 ok = ra :start_server (? SYS , ClusterName , New , Machine , [A , B ]),
414440 NonVoter = {nonvoter , #{nvid => <<" test" >>}},
@@ -444,7 +470,7 @@ nonvoter_catches_up_after_restart(Config) ->
444470 || N <- lists :seq (1 , 10000 )],
445471 {ok , _ , _ } = ra :process_command (Leader , banana ),
446472
447- New = #{id => C , init_non_voter => <<" test" >>},
473+ New = #{id => C , non_voter_id => <<" test" >>},
448474 {ok , _ , _ } = ra :add_member (A , New ),
449475 ok = ra :start_server (? SYS , ClusterName , New , Machine , [A , B ]),
450476 NonVoter = {nonvoter , #{nvid => <<" test" >>}},
@@ -482,7 +508,7 @@ nonvoter_catches_up_after_leader_restart(Config) ->
482508 || N <- lists :seq (1 , 10000 )],
483509 {ok , _ , _ } = ra :process_command (Leader , banana ),
484510
485- New = #{id => C , init_non_voter => <<" test" >>},
511+ New = #{id => C , non_voter_id => <<" test" >>},
486512 {ok , _ , _ } = ra :add_member (A , New ),
487513 ok = ra :start_server (? SYS , ClusterName , New , Machine , [A , B ]),
488514 NonVoter = {nonvoter , #{nvid => <<" test" >>}},
0 commit comments