]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: Add check of imported routes for bgp_evpn_rt5 18656/head
authorXiao Liang <shaw.leon@gmail.com>
Tue, 15 Apr 2025 08:34:20 +0000 (16:34 +0800)
committerXiao Liang <shaw.leon@gmail.com>
Fri, 18 Apr 2025 01:51:53 +0000 (09:51 +0800)
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>
tests/topotests/bgp_evpn_rt5/r1/bgp_vrf_ipv4_routes_detail.json [new file with mode: 0644]
tests/topotests/bgp_evpn_rt5/r1/bgp_vrf_ipv6_routes_detail.json [new file with mode: 0644]
tests/topotests/bgp_evpn_rt5/r2/bgp_vrf_ipv4_routes_detail.json [new file with mode: 0644]
tests/topotests/bgp_evpn_rt5/r2/bgp_vrf_ipv6_routes_detail.json [new file with mode: 0644]
tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py

diff --git a/tests/topotests/bgp_evpn_rt5/r1/bgp_vrf_ipv4_routes_detail.json b/tests/topotests/bgp_evpn_rt5/r1/bgp_vrf_ipv4_routes_detail.json
new file mode 100644 (file)
index 0000000..3327bbc
--- /dev/null
@@ -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
+                    }
+                ]
+            }
+        ]
+    }
+}
diff --git a/tests/topotests/bgp_evpn_rt5/r1/bgp_vrf_ipv6_routes_detail.json b/tests/topotests/bgp_evpn_rt5/r1/bgp_vrf_ipv6_routes_detail.json
new file mode 100644 (file)
index 0000000..f89b89f
--- /dev/null
@@ -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
+                    }
+                ]
+            }
+        ]
+    }
+}
diff --git a/tests/topotests/bgp_evpn_rt5/r2/bgp_vrf_ipv4_routes_detail.json b/tests/topotests/bgp_evpn_rt5/r2/bgp_vrf_ipv4_routes_detail.json
new file mode 100644 (file)
index 0000000..c50964f
--- /dev/null
@@ -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
+                    }
+                ]
+            }
+        ]
+    }
+}
diff --git a/tests/topotests/bgp_evpn_rt5/r2/bgp_vrf_ipv6_routes_detail.json b/tests/topotests/bgp_evpn_rt5/r2/bgp_vrf_ipv6_routes_detail.json
new file mode 100644 (file)
index 0000000..17928a9
--- /dev/null
@@ -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
+                    }
+                ]
+            }
+        ]
+    }
+}
index f699bea7c23f2bb57187d4d092a65ff679f867ee..c5f400ce840d7ef598ae834a4e2f17db03ac8a82 100644 (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