Skip to content

Commit 2e77f6f

Browse files
committed
tests: PIM AutoRP candidate RP tests
Signed-off-by: Nathan Bahr <[email protected]>
1 parent 2ae3e98 commit 2e77f6f

File tree

5 files changed

+70
-38
lines changed

5 files changed

+70
-38
lines changed

tests/topotests/lib/pim.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1779,16 +1779,15 @@ def verify_pim_rp_info_is_empty(tgen, dut, af="ipv4"):
17791779
logger.info("[DUT: %s]: Verifying %s rp info", dut, ip_cmd)
17801780
cmd = "show {} pim rp-info json".format(ip_cmd)
17811781
show_ip_rp_info_json = run_frr_cmd(rnode, cmd, isjson=True)
1782-
1782+
17831783
if show_ip_rp_info_json:
1784-
errormsg = (
1785-
"[DUT %s]: Verifying empty rp-info [FAILED]!!" % (dut)
1786-
)
1784+
errormsg = "[DUT %s]: Verifying empty rp-info [FAILED]!!" % (dut)
17871785
return errormsg
17881786

17891787
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
17901788
return True
17911789

1790+
17921791
@retry(retry_timeout=60, diag_pct=0)
17931792
def verify_pim_state(
17941793
tgen,
@@ -2794,6 +2793,7 @@ def scapy_send_bsr_raw_packet(tgen, topo, senderRouter, receiverRouter, packet=N
27942793
logger.debug("Exiting lib API: scapy_send_bsr_raw_packet")
27952794
return True
27962795

2796+
27972797
def scapy_send_autorp_raw_packet(tgen, senderRouter, senderInterface, packet=None):
27982798
"""
27992799
Using scapy Raw() method to send AutoRP raw packet from one FRR
@@ -2835,6 +2835,7 @@ def scapy_send_autorp_raw_packet(tgen, senderRouter, senderInterface, packet=Non
28352835
logger.debug("Exiting lib API: scapy_send_autorp_raw_packet")
28362836
return True
28372837

2838+
28382839
def find_rp_from_bsrp_info(tgen, dut, bsr, grp=None):
28392840
"""
28402841
Find which RP is having lowest prioriy and returns rp IP
@@ -4344,6 +4345,7 @@ def verify_local_igmp_groups(tgen, dut, interface, group_addresses):
43444345
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
43454346
return True
43464347

4348+
43474349
@retry(retry_timeout=62)
43484350
def verify_static_groups(tgen, dut, interface, group_addresses):
43494351
"""
@@ -4377,7 +4379,9 @@ def verify_static_groups(tgen, dut, interface, group_addresses):
43774379
rnode = tgen.routers()[dut]
43784380

43794381
logger.info("[DUT: %s]: Verifying static groups received:", dut)
4380-
show_static_group_json = run_frr_cmd(rnode, "show ip igmp static-group json", isjson=True)
4382+
show_static_group_json = run_frr_cmd(
4383+
rnode, "show ip igmp static-group json", isjson=True
4384+
)
43814385

43824386
if type(group_addresses) is not list:
43834387
group_addresses = [group_addresses]
@@ -4414,6 +4418,7 @@ def verify_static_groups(tgen, dut, interface, group_addresses):
44144418
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
44154419
return True
44164420

4421+
44174422
def verify_pim_interface_traffic(tgen, input_dict, return_stats=True, addr_type="ipv4"):
44184423
"""
44194424
Verify ip pim interface traffic by running

tests/topotests/multicast_pim_autorp/r1/frr.conf renamed to tests/topotests/pim_autorp/r1/frr.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ log file /tmp/r1-frr.log
55
debug pim autorp
66
!
77
interface r1-eth0
8-
ip address 10.10.76.2/24
8+
ip address 10.10.76.1/24
99
ip igmp
1010
ip pim
1111
!

tests/topotests/multicast_pim_autorp/r2/frr.conf renamed to tests/topotests/pim_autorp/r2/frr.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ log file /tmp/r2-frr.log
55
debug pim autorp
66
!
77
interface r2-eth0
8-
ip address 10.10.76.1/24
8+
ip address 10.10.76.2/24
99
ip igmp
1010
ip pim
1111
!

tests/topotests/multicast_pim_autorp/test_multicast_pim_autorp.py renamed to tests/topotests/pim_autorp/test_pim_autorp.py

+58-31
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: ISC
33

44
#
5-
# test_multicast_pim_autorp.py
5+
# test_pim_autorp.py
66
#
77
# Copyright (c) 2024 ATCorp
88
# Nathan Bahr
@@ -19,8 +19,10 @@
1919
from lib.pim import scapy_send_autorp_raw_packet, verify_pim_rp_info, verify_pim_rp_info_is_empty
2020
from lib.common_config import step, write_test_header
2121

22+
from time import sleep
23+
2224
"""
23-
test_multicast_pim_autorp.py: Test general PIM AutoRP functionality
25+
test_pim_autorp.py: Test general PIM AutoRP functionality
2426
"""
2527

2628
TOPOLOGY = """
@@ -52,7 +54,7 @@ def build_topo(tgen):
5254
switch = tgen.add_switch("s1-2")
5355
switch.add_link(tgen.gears["r1"])
5456
switch.add_link(tgen.gears["r2"])
55-
57+
5658
def setup_module(mod):
5759
logger.info("PIM AutoRP basic functionality:\n {}".format(TOPOLOGY))
5860

@@ -97,20 +99,20 @@ def test_pim_autorp_discovery_single_rp(request):
9799
step("Start with no RP configuration")
98100
result = verify_pim_rp_info_is_empty(tgen, "r1")
99101
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
100-
101-
step("Send AutoRP packet from r2 to r1")
102+
103+
step("Send AutoRP packet from r1 to r2")
102104
# 1 RP(s), hold time 5 secs, 10.10.76.1, group(s) 224.0.0.0/4
103105
data = "01005e00012800127f55cfb1080045c00030700c000008110abe0a0a4c01e000012801f001f0001c798b12010005000000000a0a4c0103010004e0000000"
104-
scapy_send_autorp_raw_packet(tgen, "r2", "r2-eth0", data)
105-
106+
scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data)
107+
106108
step("Verify rp-info from AutoRP packet")
107-
result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/4", "r1-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
109+
result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
108110
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
109-
111+
110112
step("Verify AutoRP configuration times out")
111-
result = verify_pim_rp_info_is_empty(tgen, "r1")
113+
result = verify_pim_rp_info_is_empty(tgen, "r2")
112114
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
113-
115+
114116
def test_pim_autorp_discovery_multiple_rp(request):
115117
"Test PIM AutoRP Discovery with multiple RP's"
116118
tgen = get_topogen()
@@ -121,20 +123,20 @@ def test_pim_autorp_discovery_multiple_rp(request):
121123
pytest.skip("skipped because of router(s) failure")
122124

123125
step("Start with no RP configuration")
124-
result = verify_pim_rp_info_is_empty(tgen, "r1")
126+
result = verify_pim_rp_info_is_empty(tgen, "r2")
125127
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
126-
127-
step("Send AutoRP packet from r2 to r1")
128+
129+
step("Send AutoRP packet from r1 to r2")
128130
# 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
129131
data = "01005e00012800127f55cfb1080045c0003c700c000008110ab20a0a4c01e000012801f001f000283f5712020005000000000a0a4c0103010008e00000000a0a4c0303010008e1000000"
130-
scapy_send_autorp_raw_packet(tgen, "r2", "r2-eth0", data)
131-
132+
scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data)
133+
132134
step("Verify rp-info from AutoRP packet")
133-
result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/8", "r1-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
135+
result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/8", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
134136
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
135-
result = verify_pim_rp_info(tgen, None, "r1", "225.0.0.0/8", "r1-eth0", "10.10.76.3", "AutoRP", False, "ipv4", True)
137+
result = verify_pim_rp_info(tgen, None, "r2", "225.0.0.0/8", "r2-eth0", "10.10.76.3", "AutoRP", False, "ipv4", True)
136138
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
137-
139+
138140

139141
def test_pim_autorp_discovery_static(request):
140142
"Test PIM AutoRP Discovery with Static RP"
@@ -146,26 +148,51 @@ def test_pim_autorp_discovery_static(request):
146148
pytest.skip("skipped because of router(s) failure")
147149

148150
step("Start with no RP configuration")
149-
result = verify_pim_rp_info_is_empty(tgen, "r1")
151+
result = verify_pim_rp_info_is_empty(tgen, "r2")
150152
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
151-
152-
step("Add static RP configuration to r1")
153-
rnode = tgen.routers()["r1"]
153+
154+
step("Add static RP configuration to r2")
155+
rnode = tgen.routers()["r2"]
154156
rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'rp 10.10.76.3 224.0.0.0/4'")
155-
156-
step("Verify static rp-info from r1")
157-
result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/4", "r1-eth0", "10.10.76.3", "Static", False, "ipv4", True)
157+
158+
step("Verify static rp-info from r2")
159+
result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.3", "Static", False, "ipv4", True)
158160
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
159-
160-
step("Send AutoRP packet from r2 to r1")
161+
162+
step("Send AutoRP packet from r1 to r2")
161163
# 1 RP(s), hold time 5 secs, 10.10.76.1, group(s) 224.0.0.0/4
162164
data = "01005e00012800127f55cfb1080045c00030700c000008110abe0a0a4c01e000012801f001f0001c798b12010005000000000a0a4c0103010004e0000000"
163-
scapy_send_autorp_raw_packet(tgen, "r2", "r2-eth0", data)
164-
165+
scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data)
166+
165167
step("Verify rp-info from AutoRP packet")
166-
result = verify_pim_rp_info(tgen, None, "r1", "224.0.0.0/4", "r1-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
168+
result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
167169
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
168170

171+
172+
def test_pim_autorp_announce_group(request):
173+
"Test PIM AutoRP Announcement with a single group"
174+
tgen = get_topogen()
175+
tc_name = request.node.name
176+
write_test_header(tc_name)
177+
178+
if tgen.routers_have_failure():
179+
pytest.skip("skipped because of router(s) failure")
180+
181+
step("Add candidate RP configuration to r1")
182+
rnode = tgen.routers()["r1"]
183+
rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce 10.10.76.1 224.0.0.0/4'")
184+
step("Verify Announcement sent data")
185+
# TODO: Verify AutoRP mapping agent receives candidate RP announcement
186+
# Mapping agent is not yet implemented
187+
#sleep(10)
188+
step("Change AutoRP Announcement packet parameters")
189+
rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce scope 8 interval 10 holdtime 60'")
190+
step("Verify Announcement sent data")
191+
# TODO: Verify AutoRP mapping agent receives updated candidate RP announcement
192+
# Mapping agent is not yet implemented
193+
#sleep(10)
194+
195+
169196
def test_memory_leak():
170197
"Run the memory leak test and report results."
171198
tgen = get_topogen()

0 commit comments

Comments
 (0)