From a7e7cc301d4784c738ef40e0a2231e3078419aae Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Wed, 23 Oct 2024 00:09:06 -0500 Subject: [PATCH] tests: expand bsr topotest to cover ipv6 Signed-off-by: Jafar Al-Gharaibeh --- tests/topotests/pim_cand_rp_bsr/r1/frr.conf | 26 +- tests/topotests/pim_cand_rp_bsr/r2/frr.conf | 30 +- tests/topotests/pim_cand_rp_bsr/r3/frr.conf | 24 +- tests/topotests/pim_cand_rp_bsr/r4/frr.conf | 37 ++- tests/topotests/pim_cand_rp_bsr/r5/frr.conf | 19 +- tests/topotests/pim_cand_rp_bsr/r6/frr.conf | 22 +- .../pim_cand_rp_bsr/test_pim_cand_rp_bsr.py | 258 +++++++++++++++--- 7 files changed, 367 insertions(+), 49 deletions(-) diff --git a/tests/topotests/pim_cand_rp_bsr/r1/frr.conf b/tests/topotests/pim_cand_rp_bsr/r1/frr.conf index d0aa3d529f..899e9c0684 100644 --- a/tests/topotests/pim_cand_rp_bsr/r1/frr.conf +++ b/tests/topotests/pim_cand_rp_bsr/r1/frr.conf @@ -5,21 +5,45 @@ log file /tmp/r1-frr.log ! !debug pim packet !debug pim bsm +!debug pimv6 bsm ! -ip route 0.0.0.0/0 10.0.0.4 +! +interface lo + ip address 10.0.0.1/32 + ipv6 address fd00:0:0:0::1/128 + ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r1-eth0 ip address 10.0.0.1/24 + ipv6 address fd00:0:0:0::1/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r1-eth1 ip address 10.0.1.1/24 + ipv6 address fd00:0:0:1::1/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! router pim bsr candidate-bsr priority 200 source address 10.0.0.1 ! +router pim6 + bsr candidate-bsr priority 200 source address fd00:0:0:0::1 +! +router ospf + ospf router-id 10.0.0.1 + network 10.0.0.0/16 area 0 +! +router ospf6 + ospf6 router-id 10.0.0.1 +! ip forwarding +ipv6 forwarding ! diff --git a/tests/topotests/pim_cand_rp_bsr/r2/frr.conf b/tests/topotests/pim_cand_rp_bsr/r2/frr.conf index 741c839f19..85af461d5e 100644 --- a/tests/topotests/pim_cand_rp_bsr/r2/frr.conf +++ b/tests/topotests/pim_cand_rp_bsr/r2/frr.conf @@ -3,20 +3,46 @@ hostname r2 password zebra log file /tmp/r2-frr.log ! -ip route 0.0.0.0/0 10.0.0.4 +!debug pim packet +!debug pim bsm +!debug pimv6 bsm +! +interface lo + ip address 10.0.0.2/32 + ipv6 address fd00:0:0:0::2/128 + ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r2-eth0 ip address 10.0.0.2/24 + ipv6 address fd00:0:0:0::2/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r2-eth1 ip address 10.0.2.2/24 + ipv6 address fd00:0:0:2::2/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! router pim - bsr candidate-bsr priority 100 source address 10.0.0.2 + bsr candidate-bsr priority 100 +! +router pim6 + bsr candidate-bsr priority 100 +! +router ospf + ospf router-id 10.0.0.2 + network 10.0.0.0/16 area 0 +! +router ospf6 + ospf6 router-id 10.0.0.2 ! ip forwarding +ipv6 forwarding ! diff --git a/tests/topotests/pim_cand_rp_bsr/r3/frr.conf b/tests/topotests/pim_cand_rp_bsr/r3/frr.conf index bd5c8ce93f..022c44ea58 100644 --- a/tests/topotests/pim_cand_rp_bsr/r3/frr.conf +++ b/tests/topotests/pim_cand_rp_bsr/r3/frr.conf @@ -5,28 +5,48 @@ log file /tmp/r3-frr.log ! !debug pim packet !debug pim bsm +!debug pimv6 bsm ! -ip route 0.0.0.0/0 10.0.3.4 -ip route 10.0.6.0/24 10.0.3.6 ! interface r3-eth0 ip address 10.0.1.3/24 + ipv6 address fd00:0:0:1::3/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r3-eth1 ip address 10.0.3.3/24 + ipv6 address fd00:0:0:3::3/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r3-eth2 ip address 10.0.4.3/24 + ipv6 address fd00:0:0:4::3/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! router pim bsr candidate-rp group 239.0.0.0/16 bsr candidate-rp priority 10 source address 10.0.3.3 ! +router pim6 + bsr candidate-rp group ffbb::/64 + bsr candidate-rp priority 10 source address fd00:0:0:3::3 +! +router ospf + ospf router-id 10.0.1.3 + network 10.0.0.0/16 area 0 +! +router ospf6 + ospf6 router-id 10.0.1.3 +! ip forwarding +ipv6 forwarding ! diff --git a/tests/topotests/pim_cand_rp_bsr/r4/frr.conf b/tests/topotests/pim_cand_rp_bsr/r4/frr.conf index 825b227728..2d0a035f9a 100644 --- a/tests/topotests/pim_cand_rp_bsr/r4/frr.conf +++ b/tests/topotests/pim_cand_rp_bsr/r4/frr.conf @@ -3,35 +3,64 @@ hostname r4 password zebra log file /tmp/r4-frr.log ! -ip route 10.0.1.0/24 10.0.0.1 -ip route 10.0.4.0/24 10.0.3.3 -ip route 10.0.6.0/24 10.0.3.6 +! +interface lo + ip address 10.0.3.4/32 + ipv6 address fd00:0:0:3::4/64 + ip pim + ipv6 pim ! interface r4-eth0 ip address 10.0.2.4/24 + ipv6 address fd00:0:0:2::4/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r4-eth1 ip address 10.0.3.4/24 + ipv6 address fd00:0:0:3::4/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r4-eth2 ip address 10.0.5.4/24 + ipv6 address fd00:0:0:5::4/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r4-eth3 ip address 10.0.0.4/24 + ipv6 address fd00:0:0:0::4/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! router pim bsr candidate-rp group 239.0.0.0/24 bsr candidate-rp group 239.0.0.0/16 bsr candidate-rp group 239.0.0.0/8 - bsr candidate-rp priority 20 source address 10.0.3.4 + bsr candidate-rp priority 20 +! +router pim6 + bsr candidate-rp group ffbb::/124 + bsr candidate-rp group ffbb::/64 + bsr candidate-rp group ffbb::/108 + bsr candidate-rp priority 20 +! +router ospf + ospf router-id 10.0.2.4 + network 10.0.0.0/16 area 0 +! +router ospf6 + ospf6 router-id 10.0.2.4 ! ip forwarding +ipv6 forwarding ! diff --git a/tests/topotests/pim_cand_rp_bsr/r5/frr.conf b/tests/topotests/pim_cand_rp_bsr/r5/frr.conf index c934717d08..552e51f417 100644 --- a/tests/topotests/pim_cand_rp_bsr/r5/frr.conf +++ b/tests/topotests/pim_cand_rp_bsr/r5/frr.conf @@ -3,15 +3,32 @@ hostname r5 password zebra log file /tmp/r5-frr.log ! -ip route 0.0.0.0/0 10.0.4.3 ! interface r5-eth0 ip address 10.0.4.5/24 + ipv6 address fd00:0:0:4::5/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r5-eth1 ip address 10.0.6.5/24 + ipv6 address fd00:0:0:6::5/64 + ip igmp + ip pim + ipv6 pim + ipv6 ospf6 area 0 +! +router pim6 +! +router ospf + ospf router-id 10.0.4.5 + network 10.0.0.0/16 area 0 +! +router ospf6 + ospf6 router-id 10.0.4.5 ! ip forwarding +ipv6 forwarding ! diff --git a/tests/topotests/pim_cand_rp_bsr/r6/frr.conf b/tests/topotests/pim_cand_rp_bsr/r6/frr.conf index fd9d1eb5c4..20955a12c7 100644 --- a/tests/topotests/pim_cand_rp_bsr/r6/frr.conf +++ b/tests/topotests/pim_cand_rp_bsr/r6/frr.conf @@ -3,20 +3,40 @@ hostname r6 password zebra log file /tmp/r6-frr.log ! -ip route 0.0.0.0/0 10.0.6.6 ! interface r6-eth0 ip address 10.0.5.6/24 + ipv6 address fd00:0:0:5::6/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r6-eth1 ip address 10.0.6.6/24 + ipv6 address fd00:0:0:6::6/64 + ip igmp + ip pim + ipv6 pim + ipv6 ospf6 area 0 ! interface r6-eth2 ip address 10.0.3.6/24 + ipv6 address fd00:0:0:3::6/64 ip igmp ip pim + ipv6 pim + ipv6 ospf6 area 0 +! +router pim6 +! +router ospf + ospf router-id 10.0.5.6 + network 10.0.0.0/16 area 0 +! +router ospf6 + ospf6 router-id 10.0.5.6 ! ip forwarding +ipv6 forwarding ! diff --git a/tests/topotests/pim_cand_rp_bsr/test_pim_cand_rp_bsr.py b/tests/topotests/pim_cand_rp_bsr/test_pim_cand_rp_bsr.py index ce7bc9dc56..96a3241a2b 100644 --- a/tests/topotests/pim_cand_rp_bsr/test_pim_cand_rp_bsr.py +++ b/tests/topotests/pim_cand_rp_bsr/test_pim_cand_rp_bsr.py @@ -59,7 +59,12 @@ CWD = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(CWD, "../")) # Required to instantiate the topology builder class. -pytestmark = [pytest.mark.pimd] +pytestmark = [ + pytest.mark.pimd, + pytest.mark.pim6d, + pytest.mark.ospfd, + pytest.mark.ospf6d, +] def build_topo(tgen): @@ -102,6 +107,7 @@ def build_topo(tgen): sw1.add_link(tgen.gears["r4"]) sw3.add_link(tgen.gears["r6"]) + def setup_module(mod): logger.info("PIM Candidate RP/BSR:\n {}".format(TOPOLOGY)) @@ -125,6 +131,7 @@ def teardown_module(mod): tgen = get_topogen() tgen.stop_topology() + def test_pim_bsr_election_r1(request): "Test PIM BSR Election" tgen = get_topogen() @@ -137,19 +144,18 @@ def test_pim_bsr_election_r1(request): r2 = tgen.gears["r2"] # r1 should be the BSR winner because it has higher priority expected = { - "bsr":"10.0.0.1", - "priority":200, - "state":"ACCEPT_PREFERRED", + "bsr": "10.0.0.1", + "priority": 200, + "state": "ACCEPT_PREFERRED", } - test_func = partial( - topotest.router_json_cmp, r2, "show ip pim bsr json", expected - ) + test_func = partial(topotest.router_json_cmp, r2, "show ip pim bsr json", expected) _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r2: r1 was not elected, bsr election mismatch" assert result is None, assertmsg + def test_pim_bsr_cand_bsr_r1(request): "Test PIM BSR candidate BSR" tgen = get_topogen() @@ -162,11 +168,7 @@ def test_pim_bsr_cand_bsr_r1(request): r2 = tgen.gears["r2"] # r2 is a candidate bsr with low priority: elected = False - expected = { - "address": "10.0.0.2", - "priority": 100, - "elected": False - } + expected = {"address": "10.0.0.2", "priority": 100, "elected": False} test_func = partial( topotest.router_json_cmp, r2, "show ip pim bsr candidate-bsr json", expected ) @@ -175,6 +177,7 @@ def test_pim_bsr_cand_bsr_r1(request): assertmsg = "r2: candidate bsr mismatch " assert result is None, assertmsg + def test_pim_bsr_cand_rp(request): "Test PIM BSR candidate RP" tgen = get_topogen() @@ -187,10 +190,7 @@ def test_pim_bsr_cand_rp(request): r3 = tgen.gears["r3"] # r3 is a candidate rp - expected = { - "address":"10.0.3.3", - "priority":10 - } + expected = {"address": "10.0.3.3", "priority": 10} test_func = partial( topotest.router_json_cmp, r3, "show ip pim bsr candidate-rp json", expected ) @@ -211,29 +211,95 @@ def test_pim_bsr_rp_info(request): # At this point, all nodes, including r5 should have synced the RP state step("Verify rp-info on r5 from BSR") - result = verify_pim_rp_info(tgen, None, "r5", "239.0.0.0/16", None, "10.0.3.3", - "BSR", False, "ipv4", True, retry_timeout = 90) + result = verify_pim_rp_info( + tgen, + None, + "r5", + "239.0.0.0/16", + None, + "10.0.3.3", + "BSR", + False, + "ipv4", + True, + retry_timeout=90, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - result = verify_pim_rp_info(tgen, None, "r5", "239.0.0.0/8", None, "10.0.3.4", - "BSR", False, "ipv4", True, retry_timeout = 30) + result = verify_pim_rp_info( + tgen, + None, + "r5", + "239.0.0.0/8", + None, + "10.0.3.4", + "BSR", + False, + "ipv4", + True, + retry_timeout=30, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - result = verify_pim_rp_info(tgen, None, "r5", "239.0.0.0/24", None, "10.0.3.4", - "BSR", False, "ipv4", True, retry_timeout = 30) + result = verify_pim_rp_info( + tgen, + None, + "r5", + "239.0.0.0/24", + None, + "10.0.3.4", + "BSR", + False, + "ipv4", + True, + retry_timeout=30, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("Verify rp-info on the BSR node itself r1") - result = verify_pim_rp_info(tgen, None, "r1", "239.0.0.0/16", None, "10.0.3.3", - "BSR", False, "ipv4", True, retry_timeout = 10) + result = verify_pim_rp_info( + tgen, + None, + "r1", + "239.0.0.0/16", + None, + "10.0.3.3", + "BSR", + False, + "ipv4", + True, + retry_timeout=10, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - result = verify_pim_rp_info(tgen, None, "r1", "239.0.0.0/8", None, "10.0.3.4", - "BSR", False, "ipv4", True, retry_timeout = 10) + result = verify_pim_rp_info( + tgen, + None, + "r1", + "239.0.0.0/8", + None, + "10.0.3.4", + "BSR", + False, + "ipv4", + True, + retry_timeout=10, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - result = verify_pim_rp_info(tgen, None, "r1", "239.0.0.0/24", None, "10.0.3.4", - "BSR", False, "ipv4", True, retry_timeout = 10) + result = verify_pim_rp_info( + tgen, + None, + "r1", + "239.0.0.0/24", + None, + "10.0.3.4", + "BSR", + False, + "ipv4", + True, + retry_timeout=10, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -253,7 +319,8 @@ def test_pim_bsr_election_fallback_r2(request): configure router pim no bsr candidate-bsr priority 200 source address 10.0.0.1 - """) + """ + ) step("Verify r1 is no longer a BSR candidate") expected = {} @@ -269,16 +336,14 @@ def test_pim_bsr_election_fallback_r2(request): r2 = tgen.gears["r2"] # We should fall back to r2 as the BSR expected = { - "bsr":"10.0.0.2", - "priority":100, - "state":"BSR_ELECTED", + "bsr": "10.0.0.2", + "priority": 100, + "state": "BSR_ELECTED", } step("Verify that we fallback to r2 as the new BSR") - test_func = partial( - topotest.router_json_cmp, r2, "show ip pim bsr json", expected - ) + test_func = partial(topotest.router_json_cmp, r2, "show ip pim bsr json", expected) _, result = topotest.run_and_expect(test_func, None, count=180, wait=1) assertmsg = "r2: failed to fallback to r2 as a BSR" @@ -301,12 +366,129 @@ def test_pim_bsr_rp_info_fallback(request): configure router pim no bsr candidate-rp group 239.0.0.0/16 - """) + """ + ) step("Verify falling back to r4 as the new RP for 239.0.0.0/16") - result = verify_pim_rp_info(tgen, None, "r5", "239.0.0.0/16", None, "10.0.3.4", - "BSR", False, "ipv4", True, retry_timeout = 30) + result = verify_pim_rp_info( + tgen, + None, + "r5", + "239.0.0.0/16", + None, + "10.0.3.4", + "BSR", + False, + "ipv4", + True, + retry_timeout=30, + ) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + + +def test_pimv6_bsr_election_r1(request): + "Test PIMv6 BSR Election" + tgen = get_topogen() + tc_name = request.node.name + write_test_header(tc_name) + + if tgen.routers_have_failure(): + pytest.skip("skipped because of router(s) failure") + + r2 = tgen.gears["r2"] + # r1 should be the BSR winner because it has higher priority + expected = { + "bsr": "fd00::1", + "priority": 200, + "state": "ACCEPT_PREFERRED", + } + + test_func = partial( + topotest.router_json_cmp, r2, "show ipv6 pim bsr json", expected + ) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) + + assertmsg = "r2: r1 was not elected, IPv6 bsr election mismatch" + assert result is None, assertmsg + + +def test_pimv6_bsr_cand_rp(request): + "Test PIMv6 BSR candidate RP" + tgen = get_topogen() + tc_name = request.node.name + write_test_header(tc_name) + + if tgen.routers_have_failure(): + pytest.skip("skipped because of router(s) failure") + + r3 = tgen.gears["r3"] + + # r3 is a candidate rp + expected = {"address": "fd00:0:0:3::3", "priority": 10} + test_func = partial( + topotest.router_json_cmp, r3, "show ipv6 pim bsr candidate-rp json", expected + ) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) + + assertmsg = "r3: bsr candidate rp mismatch" + assert result is None, assertmsg + + +def test_pimv6_bsr_rp_info(request): + "Test IPv6 RP info state" + tgen = get_topogen() + tc_name = request.node.name + write_test_header(tc_name) + + if tgen.routers_have_failure(): + pytest.skip("skipped because of router(s) failure") + + # At this point, all nodes, including r5 should have synced the RP state + step("Verify rp-info on r5 from BSR") + result = verify_pim_rp_info( + tgen, + None, + "r5", + "ffbb::0/64", + None, + "fd00:0:0:3::3", + "BSR", + False, + "ipv6", + True, + retry_timeout=90, + ) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + + result = verify_pim_rp_info( + tgen, + None, + "r5", + "ffbb::0/124", + None, + "fd00:0:0:3::4", + "BSR", + False, + "ipv6", + True, + retry_timeout=30, + ) + assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + + result = verify_pim_rp_info( + tgen, + None, + "r5", + "ffbb::0/108", + None, + "fd00:0:0:3::4", + "BSR", + False, + "ipv6", + True, + retry_timeout=30, + ) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) -- 2.39.5