]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: test nexthop-local unchanged with reflector 17071/head
authorLouis Scalbert <louis.scalbert@6wind.com>
Fri, 11 Oct 2024 11:14:25 +0000 (13:14 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 11 Oct 2024 12:08:12 +0000 (14:08 +0200)
Test nexthop-local unchanged with route-reflector.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/bgp_nexthop_ipv6/r1/show_bgp_ipv6_step1.json
tests/topotests/bgp_nexthop_ipv6/r2/show_bgp_ipv6_step1.json
tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step1.json
tests/topotests/bgp_nexthop_ipv6/r6/show_bgp_ipv6_step1.json
tests/topotests/bgp_nexthop_ipv6/rr/bgpd.conf
tests/topotests/bgp_nexthop_ipv6/test_bgp_nexthop_ipv6_topo1.py

index 9923edb348da906a7560196799b04fe0d1955759..f468ae1b3e37ae7313b03f3d56b7f405b0052883 100644 (file)
             "ip": "fd00:0:2::2",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r2:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::4",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r4:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:3::5",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:4::6",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::2",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r2:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::4",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r4:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:3::5",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:4::6",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
index bb2efa16d9e846dc6363e8a56daf0448cc326ba4..824db383a9ef76914644e64d82b736392b92ffcc 100644 (file)
@@ -9,7 +9,13 @@
             "ip": "fd00:0:2::1",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r1:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::4",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r4:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:3::5",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:4::6",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::1",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r1:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::4",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:r4:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:3::5",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:4::6",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-sw",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
index d0875474ae94f69d52c7d1a79781b449cb64145e..88e3efb617570eb23a22f70e50e8088a1f44ec34 100644 (file)
             "ip": "fd00:0:3::9",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global"
-          },
-          {
-            "ip": "link-local:rr:eth-r5",
-            "hostname": "rr",
-            "afi": "ipv6",
-            "scope": "link-local",
+            "scope": "global",
             "used": true
           }
         ]
             "ip": "fd00:0:3::9",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global"
-          },
-          {
-            "ip": "link-local:rr:eth-r5",
-            "hostname": "rr",
-            "afi": "ipv6",
-            "scope": "link-local",
+            "scope": "global",
             "used": true
           }
         ]
index cd48dd4697ce495bcb46e81fc8d4de5711f40309..1407eca359f1eb6740df54a228767c28b0b2a1e1 100644 (file)
@@ -9,7 +9,13 @@
             "ip": "fd00:0:2::1",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::2",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::4",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:3::5",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::1",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::2",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:2::4",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
             "ip": "fd00:0:3::5",
             "hostname": "rr",
             "afi": "ipv6",
-            "scope": "global",
+            "scope": "global"
+          },
+          {
+            "ip": "link-local:rr:eth-r6",
+            "hostname": "rr",
+            "afi": "ipv6",
+            "scope": "link-local",
             "used": true
           }
         ]
index 6dcded15258c6bd8605067c3c4820d2fcadf2881..705ae78b8e1e0f1d16733f4499395b15b8bb9fbf 100644 (file)
@@ -19,12 +19,17 @@ router bgp 65000
   neighbor fd00:0:4::6 route-reflector-client
  address-family ipv6 unicast
   neighbor fd00:0:2::1 route-reflector-client
+  neighbor fd00:0:2::1 nexthop-local unchanged
   neighbor fd00:0:2::1 activate
   neighbor fd00:0:2::2 route-reflector-client
+  neighbor fd00:0:2::2 nexthop-local unchanged
   neighbor fd00:0:2::2 activate
   neighbor fd00:0:2::3 route-reflector-client
+  neighbor fd00:0:2::3 nexthop-local unchanged
   neighbor fd00:0:2::3 activate
   neighbor fd00:0:2::4 nexthop-local unchanged
   neighbor fd00:0:2::4 activate
+  neighbor fd00:0:3::5 nexthop-local unchanged
   neighbor fd00:0:3::5 activate
+  neighbor fd00:0:4::6 nexthop-local unchanged
   neighbor fd00:0:4::6 activate
index 24d71f5622ae49e387a3a82aeeb6351ff93210f4..e478139eb1e617f038ce6a9e0c283ba91901c58c 100644 (file)
@@ -165,6 +165,21 @@ def replace_link_local(expected, cache):
             nexthop["ip"] = ip
 
 
+def check_rr_sub_group(expected):
+    tgen = get_topogen()
+
+    rr = tgen.gears["rr"]
+
+    output = json.loads(rr.vtysh_cmd("show bgp update-groups json"))
+    actual = [
+        subgroup["peers"]
+        for entry in output.get("default", {}).values()
+        for subgroup in entry["subGroup"]
+    ]
+
+    return topotest.json_cmp(actual, expected)
+
+
 def teardown_module(_mod):
     "Teardown the pytest environment"
     tgen = get_topogen()
@@ -222,6 +237,19 @@ def test_bgp_ipv6_table_step1():
         assertmsg = "{}: BGP IPv6 Nexthop failure".format(router.name)
         assert res is None, assertmsg
 
+    # check rr sub-groups
+    expected = [
+        ["fd00:0:2::1", "fd00:0:2::2"],
+        ["fd00:0:2::3"],
+        ["fd00:0:2::4"],
+        ["fd00:0:3::5"],
+        ["fd00:0:4::6"],
+    ]
+
+    test_func = partial(check_rr_sub_group, expected)
+    _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert result is None, "Peer group split failed"
+
 
 def test_bgp_ipv6_table_step2():
     tgen = get_topogen()
@@ -236,7 +264,12 @@ def test_bgp_ipv6_table_step2():
 configure terminal
 router bgp 65000
  address-family ipv6 unicast
+  no neighbor fd00:0:2::1 nexthop-local unchanged
+  no neighbor fd00:0:2::2 nexthop-local unchanged
+  no neighbor fd00:0:2::3 nexthop-local unchanged
   no neighbor fd00:0:2::4 nexthop-local unchanged
+  no neighbor fd00:0:3::5 nexthop-local unchanged
+  no neighbor fd00:0:4::6 nexthop-local unchanged
 """
     )
 
@@ -257,6 +290,71 @@ router bgp 65000
         assertmsg = "{}: BGP IPv6 Nexthop failure".format(router.name)
         assert res is None, assertmsg
 
+    # check rr sub-groups
+    expected = [
+        ["fd00:0:2::1", "fd00:0:2::2"],
+        ["fd00:0:2::3"],
+        ["fd00:0:3::5", "fd00:0:2::4"],
+        ["fd00:0:4::6"],
+    ]
+
+    test_func = partial(check_rr_sub_group, expected)
+    _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert result is None, "Peer group split failed"
+
+
+def test_bgp_ipv6_table_step3():
+    tgen = get_topogen()
+
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    rr = tgen.gears["rr"]
+    rr.vtysh_cmd(
+        """
+configure terminal
+router bgp 65000
+ address-family ipv6 unicast
+  neighbor fd00:0:2::1 nexthop-local unchanged
+  neighbor fd00:0:2::2 nexthop-local unchanged
+  neighbor fd00:0:2::3 nexthop-local unchanged
+  neighbor fd00:0:2::4 nexthop-local unchanged
+  neighbor fd00:0:3::5 nexthop-local unchanged
+  neighbor fd00:0:4::6 nexthop-local unchanged
+"""
+    )
+
+    router_list = tgen.routers().values()
+    for router in router_list:
+        # router.cmd("vtysh -c 'sh bgp ipv6 json' >/tmp/show_bgp_ipv6_%s.json" % router.name)
+        ref_file = "{}/{}/show_bgp_ipv6_step1.json".format(CWD, router.name)
+        expected = json.loads(open(ref_file).read())
+        replace_link_local(expected, link_local_cache)
+
+        test_func = partial(
+            topotest.router_json_cmp,
+            router,
+            "show bgp ipv6 unicast json",
+            expected,
+        )
+        _, res = topotest.run_and_expect(test_func, None, count=30, wait=1)
+        assertmsg = "{}: BGP IPv6 Nexthop failure".format(router.name)
+        assert res is None, assertmsg
+
+    # check rr sub-groups
+    expected = [
+        ["fd00:0:2::1", "fd00:0:2::2"],
+        ["fd00:0:2::3"],
+        ["fd00:0:2::4"],
+        ["fd00:0:3::5"],
+        ["fd00:0:4::6"],
+    ]
+
+    test_func = partial(check_rr_sub_group, expected)
+    _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert result is None, "Peer group split failed"
+
 
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]