topotests: Add check of imported routes for bgp_evpn_rt5

In bgp_evpn_rt5, check if EVPN routes are correctly imported to VRF.
Note that EVPN and RT extended communities should have been stripped.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
This commit is contained in:
Xiao Liang 2025-04-15 16:34:20 +08:00
parent b336388d4a
commit 9c6e6a35d4
5 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,23 @@
{
"vrfName": "r1-vrf-101",
"routerId": "192.168.102.21",
"localAS": 65000,
"routes": {
"192.168.101.41/32": [
{
"importedFrom": "65000:201",
"vni": "101",
"valid": true,
"extendedCommunity": null,
"nexthops": [
{
"ip": "192.168.100.41",
"hostname": "r2",
"afi": "ipv4",
"used": true
}
]
}
]
}
}

View file

@ -0,0 +1,24 @@
{
"vrfName": "r1-vrf-101",
"routerId": "192.168.102.21",
"localAS": 65000,
"routes": {
"fd00::2/128": [
{
"importedFrom": "65000:201",
"vni": "101",
"valid": true,
"extendedCommunity": null,
"nexthops": [
{
"ip": "::ffff:192.168.100.41",
"hostname": "r2",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
]
}
}

View file

@ -0,0 +1,23 @@
{
"vrfName": "r2-vrf-101",
"routerId": "192.168.101.41",
"localAS": 65000,
"routes": {
"192.168.102.21/32": [
{
"importedFrom": "65000:101",
"vni": "101",
"valid": true,
"extendedCommunity": null,
"nexthops": [
{
"ip": "192.168.100.21",
"hostname": "r1",
"afi": "ipv4",
"used": true
}
]
}
]
}
}

View file

@ -0,0 +1,24 @@
{
"vrfName": "r2-vrf-101",
"routerId": "192.168.101.41",
"localAS": 65000,
"routes": {
"fd00::1/128": [
{
"importedFrom": "65000:101",
"vni": "101",
"valid": true,
"extendedCommunity": null,
"nexthops": [
{
"ip": "::ffff:192.168.100.21",
"hostname": "r1",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
]
}
}

View file

@ -280,6 +280,37 @@ def test_protocols_dump_info():
logger.info(output)
def test_bgp_vrf_routes():
"""
Check routes are correctly imported to VRF
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
for rname in ("r1", "r2"):
router = tgen.gears[rname]
for af in ("ipv4", "ipv6"):
json_file = "{}/{}/bgp_vrf_{}_routes_detail.json".format(
CWD, router.name, af
)
if not os.path.isfile(json_file):
assert 0, "bgp vrf routes file not found"
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp,
router,
"show bgp vrf {}-vrf-101 {} unicast detail json".format(
router.name, af
),
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
def test_router_check_ip():
"""
Check routes are correctly installed