@@ -303,6 +303,50 @@ def test_pim_bsr_rp_info(request):
303303 assert result is True , "Testcase {} :Failed \n Error: {}" .format (tc_name , result )
304304
305305
306+ def test_pim_bsr_priority_modify (request ):
307+ "Test PIM BSR candidate-BSR priority-only change"
308+ tgen = get_topogen ()
309+ tc_name = request .node .name
310+ write_test_header (tc_name )
311+
312+ if tgen .routers_have_failure ():
313+ pytest .skip ("skipped because of router(s) failure" )
314+
315+ r2 = tgen .gears ["r2" ]
316+
317+ step ("Raise r2 candidate-BSR priority above r1" )
318+ r2 .vtysh_cmd (
319+ """
320+ configure
321+ router pim
322+ bsr candidate-bsr priority 250
323+ """
324+ )
325+
326+ step ("Verify r2 reports the updated candidate-BSR state" )
327+ expected = {"address" : "10.0.0.2" , "priority" : 250 , "elected" : True }
328+ test_func = partial (
329+ topotest .router_json_cmp , r2 , "show ip pim bsr candidate-bsr json" , expected
330+ )
331+ _ , result = topotest .run_and_expect (test_func , None , count = 60 , wait = 1 )
332+
333+ assertmsg = "r2: candidate bsr priority modify mismatch"
334+ assert result is None , assertmsg
335+
336+ step ("Verify r2 is elected as the new BSR" )
337+ expected = {
338+ "bsr" : "10.0.0.2" ,
339+ "priority" : 250 ,
340+ "state" : "BSR_ELECTED" ,
341+ }
342+
343+ test_func = partial (topotest .router_json_cmp , r2 , "show ip pim bsr json" , expected )
344+ _ , result = topotest .run_and_expect (test_func , None , count = 180 , wait = 1 )
345+
346+ assertmsg = "r2: failed to become BSR after priority increase"
347+ assert result is None , assertmsg
348+
349+
306350def test_pim_bsr_election_fallback_r2 (request ):
307351 "Test PIM BSR Election Backup"
308352 tgen = get_topogen ()
@@ -328,16 +372,16 @@ def test_pim_bsr_election_fallback_r2(request):
328372 test_func = partial (
329373 topotest .router_json_cmp , r1 , "show ip pim bsr candidate-bsr json" , expected
330374 )
331- _ , result = topotest .run_and_expect (test_func , None , count = 10 , wait = 1 )
375+ _ , result = topotest .run_and_expect (test_func , None , count = 20 , wait = 3 )
332376
333377 assertmsg = "r1: failed to remove bsr candidate configuration"
334378 assert result is None , assertmsg
335379
336380 r2 = tgen .gears ["r2" ]
337- # We should fall back to r2 as the BSR
381+ # r2 became BSR earlier after its priority was raised to 250
338382 expected = {
339383 "bsr" : "10.0.0.2" ,
340- "priority" : 100 ,
384+ "priority" : 250 ,
341385 "state" : "BSR_ELECTED" ,
342386 }
343387
@@ -429,6 +473,28 @@ def test_pimv6_bsr_election_r1(request):
429473 assert result is None , assertmsg
430474
431475
476+ def test_pimv6_bsr_cand_bsr_r2 (request ):
477+ "Test PIMv6 BSR candidate BSR JSON output"
478+ tgen = get_topogen ()
479+ tc_name = request .node .name
480+ write_test_header (tc_name )
481+
482+ if tgen .routers_have_failure ():
483+ pytest .skip ("skipped because of router(s) failure" )
484+
485+ r2 = tgen .gears ["r2" ]
486+
487+ # r2 is a candidate bsr with low priority: elected = False
488+ expected = {"address" : "fd00::2" , "priority" : 100 , "elected" : False }
489+ test_func = partial (
490+ topotest .router_json_cmp , r2 , "show ipv6 pim bsr candidate-bsr json" , expected
491+ )
492+ _ , result = topotest .run_and_expect (test_func , None , count = 60 , wait = 1 )
493+
494+ assertmsg = "r2: IPv6 candidate bsr mismatch"
495+ assert result is None , assertmsg
496+
497+
432498def test_pimv6_bsr_cand_rp (request ):
433499 "Test PIMv6 BSR candidate RP"
434500 tgen = get_topogen ()
0 commit comments