Skip to content

Commit

Permalink
tests: add topotest for igmp proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Barry A. Trent <[email protected]>
  • Loading branch information
Barry A. Trent committed Sep 19, 2024
1 parent 825672d commit fe1768e
Show file tree
Hide file tree
Showing 6 changed files with 460 additions and 1 deletion.
70 changes: 69 additions & 1 deletion tests/topotests/lib/pim.py
Original file line number Diff line number Diff line change
Expand Up @@ -4260,6 +4260,7 @@ def verify_local_igmp_groups(tgen, dut, interface, group_addresses):
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
return True


@retry(retry_timeout=62)
def verify_static_groups(tgen, dut, interface, group_addresses):
"""
Expand Down Expand Up @@ -4293,7 +4294,9 @@ def verify_static_groups(tgen, dut, interface, group_addresses):
rnode = tgen.routers()[dut]

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

if type(group_addresses) is not list:
group_addresses = [group_addresses]
Expand Down Expand Up @@ -4330,6 +4333,71 @@ def verify_static_groups(tgen, dut, interface, group_addresses):
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
return True


@retry(retry_timeout=62)
def verify_local_igmp_proxy_groups(
tgen, dut, group_addresses_present, group_addresses_not_present
):
"""
Verify igmp proxy groups are as expected by running
"show ip igmp static-group json" command
Parameters
----------
* `tgen`: topogen object
* `dut`: device under test
* `group_addresses_present`: IGMP group addresses which should
currently be proxied
* `group_addresses_not_present`: IGMP group addresses which should
not currently be proxied
Usage
-----
dut = "r1"
group_addresses_present = "225.1.1.1"
group_addresses_not_present = "225.2.2.2"
result = verify_igmp_proxy_groups(tgen, dut, group_p, group_np)
Returns
-------
errormsg(str) or True
"""

if dut not in tgen.routers():
errormsg = "[DUT %s]: Device not found!"
return errormsg

rnode = tgen.routers()[dut]

logger.info("[DUT: %s]: Verifying local IGMP proxy groups:", dut)

out = rnode.vtysh_cmd("show ip igmp proxy json", isjson=True)
groups = [g["group"] if "group" in g else None for g in out["r1-eth1"]["groups"]]

if type(group_addresses_present) is not list:
group_addresses_present = [group_addresses_present]
if type(group_addresses_not_present) is not list:
group_addresses_not_present = [group_addresses_not_present]

for test_addr in group_addresses_present:
if not test_addr in groups:
errormsg = (
"[DUT %s]: Verifying local IGMP proxy joins FAILED!! "
" Expected but not found: %s " % (dut, test_addr)
)
return errormsg

for test_addr in group_addresses_not_present:
if test_addr in groups:
errormsg = (
"[DUT %s]: Verifying local IGMP proxy join removed FAILED!! "
" Unexpected but found: %s " % (dut, test_addr)
)
return errormsg

return True


def verify_pim_interface_traffic(tgen, input_dict, return_stats=True, addr_type="ipv4"):
"""
Verify ip pim interface traffic by running
Expand Down
29 changes: 29 additions & 0 deletions tests/topotests/pim_basic_igmp_proxy/r1/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
hostname r1
!
interface r1-eth0
ip address 10.0.20.1/24
ip igmp
ip pim
ip igmp join 225.1.1.1
ip igmp join 225.2.2.2
!
interface r1-eth1
ip address 10.0.30.1/24
ip pim
ip igmp
ip igmp proxy
!
interface r1-eth2
ip address 10.0.40.1/24
ip igmp
ip pim
ip igmp join 225.3.3.3
ip igmp join 225.4.4.4
!
interface lo
ip address 10.254.0.1/32
ip pim
!
router pim
rp 10.254.0.3
join-prune-interval 5
19 changes: 19 additions & 0 deletions tests/topotests/pim_basic_igmp_proxy/r2/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
hostname r2
!
interface r2-eth0
ip address 10.0.20.2/24
ip igmp
ip pim
ip igmp proxy
!
interface r2-eth1
ip address 10.0.80.1/24
ip igmp
ip pim passive
!
interface lo
ip address 10.254.0.2/32
!
router pim
rp 10.254.0.3
join-prune-interval 5
8 changes: 8 additions & 0 deletions tests/topotests/pim_basic_igmp_proxy/r3/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hostname r3
!
interface r3-eth0
ip address 10.0.40.4/24
!
interface lo
ip address 10.254.0.4/32
!
16 changes: 16 additions & 0 deletions tests/topotests/pim_basic_igmp_proxy/rp/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
hostname rp
!
interface rp-eth0
ip address 10.0.30.3/24
ip pim
!
interface lo
ip address 10.254.0.3/32
ip pim
!
router pim
join-prune-interval 5
rp 10.254.0.3
register-accept-list ACCEPT

ip prefix-list ACCEPT seq 5 permit 10.0.20.0/24 le 32
Loading

0 comments on commit fe1768e

Please sign in to comment.