From d1545c7bd0c1a52d90d3dd6bcfef2c0a7f563331 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 28 Mar 2024 13:58:33 +0100 Subject: [PATCH] tests: ipv6 global removal in bgp_nexthop_mp_ipv4_6 Test ipv6 global removal in bgp_nexthop_mp_ipv4_6 Signed-off-by: Louis Scalbert --- .../r1/bgp_ipv6_step2.json | 54 ++++++++++++++++++ .../r2/bgp_ipv6_step2.json | 33 +++++++++++ .../r3/bgp_ipv6_step2.json | 33 +++++++++++ .../r4/bgp_ipv6_step2.json | 34 ++++++++++++ .../r5/bgp_ipv6_step2.json | 1 + .../r6/bgp_ipv6_step2.json | 32 +++++++++++ .../r7/bgp_ipv6_step2.json | 37 +++++++++++++ .../rr1/bgp_ipv6_step2.json | 47 ++++++++++++++++ .../test_nexthop_mp_ipv4_6.py | 55 +++++++++++++++++++ 9 files changed, 326 insertions(+) create mode 100755 tests/topotests/bgp_nexthop_mp_ipv4_6/r1/bgp_ipv6_step2.json create mode 100644 tests/topotests/bgp_nexthop_mp_ipv4_6/r2/bgp_ipv6_step2.json create mode 100644 tests/topotests/bgp_nexthop_mp_ipv4_6/r3/bgp_ipv6_step2.json create mode 100755 tests/topotests/bgp_nexthop_mp_ipv4_6/r4/bgp_ipv6_step2.json create mode 120000 tests/topotests/bgp_nexthop_mp_ipv4_6/r5/bgp_ipv6_step2.json create mode 100644 tests/topotests/bgp_nexthop_mp_ipv4_6/r6/bgp_ipv6_step2.json create mode 100644 tests/topotests/bgp_nexthop_mp_ipv4_6/r7/bgp_ipv6_step2.json create mode 100644 tests/topotests/bgp_nexthop_mp_ipv4_6/rr1/bgp_ipv6_step2.json diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r1/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r1/bgp_ipv6_step2.json new file mode 100755 index 000000000000..0be8cc6d3c33 --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r1/bgp_ipv6_step2.json @@ -0,0 +1,54 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "path": "", + "nexthops": [ + { + "ip": "::", + "afi": "ipv6", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "multipath": true, + "path": "65000 65600", + "nexthops": [ + { + "ip": "fd00:0:2::3", + "afi": "ipv6", + "scope": "global" + }, + { + "afi": "ipv6", + "scope": "link-local", + "used": true + } + ] + }, + { + "valid": true, + "bestpath": true, + "path": "65000 65600", + "nexthops": [ + { + "ip": "fd00:0:1::2", + "afi": "ipv6", + "scope": "global" + }, + { + "afi": "ipv6", + "scope": "link-local", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r2/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r2/bgp_ipv6_step2.json new file mode 100644 index 000000000000..1dbfdb08db3e --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r2/bgp_ipv6_step2.json @@ -0,0 +1,33 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65500", + "nexthops": [ + { + "afi": "ipv6", + "scope": "link-local", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65600", + "nexthops": [ + { + "ip": "fd00:1000::6", + "scope": "global", + "afi": "ipv6", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r3/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r3/bgp_ipv6_step2.json new file mode 100644 index 000000000000..1dbfdb08db3e --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r3/bgp_ipv6_step2.json @@ -0,0 +1,33 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65500", + "nexthops": [ + { + "afi": "ipv6", + "scope": "link-local", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65600", + "nexthops": [ + { + "ip": "fd00:1000::6", + "scope": "global", + "afi": "ipv6", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r4/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r4/bgp_ipv6_step2.json new file mode 100755 index 000000000000..0566d166a5ef --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r4/bgp_ipv6_step2.json @@ -0,0 +1,34 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65500", + "nexthops": [ + { + "ip": "fd00:1000::2", + "afi": "ipv6", + "scope": "global", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65600", + "nexthops": [ + { + "ip": "fd00:1000::6", + "scope": "global", + "afi": "ipv6", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r5/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r5/bgp_ipv6_step2.json new file mode 120000 index 000000000000..14083e140ca7 --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r5/bgp_ipv6_step2.json @@ -0,0 +1 @@ +../r4/bgp_ipv6_step2.json \ No newline at end of file diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r6/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r6/bgp_ipv6_step2.json new file mode 100644 index 000000000000..864441216970 --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r6/bgp_ipv6_step2.json @@ -0,0 +1,32 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "nexthops": [ + { + "ip": "fd00:1000::2", + "afi": "ipv6", + "scope": "global", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65600", + "nexthops": [ + { + "afi": "ipv6", + "scope": "link-local", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/r7/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/r7/bgp_ipv6_step2.json new file mode 100644 index 000000000000..4dbc881607cc --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/r7/bgp_ipv6_step2.json @@ -0,0 +1,37 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65000 65500", + "nexthops": [ + { + "ip": "fd00:0:9::6", + "afi": "ipv6", + "scope": "global" + }, + { + "afi": "ipv6", + "scope": "link-local", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "bestpath": true, + "path": "", + "nexthops": [ + { + "ip": "::", + "afi": "ipv6", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/rr1/bgp_ipv6_step2.json b/tests/topotests/bgp_nexthop_mp_ipv4_6/rr1/bgp_ipv6_step2.json new file mode 100644 index 000000000000..682c6f72d3e5 --- /dev/null +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/rr1/bgp_ipv6_step2.json @@ -0,0 +1,47 @@ +{ + "routes": { + "fd00:500::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65500", + "nexthops": [ + { + "ip": "fd00:1000::2", + "afi": "ipv6", + "scope": "global", + "used": true + } + ] + }, + { + "valid": true, + "multipath": true, + "path": "65500", + "nexthops": [ + { + "ip": "fd00:1000::3", + "afi": "ipv6", + "scope": "global", + "used": true + } + ] + } + ], + "fd00:600::/64": [ + { + "valid": true, + "bestpath": true, + "path": "65600", + "nexthops": [ + { + "ip": "fd00:1000::6", + "afi": "ipv6", + "scope": "global", + "used": true + } + ] + } + ] + } +} diff --git a/tests/topotests/bgp_nexthop_mp_ipv4_6/test_nexthop_mp_ipv4_6.py b/tests/topotests/bgp_nexthop_mp_ipv4_6/test_nexthop_mp_ipv4_6.py index bd966542aac4..7cc3af2a3fa9 100644 --- a/tests/topotests/bgp_nexthop_mp_ipv4_6/test_nexthop_mp_ipv4_6.py +++ b/tests/topotests/bgp_nexthop_mp_ipv4_6/test_nexthop_mp_ipv4_6.py @@ -201,6 +201,61 @@ def test_bgp_ping_ok_step1(): check_ping("h1", "fd00:600::1", True, 5, 1) +def test_bgp_ipv6_nexthop_step2(): + """ + Remove IPv6 global on r1 and r7 + Assert that BGP has correct ipv6 nexthops. + """ + + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + tgen.gears["r1"].vtysh_cmd( + """ +configure +interface eth-r2 + no ipv6 address fd00:0:1::1/64 +! +interface eth-r3 + no ipv6 address fd00:0:2::1/64 +""" + ) + tgen.gears["r7"].vtysh_cmd( + """ +configure +interface eth-r6 + no ipv6 address fd00:0:9::7/64 +""" + ) + + for rname, router in tgen.routers().items(): + if "h" in rname: + # hosts + continue + ref_file = "{}/{}/bgp_ipv6_step2.json".format(CWD, rname) + expected = json.loads(open(ref_file).read()) + 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(rname) + assert res is None, assertmsg + + +def test_bgp_ping_ok_step2(): + "Check that h1 pings h2" + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + check_ping("h1", "192.168.6.1", True, 5, 1) + check_ping("h1", "fd00:600::1", True, 5, 1) + + if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args))