]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: cosmetic changes to bgp_vpnv4_noretain
authorLouis Scalbert <louis.scalbert@6wind.com>
Tue, 6 Jun 2023 15:00:18 +0000 (17:00 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 16 Jun 2023 12:18:25 +0000 (14:18 +0200)
Cosmetic changes to bgp_vpnv4_noretain to prepare the next commit.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json [deleted file]
tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_all.json [new file with mode: 0644]
tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json [new file with mode: 0644]
tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json [deleted file]
tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py

diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json
deleted file mode 100644 (file)
index 28e153e..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-{
-   "vrfId":0,
-   "vrfName":"default",
-   "routerId":"1.1.1.1",
-   "defaultLocPrf":100,
-   "localAS":65500,
-   "routes":{
-      "routeDistinguishers":{
-         "444:1":{
-            "10.201.0.0/24":[
-               {
-                  "valid":true,
-                  "bestpath":true,
-                  "selectionReason":"First path received",
-                  "pathFrom":"external",
-                  "prefix":"10.201.0.0",
-                  "prefixLen":24,
-                  "network":"10.201.0.0\/24",
-                  "metric":0,
-                  "weight":32768,
-                  "peerId":"(unspec)",
-                  "path":"",
-                  "origin":"incomplete",
-                  "announceNexthopSelf":true,
-                  "nhVrfName":"vrf1",
-                  "nexthops":[
-                     {
-                        "ip":"0.0.0.0",
-                        "hostname":"r1",
-                        "afi":"ipv4",
-                        "used":true
-                     }
-                  ]
-               }
-            ]
-         },
-         "444:2":{
-            "10.200.0.0/24":[
-               {
-                  "valid":true,
-                  "bestpath":true,
-                  "selectionReason":"First path received",
-                  "pathFrom":"internal",
-                  "prefix":"10.200.0.0",
-                  "prefixLen":24,
-                  "network":"10.200.0.0\/24",
-                  "metric":0,
-                  "locPrf":100,
-                  "weight":0,
-                  "peerId":"10.125.0.2",
-                  "path":"",
-                  "origin":"incomplete",
-                  "nexthops":[
-                     {
-                        "ip":"10.125.0.2",
-                        "hostname":"r2",
-                        "afi":"ipv4",
-                        "used":true
-                     }
-                  ]
-               }
-            ]
-         },
-         "444:3":{
-         }
-      }
-   }
-}
diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_all.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_all.json
new file mode 100644 (file)
index 0000000..45f4acc
--- /dev/null
@@ -0,0 +1,93 @@
+{
+   "vrfId":0,
+   "vrfName":"default",
+   "routerId":"1.1.1.1",
+   "defaultLocPrf":100,
+   "localAS":65500,
+   "routes":{
+      "routeDistinguishers":{
+         "444:1":{
+            "10.201.0.0/24":[
+               {
+                  "valid":true,
+                  "bestpath":true,
+                  "selectionReason":"First path received",
+                  "pathFrom":"external",
+                  "prefix":"10.201.0.0",
+                  "prefixLen":24,
+                  "network":"10.201.0.0\/24",
+                  "metric":0,
+                  "weight":32768,
+                  "peerId":"(unspec)",
+                  "path":"",
+                  "origin":"incomplete",
+                  "announceNexthopSelf":true,
+                  "nhVrfName":"vrf1",
+                  "nexthops":[
+                     {
+                        "ip":"0.0.0.0",
+                        "hostname":"r1",
+                        "afi":"ipv4",
+                        "used":true
+                     }
+                  ]
+               }
+            ]
+         },
+         "444:2":{
+            "10.200.0.0/24":[
+               {
+                  "valid":true,
+                  "bestpath":true,
+                  "selectionReason":"First path received",
+                  "pathFrom":"internal",
+                  "prefix":"10.200.0.0",
+                  "prefixLen":24,
+                  "network":"10.200.0.0\/24",
+                  "metric":0,
+                  "locPrf":100,
+                  "weight":0,
+                  "peerId":"10.125.0.2",
+                  "path":"",
+                  "origin":"incomplete",
+                  "nexthops":[
+                     {
+                        "ip":"10.125.0.2",
+                        "hostname":"r2",
+                        "afi":"ipv4",
+                        "used":true
+                     }
+                  ]
+               }
+            ]
+         },
+         "444:3":{
+            "10.210.0.0/24":[
+               {
+                  "valid":true,
+                  "bestpath":true,
+                  "selectionReason":"First path received",
+                  "pathFrom":"internal",
+                  "prefix":"10.210.0.0",
+                  "prefixLen":24,
+                  "network":"10.210.0.0\/24",
+                  "metric":0,
+                  "locPrf":100,
+                  "weight":0,
+                  "peerId":"10.125.0.2",
+                  "path":"",
+                  "origin":"incomplete",
+                  "nexthops":[
+                     {
+                        "ip":"10.125.0.2",
+                        "hostname":"r2",
+                        "afi":"ipv4",
+                        "used":true
+                     }
+                  ]
+               }
+            ]
+         }
+      }
+   }
+}
diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_no_retain_init.json
new file mode 100644 (file)
index 0000000..28e153e
--- /dev/null
@@ -0,0 +1,68 @@
+{
+   "vrfId":0,
+   "vrfName":"default",
+   "routerId":"1.1.1.1",
+   "defaultLocPrf":100,
+   "localAS":65500,
+   "routes":{
+      "routeDistinguishers":{
+         "444:1":{
+            "10.201.0.0/24":[
+               {
+                  "valid":true,
+                  "bestpath":true,
+                  "selectionReason":"First path received",
+                  "pathFrom":"external",
+                  "prefix":"10.201.0.0",
+                  "prefixLen":24,
+                  "network":"10.201.0.0\/24",
+                  "metric":0,
+                  "weight":32768,
+                  "peerId":"(unspec)",
+                  "path":"",
+                  "origin":"incomplete",
+                  "announceNexthopSelf":true,
+                  "nhVrfName":"vrf1",
+                  "nexthops":[
+                     {
+                        "ip":"0.0.0.0",
+                        "hostname":"r1",
+                        "afi":"ipv4",
+                        "used":true
+                     }
+                  ]
+               }
+            ]
+         },
+         "444:2":{
+            "10.200.0.0/24":[
+               {
+                  "valid":true,
+                  "bestpath":true,
+                  "selectionReason":"First path received",
+                  "pathFrom":"internal",
+                  "prefix":"10.200.0.0",
+                  "prefixLen":24,
+                  "network":"10.200.0.0\/24",
+                  "metric":0,
+                  "locPrf":100,
+                  "weight":0,
+                  "peerId":"10.125.0.2",
+                  "path":"",
+                  "origin":"incomplete",
+                  "nexthops":[
+                     {
+                        "ip":"10.125.0.2",
+                        "hostname":"r2",
+                        "afi":"ipv4",
+                        "used":true
+                     }
+                  ]
+               }
+            ]
+         },
+         "444:3":{
+         }
+      }
+   }
+}
diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json
deleted file mode 100644 (file)
index 45f4acc..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-{
-   "vrfId":0,
-   "vrfName":"default",
-   "routerId":"1.1.1.1",
-   "defaultLocPrf":100,
-   "localAS":65500,
-   "routes":{
-      "routeDistinguishers":{
-         "444:1":{
-            "10.201.0.0/24":[
-               {
-                  "valid":true,
-                  "bestpath":true,
-                  "selectionReason":"First path received",
-                  "pathFrom":"external",
-                  "prefix":"10.201.0.0",
-                  "prefixLen":24,
-                  "network":"10.201.0.0\/24",
-                  "metric":0,
-                  "weight":32768,
-                  "peerId":"(unspec)",
-                  "path":"",
-                  "origin":"incomplete",
-                  "announceNexthopSelf":true,
-                  "nhVrfName":"vrf1",
-                  "nexthops":[
-                     {
-                        "ip":"0.0.0.0",
-                        "hostname":"r1",
-                        "afi":"ipv4",
-                        "used":true
-                     }
-                  ]
-               }
-            ]
-         },
-         "444:2":{
-            "10.200.0.0/24":[
-               {
-                  "valid":true,
-                  "bestpath":true,
-                  "selectionReason":"First path received",
-                  "pathFrom":"internal",
-                  "prefix":"10.200.0.0",
-                  "prefixLen":24,
-                  "network":"10.200.0.0\/24",
-                  "metric":0,
-                  "locPrf":100,
-                  "weight":0,
-                  "peerId":"10.125.0.2",
-                  "path":"",
-                  "origin":"incomplete",
-                  "nexthops":[
-                     {
-                        "ip":"10.125.0.2",
-                        "hostname":"r2",
-                        "afi":"ipv4",
-                        "used":true
-                     }
-                  ]
-               }
-            ]
-         },
-         "444:3":{
-            "10.210.0.0/24":[
-               {
-                  "valid":true,
-                  "bestpath":true,
-                  "selectionReason":"First path received",
-                  "pathFrom":"internal",
-                  "prefix":"10.210.0.0",
-                  "prefixLen":24,
-                  "network":"10.210.0.0\/24",
-                  "metric":0,
-                  "locPrf":100,
-                  "weight":0,
-                  "peerId":"10.125.0.2",
-                  "path":"",
-                  "origin":"incomplete",
-                  "nexthops":[
-                     {
-                        "ip":"10.125.0.2",
-                        "hostname":"r2",
-                        "afi":"ipv4",
-                        "used":true
-                     }
-                  ]
-               }
-            ]
-         }
-      }
-   }
-}
index 9b8ae4b7e3303736e46b2d07007156d0f8040407..af6e47ab789cbb2112bd994cdc60280db9fa86f0 100644 (file)
@@ -139,24 +139,15 @@ def router_json_cmp_exact_filter(router, cmd, expected):
     return topotest.json_cmp(json_output, expected, exact=True)
 
 
-def test_bgp_no_retain():
-    """
-    Check bgp no retain route-target all on r1
-    """
-
+def check_show_bgp_ipv4_vpn(rname, json_file):
     tgen = get_topogen()
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
+    router = tgen.gears[rname]
 
-    # Check IPv4 VPN routing tables on r1
-    logger.info("Checking VPNv4 routes for convergence on r1")
-    router = tgen.gears["r1"]
-    json_file = "{}/{}/ipv4_vpn_routes.json".format(CWD, router.name)
-    if not os.path.isfile(json_file):
-        logger.info("skipping file {}".format(json_file))
-        assert 0, "{} file not found".format(json_file)
-        return
+    logger.info("Checking VPNv4 routes for convergence on {}".format(rname))
 
+    json_file = "{}/{}/{}".format(CWD, router.name, json_file)
     expected = json.loads(open(json_file).read())
     test_func = partial(
         router_json_cmp_exact_filter,
@@ -169,37 +160,35 @@ def test_bgp_no_retain():
     assert result is None, assertmsg
 
 
-def test_bgp_retain():
+def test_bgp_no_retain_step1():
+    """
+    Check bgp no retain route-target all on r1
+    """
+
+    rname = "r1"
+    check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_no_retain_init.json")
+
+
+def test_bgp_retain_step2():
     """
     Apply and check bgp retain route-target all on r1
     """
+    rname = "r1"
+    cfg = """
+configure
+router bgp 65500
+ address-family ipv4 vpn
+  bgp retain route-target all
+"""
 
     tgen = get_topogen()
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
-    # Check IPv4 VPN routing tables on r1
-    logger.info("Checking VPNv4 routes on r1 after bgp no retain")
-    router = tgen.gears["r1"]
-    router.vtysh_cmd(
-        "configure\nrouter bgp 65500\naddress-family ipv4 vpn\nbgp retain route-target all\n"
-    )
-    json_file = "{}/{}/ipv4_vpn_routes_unfiltered.json".format(CWD, router.name)
-    if not os.path.isfile(json_file):
-        logger.info("skipping file {}".format(json_file))
-        assert 0, "{} file not found".format(json_file)
-        return
+    router = tgen.gears[rname]
+    router.vtysh_cmd(cfg)
 
-    expected = json.loads(open(json_file).read())
-    test_func = partial(
-        router_json_cmp_exact_filter,
-        router,
-        "show bgp ipv4 vpn json",
-        expected,
-    )
-    _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
-    assertmsg = '"{}" JSON output mismatches'.format(router.name)
-    assert result is None, assertmsg
+    check_show_bgp_ipv4_vpn(rname, "ipv4_vpn_routes_all.json")
 
 
 def test_memory_leak():