Skip to content

Commit 36b5734

Browse files
mrin-gMark Stapp
authored andcommitted
test: Topotest to validate PMSI V4 and V6 tunnel Id
Test 'test_imet' added for V4 and V4 to validate Tunnel ID PMSI Signed-off-by: Mrinmoy Ghosh <[email protected]>
1 parent da29372 commit 36b5734

File tree

3 files changed

+95
-2
lines changed

3 files changed

+95
-2
lines changed

tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
evpn_mac_learn_test,
3131
evpn_mac_test_local_remote,
3232
evpn_show_vni_json_elide_ifindex,
33+
evpn_check_bgp_imet,
3334
)
3435
from lib.topogen import Topogen, TopoRouter, get_topogen
3536
from lib.topolog import logger
@@ -632,6 +633,39 @@ def test_evpn_l3vni_vlan_bridge():
632633
assert "Type: L3" in output, assertmsg
633634

634635

636+
def test_imet():
637+
"""
638+
Verify PMSI tunnel attribute info
639+
"""
640+
tgen = get_topogen()
641+
if tgen.routers_have_failure():
642+
pytest.skip(tgen.errors)
643+
644+
dut_name = "PE1"
645+
dut = tgen.gears[dut_name]
646+
rd = "10.30.30.30:2"
647+
prefix = "[3]:[0]:[32]:[10.30.30.30]"
648+
pmsi_label = 101
649+
pmsi_id = "10.30.30.30"
650+
# Check Imet from PE2 to PE1
651+
test_fn = partial(evpn_check_bgp_imet, dut, rd, prefix, pmsi_label, pmsi_id)
652+
_, result = topotest.run_and_expect(test_fn, None, count=10, wait=3)
653+
assertmsg = f"{dut_name} IMET not present/incorrect, result:{result}"
654+
assert result is None, assertmsg
655+
656+
# Check Imet from PE1 to PE2
657+
dut_name = "PE2"
658+
dut = tgen.gears[dut_name]
659+
rd = "10.10.10.10:2"
660+
prefix = "[3]:[0]:[32]:[10.10.10.10]"
661+
pmsi_label = 101
662+
pmsi_id = "10.10.10.10"
663+
test_fn = partial(evpn_check_bgp_imet, dut, rd, prefix, pmsi_label, pmsi_id)
664+
_, result = topotest.run_and_expect(test_fn, None, count=10, wait=3)
665+
assertmsg = f"{dut_name} IMET not present/incorrect, result:{result}"
666+
assert result is None, assertmsg
667+
668+
635669
def test_remote_neigh_uninstall_on_vxlan_down():
636670
"Ensure remote neighs are removed when VxLAN if is down"
637671
tgen = get_topogen()

tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan_v6_vtep.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
evpn_mac_learn_test,
3535
evpn_mac_test_local_remote,
3636
evpn_show_vni_json_elide_ifindex,
37+
evpn_check_bgp_imet,
3738
)
3839
from lib.topogen import Topogen, TopoRouter, get_topogen
3940
from lib.topolog import logger
@@ -117,10 +118,12 @@ def setup_module(mod):
117118
# For all registered routers, load the zebra configuration file
118119
for rname, router in router_list.items():
119120
router.load_config(
120-
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra_v6_vtep.conf".format(rname))
121+
TopoRouter.RD_ZEBRA,
122+
os.path.join(CWD, "{}/zebra_v6_vtep.conf".format(rname)),
121123
)
122124
router.load_config(
123-
TopoRouter.RD_OSPF6, os.path.join(CWD, "{}/ospfd_v6_vtep.conf".format(rname))
125+
TopoRouter.RD_OSPF6,
126+
os.path.join(CWD, "{}/ospfd_v6_vtep.conf".format(rname)),
124127
)
125128
router.load_config(
126129
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd_v6_vtep.conf".format(rname))
@@ -299,6 +302,34 @@ def test_ip_pe2_learn():
299302
# tgen.mininet_cli()
300303

301304

305+
def test_imet():
306+
tgen = get_topogen()
307+
308+
dut_name = "PE1"
309+
dut = tgen.gears[dut_name]
310+
rd = "10.30.30.30:2"
311+
prefix = "[3]:[0]:[128]:[10:30:30::30]"
312+
pmsi_label = 101
313+
pmsi_id = "10:30:30::30"
314+
# Check Imet from PE2 to PE1
315+
test_fn = partial(evpn_check_bgp_imet, dut, rd, prefix, pmsi_label, pmsi_id)
316+
_, result = topotest.run_and_expect(test_fn, None, count=10, wait=3)
317+
assertmsg = f"{dut_name} IMET not present/incorrect, result:{result}"
318+
assert result is None, assertmsg
319+
320+
# Check Imet from PE1 to PE2
321+
dut_name = "PE2"
322+
dut = tgen.gears[dut_name]
323+
rd = "10.10.10.10:2"
324+
prefix = "[3]:[0]:[128]:[10:10:10::10]"
325+
pmsi_label = 101
326+
pmsi_id = "10:10:10::10"
327+
test_fn = partial(evpn_check_bgp_imet, dut, rd, prefix, pmsi_label, pmsi_id)
328+
_, result = topotest.run_and_expect(test_fn, None, count=10, wait=3)
329+
assertmsg = f"{dut_name} IMET not present/incorrect, result:{result}"
330+
assert result is None, assertmsg
331+
332+
302333
def test_memory_leak():
303334
"Run the memory leak test and report results."
304335
tgen = get_topogen()

tests/topotests/lib/evpn.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,34 @@ def evpn_trigger_host_arp(tgen, host_gateways, interface="swp1", count=3, interv
15581558
sleep(interval)
15591559

15601560

1561+
#
1562+
#
1563+
#
1564+
def evpn_check_bgp_imet(dut, rd, prefix, pmsi_label, pmsi_id):
1565+
"""
1566+
Return error if the type-3 PMSI attr label or ID don't match the inputs
1567+
"""
1568+
rd_routes_json = dut.vtysh_cmd(f"show bgp l2vpn evpn route rd {rd} type 3 json")
1569+
rd_routes = json.loads(rd_routes_json)
1570+
1571+
if not rd_routes:
1572+
return "Imet routes not found"
1573+
1574+
if rd not in rd_routes or prefix not in rd_routes[rd]:
1575+
return f"Imet routes not found for rd {rd} and {prefix}"
1576+
paths = rd_routes[rd][prefix]["paths"]
1577+
if not len(paths):
1578+
return f"Imet route paths routes not found for rd {rd} and {prefix}"
1579+
out_label = paths[0][0]["pmsi"].get("label", 0)
1580+
if out_label != pmsi_label:
1581+
return f"Imet PMSI Label mismatch Expected {pmsi_label} Got {out_label}"
1582+
1583+
out_id = paths[0][0]["pmsi"].get("id", "")
1584+
if out_id != pmsi_id:
1585+
return f"Imet PMSI Id mismatch Expected {pmsi_id} Got {out_id}"
1586+
return None
1587+
1588+
15611589
def evpn_trigger_arp_scapy(tgen, host_gateways, interface="swp1"):
15621590
"""
15631591
Trigger ARP using Scapy to populate MAC address tables in the EVPN fabric.

0 commit comments

Comments
 (0)