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>
--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "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
+ }
+ ]
+ }
+ ]
+ }
+}
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