From 0f844c0fe3846a7bdf1837743ef400fcda0f3ccd Mon Sep 17 00:00:00 2001 From: Nathan Bahr Date: Mon, 24 Jun 2024 12:07:25 -0500 Subject: [PATCH] tests: PIM AutoRP candidate RP tests Signed-off-by: Nathan Bahr --- .../multicast_pim_autorp/r1/frr.conf | 2 +- .../multicast_pim_autorp/r2/frr.conf | 2 +- .../test_multicast_pim_autorp.py | 58 +++++++++++++------ 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/tests/topotests/multicast_pim_autorp/r1/frr.conf b/tests/topotests/multicast_pim_autorp/r1/frr.conf index 2d930c3da05a..2fddbc3ae29e 100644 --- a/tests/topotests/multicast_pim_autorp/r1/frr.conf +++ b/tests/topotests/multicast_pim_autorp/r1/frr.conf @@ -5,7 +5,7 @@ log file /tmp/r1-frr.log debug pim autorp ! interface r1-eth0 - ip address 10.10.76.2/24 + ip address 10.10.76.1/24 ip igmp ip pim ! diff --git a/tests/topotests/multicast_pim_autorp/r2/frr.conf b/tests/topotests/multicast_pim_autorp/r2/frr.conf index 86a0eab2c09b..fd3c0cad3990 100644 --- a/tests/topotests/multicast_pim_autorp/r2/frr.conf +++ b/tests/topotests/multicast_pim_autorp/r2/frr.conf @@ -5,7 +5,7 @@ log file /tmp/r2-frr.log debug pim autorp ! interface r2-eth0 - ip address 10.10.76.1/24 + ip address 10.10.76.2/24 ip igmp ip pim ! diff --git a/tests/topotests/multicast_pim_autorp/test_multicast_pim_autorp.py b/tests/topotests/multicast_pim_autorp/test_multicast_pim_autorp.py index 637e8bdad5b1..ccfa73e62b6e 100644 --- a/tests/topotests/multicast_pim_autorp/test_multicast_pim_autorp.py +++ b/tests/topotests/multicast_pim_autorp/test_multicast_pim_autorp.py @@ -19,6 +19,8 @@ from lib.pim import scapy_send_autorp_raw_packet, verify_pim_rp_info, verify_pim_rp_info_is_empty from lib.common_config import step, write_test_header +from time import sleep + """ test_multicast_pim_autorp.py: Test general PIM AutoRP functionality """ @@ -98,17 +100,17 @@ def test_pim_autorp_discovery_single_rp(request): result = verify_pim_rp_info_is_empty(tgen, "r1") assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - step("Send AutoRP packet from r2 to r1") + step("Send AutoRP packet from r1 to r2") # 1 RP(s), hold time 5 secs, 10.10.76.1, group(s) 224.0.0.0/4 data = "01005e00012800127f55cfb1080045c00030700c000008110abe0a0a4c01e000012801f001f0001c798b12010005000000000a0a4c0103010004e0000000" - scapy_send_autorp_raw_packet(tgen, "r2", "r2-eth0", data) + scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data) step("Verify rp-info from AutoRP packet") - result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/4", "r1-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True) + result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("Verify AutoRP configuration times out") - result = verify_pim_rp_info_is_empty(tgen, "r1") + result = verify_pim_rp_info_is_empty(tgen, "r2") assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) def test_pim_autorp_discovery_multiple_rp(request): @@ -121,18 +123,18 @@ def test_pim_autorp_discovery_multiple_rp(request): pytest.skip("skipped because of router(s) failure") step("Start with no RP configuration") - result = verify_pim_rp_info_is_empty(tgen, "r1") + result = verify_pim_rp_info_is_empty(tgen, "r2") assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - step("Send AutoRP packet from r2 to r1") + step("Send AutoRP packet from r1 to r2") # 2 RP(s), hold time 5 secs, 10.10.76.1, group(s) 224.0.0.0/8, 10.10.76.3, group(s) 225.0.0.0/8 data = "01005e00012800127f55cfb1080045c0003c700c000008110ab20a0a4c01e000012801f001f000283f5712020005000000000a0a4c0103010008e00000000a0a4c0303010008e1000000" - scapy_send_autorp_raw_packet(tgen, "r2", "r2-eth0", data) + scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data) step("Verify rp-info from AutoRP packet") - result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/8", "r1-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True) + result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/8", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - result = verify_pim_rp_info(tgen, None, "r1", "225.0.0.0/8", "r1-eth0", "10.10.76.3", "AutoRP", False, "ipv4", True) + result = verify_pim_rp_info(tgen, None, "r2", "225.0.0.0/8", "r2-eth0", "10.10.76.3", "AutoRP", False, "ipv4", True) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) @@ -146,26 +148,48 @@ def test_pim_autorp_discovery_static(request): pytest.skip("skipped because of router(s) failure") step("Start with no RP configuration") - result = verify_pim_rp_info_is_empty(tgen, "r1") + result = verify_pim_rp_info_is_empty(tgen, "r2") assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - step("Add static RP configuration to r1") - rnode = tgen.routers()["r1"] + step("Add static RP configuration to r2") + rnode = tgen.routers()["r2"] rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'rp 10.10.76.3 224.0.0.0/4'") - step("Verify static rp-info from r1") - result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/4", "r1-eth0", "10.10.76.3", "Static", False, "ipv4", True) + step("Verify static rp-info from r2") + result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.3", "Static", False, "ipv4", True) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) - step("Send AutoRP packet from r2 to r1") + step("Send AutoRP packet from r1 to r2") # 1 RP(s), hold time 5 secs, 10.10.76.1, group(s) 224.0.0.0/4 data = "01005e00012800127f55cfb1080045c00030700c000008110abe0a0a4c01e000012801f001f0001c798b12010005000000000a0a4c0103010004e0000000" - scapy_send_autorp_raw_packet(tgen, "r2", "r2-eth0", data) + scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data) step("Verify rp-info from AutoRP packet") - result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/4", "r1-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True) + result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + + +def test_pim_autorp_announce_group(request): + "Test PIM AutoRP Announcement with a single group" + 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") + + step("Add candidate RP configuration to r1") + rnode = tgen.routers()["r1"] + rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce 10.10.76.1 224.0.0.0/4'") + step("Verify Announcement sent data") + sleep(10) + step("Change AutoRP Announcement packet parameters") + rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce scope 8 interval 10 holdtime 60'") + step("Verify Announcement sent data") + sleep(10) + # TODO Verify packet format sent by the router, but how?? + + def test_memory_leak(): "Run the memory leak test and report results." tgen = get_topogen()