Skip to content

Commit

Permalink
tests: PIM AutoRP candidate RP tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Bahr <[email protected]>
  • Loading branch information
nabahr committed Aug 22, 2024
1 parent 4eddfde commit 0f844c0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/topotests/multicast_pim_autorp/r1/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
!
Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/multicast_pim_autorp/r2/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
!
Expand Down
58 changes: 41 additions & 17 deletions tests/topotests/multicast_pim_autorp/test_multicast_pim_autorp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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):
Expand All @@ -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)


Expand All @@ -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()
Expand Down

0 comments on commit 0f844c0

Please sign in to comment.