diff --git a/tests/topotests/bgp_nexthop_ipv6/r1/show_bgp_ipv6_step1.json b/tests/topotests/bgp_nexthop_ipv6/r1/show_bgp_ipv6_step1.json index 9923edb348da..f468ae1b3e37 100644 --- a/tests/topotests/bgp_nexthop_ipv6/r1/show_bgp_ipv6_step1.json +++ b/tests/topotests/bgp_nexthop_ipv6/r1/show_bgp_ipv6_step1.json @@ -22,7 +22,13 @@ "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 } ] @@ -48,7 +54,13 @@ "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 } ] @@ -61,7 +73,13 @@ "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 } ] @@ -74,7 +92,13 @@ "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 } ] @@ -100,7 +124,13 @@ "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 } ] @@ -126,7 +156,13 @@ "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 } ] @@ -139,7 +175,13 @@ "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 } ] @@ -152,7 +194,13 @@ "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 } ] diff --git a/tests/topotests/bgp_nexthop_ipv6/r2/show_bgp_ipv6_step1.json b/tests/topotests/bgp_nexthop_ipv6/r2/show_bgp_ipv6_step1.json index bb2efa16d9e8..824db383a9ef 100644 --- a/tests/topotests/bgp_nexthop_ipv6/r2/show_bgp_ipv6_step1.json +++ b/tests/topotests/bgp_nexthop_ipv6/r2/show_bgp_ipv6_step1.json @@ -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 } ] @@ -48,7 +54,13 @@ "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 } ] @@ -61,7 +73,13 @@ "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 } ] @@ -74,7 +92,13 @@ "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 } ] @@ -87,7 +111,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 } ] @@ -126,7 +156,13 @@ "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 } ] @@ -139,7 +175,13 @@ "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 } ] @@ -152,7 +194,13 @@ "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 } ] diff --git a/tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step1.json b/tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step1.json index d0875474ae94..88e3efb61757 100644 --- a/tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step1.json +++ b/tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step1.json @@ -47,13 +47,7 @@ "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 } ] @@ -155,13 +149,7 @@ "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 } ] diff --git a/tests/topotests/bgp_nexthop_ipv6/r6/show_bgp_ipv6_step1.json b/tests/topotests/bgp_nexthop_ipv6/r6/show_bgp_ipv6_step1.json index cd48dd4697ce..1407eca359f1 100644 --- a/tests/topotests/bgp_nexthop_ipv6/r6/show_bgp_ipv6_step1.json +++ b/tests/topotests/bgp_nexthop_ipv6/r6/show_bgp_ipv6_step1.json @@ -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 } ] @@ -22,7 +28,13 @@ "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 } ] @@ -48,7 +60,13 @@ "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 } ] @@ -61,7 +79,13 @@ "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 } ] @@ -87,7 +111,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 } ] @@ -100,7 +130,13 @@ "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 } ] @@ -126,7 +162,13 @@ "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 } ] @@ -139,7 +181,13 @@ "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 } ] diff --git a/tests/topotests/bgp_nexthop_ipv6/rr/bgpd.conf b/tests/topotests/bgp_nexthop_ipv6/rr/bgpd.conf index 6dcded15258c..705ae78b8e1e 100644 --- a/tests/topotests/bgp_nexthop_ipv6/rr/bgpd.conf +++ b/tests/topotests/bgp_nexthop_ipv6/rr/bgpd.conf @@ -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 diff --git a/tests/topotests/bgp_nexthop_ipv6/test_bgp_nexthop_ipv6_topo1.py b/tests/topotests/bgp_nexthop_ipv6/test_bgp_nexthop_ipv6_topo1.py index 24d71f5622ae..e478139eb1e6 100644 --- a/tests/topotests/bgp_nexthop_ipv6/test_bgp_nexthop_ipv6_topo1.py +++ b/tests/topotests/bgp_nexthop_ipv6/test_bgp_nexthop_ipv6_topo1.py @@ -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 @@ def test_bgp_ipv6_table_step2(): 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:]