From e2bbf175a2184bd76f6c54ccf8456babeb1a46fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 9 Apr 2024 15:16:35 +0200 Subject: Adding upstream version 9.1. Signed-off-by: Daniel Baumann --- .../topotests/zebra_seg6local_route/r1/routes.json | 123 +++++++++++++++++++++ tests/topotests/zebra_seg6local_route/r1/setup.sh | 6 + .../topotests/zebra_seg6local_route/r1/sharpd.conf | 0 .../topotests/zebra_seg6local_route/r1/zebra.conf | 9 ++ .../test_zebra_seg6local_route.py | 110 ++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 tests/topotests/zebra_seg6local_route/r1/routes.json create mode 100644 tests/topotests/zebra_seg6local_route/r1/setup.sh create mode 100644 tests/topotests/zebra_seg6local_route/r1/sharpd.conf create mode 100644 tests/topotests/zebra_seg6local_route/r1/zebra.conf create mode 100755 tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py (limited to 'tests/topotests/zebra_seg6local_route') diff --git a/tests/topotests/zebra_seg6local_route/r1/routes.json b/tests/topotests/zebra_seg6local_route/r1/routes.json new file mode 100644 index 0000000..e391922 --- /dev/null +++ b/tests/topotests/zebra_seg6local_route/r1/routes.json @@ -0,0 +1,123 @@ +[ + { + "in": { + "dest": "1::1", + "context": "End" + }, + "out":[{ + "prefix":"1::1/128", + "protocol":"sharp", + "selected":true, + "destSelected":true, + "distance":150, + "metric":0, + "installed":true, + "table":254, + "nexthops":[{ + "flags":3, + "fib":true, + "active":true, + "directlyConnected":true, + "interfaceName": "dum0", + "seg6local": { "action": "End" } + }] + }] + }, + { + "in": { + "dest": "2::1", + "context": "End_X 2001::1" + }, + "out":[{ + "prefix":"2::1/128", + "protocol":"sharp", + "selected":true, + "destSelected":true, + "distance":150, + "metric":0, + "installed":true, + "table":254, + "nexthops":[{ + "flags":3, + "fib":true, + "active":true, + "directlyConnected":true, + "interfaceName": "dum0", + "seg6local": { "action": "End.X" } + }] + }] + }, + { + "in": { + "dest": "3::1", + "context": "End_T 10" + }, + "out":[{ + "prefix":"3::1/128", + "protocol":"sharp", + "selected":true, + "destSelected":true, + "distance":150, + "metric":0, + "installed":true, + "table":254, + "nexthops":[{ + "flags":3, + "fib":true, + "active":true, + "directlyConnected":true, + "interfaceName": "dum0", + "seg6local": { "action": "End.T" } + }] + }] + }, + { + "in": { + "dest": "4::1", + "context": "End_DX4 10.0.0.1" + }, + "out":[{ + "prefix":"4::1/128", + "protocol":"sharp", + "selected":true, + "destSelected":true, + "distance":150, + "metric":0, + "installed":true, + "table":254, + "nexthops":[{ + "flags":3, + "fib":true, + "active":true, + "directlyConnected":true, + "interfaceName": "dum0", + "seg6local": { "action": "End.DX4" } + }] + }] + }, + { + "in": { + "dest": "5::1", + "context": "End_DT46 10" + }, + "out":[{ + "prefix":"5::1/128", + "protocol":"sharp", + "selected":true, + "destSelected":true, + "distance":150, + "metric":0, + "installed":true, + "table":254, + "nexthops":[{ + "flags":3, + "fib":true, + "active":true, + "directlyConnected":true, + "interfaceName": "dum0", + "seg6local": { "action": "End.DT46" } + }] + }], + "required_kernel": "5.14" + } +] diff --git a/tests/topotests/zebra_seg6local_route/r1/setup.sh b/tests/topotests/zebra_seg6local_route/r1/setup.sh new file mode 100644 index 0000000..ec27ec9 --- /dev/null +++ b/tests/topotests/zebra_seg6local_route/r1/setup.sh @@ -0,0 +1,6 @@ +ip link add dum0 type dummy +ip link set dum0 up +ip link add vrf10 type vrf table 10 +ip link set vrf10 up +sysctl -w net.ipv6.conf.dum0.disable_ipv6=0 +sysctl -w net.vrf.strict_mode=1 diff --git a/tests/topotests/zebra_seg6local_route/r1/sharpd.conf b/tests/topotests/zebra_seg6local_route/r1/sharpd.conf new file mode 100644 index 0000000..e69de29 diff --git a/tests/topotests/zebra_seg6local_route/r1/zebra.conf b/tests/topotests/zebra_seg6local_route/r1/zebra.conf new file mode 100644 index 0000000..dee7a91 --- /dev/null +++ b/tests/topotests/zebra_seg6local_route/r1/zebra.conf @@ -0,0 +1,9 @@ +log file zebra.log +! +log stdout notifications +log monitor notifications +log commands +! +! debug zebra packet +! debug zebra dplane +! debug zebra kernel msgdump diff --git a/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py b/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py new file mode 100755 index 0000000..0dc8774 --- /dev/null +++ b/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# test_zebra_seg6local_route.py +# +# Copyright (c) 2020 by +# LINE Corporation, Hiroki Shirokura +# + +""" +test_zebra_seg6local_route.py: Test seg6local route addition with zapi. +""" + +import os +import sys +import pytest +import json +from functools import partial + +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger +from lib.common_config import required_linux_kernel_version + +pytestmark = [pytest.mark.sharpd] + + +def open_json_file(filename): + try: + with open(filename, "r") as f: + return json.load(f) + except IOError: + assert False, "Could not read file {}".format(filename) + + +def setup_module(mod): + tgen = Topogen({None: "r1"}, mod.__name__) + tgen.start_topology() + router_list = tgen.routers() + for rname, router in tgen.routers().items(): + router.run( + "/bin/bash {}".format(os.path.join(CWD, "{}/setup.sh".format(rname))) + ) + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname)) + ) + tgen.start_router() + + +def teardown_module(_mod): + tgen = get_topogen() + tgen.stop_topology() + + +def test_zebra_seg6local_routes(): + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + logger.info("Test for seg6local route install via ZAPI was start.") + r1 = tgen.gears["r1"] + + def check(router, dest, expected): + output = json.loads(router.vtysh_cmd("show ipv6 route {} json".format(dest))) + output = output.get("{}/128".format(dest)) + if output is None: + return False + return topotest.json_cmp(output, expected) + + manifests = open_json_file(os.path.join(CWD, "{}/routes.json".format("r1"))) + for manifest in manifests: + dest = manifest["in"]["dest"] + context = manifest["in"]["context"] + + logger.info("CHECK {} {}".format(dest, context)) + + if manifest.get("required_kernel") is not None: + if required_linux_kernel_version(manifest["required_kernel"]) is not True: + logger.info( + "Kernel requirements are not met. Skipping {} {}".format( + dest, context + ) + ) + continue + + r1.vtysh_cmd( + "sharp install seg6local-routes {} nexthop-seg6local dum0 {} 1".format( + dest, context + ) + ) + test_func = partial( + check, + r1, + dest, + manifest["out"], + ) + success, result = topotest.run_and_expect(test_func, None, count=25, wait=1) + assert result is None, "Failed" + + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) -- cgit v1.2.3