diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:53:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:53:30 +0000 |
commit | 2c7cac91ed6e7db0f6937923d2b57f97dbdbc337 (patch) | |
tree | c05dc0f8e6aa3accc84e3e5cffc933ed94941383 /tests/topotests/route_scale | |
parent | Initial commit. (diff) | |
download | frr-upstream.tar.xz frr-upstream.zip |
Adding upstream version 8.4.4.upstream/8.4.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/route_scale')
-rw-r--r-- | tests/topotests/route_scale/r1/installed.routes.json | 16 | ||||
-rw-r--r-- | tests/topotests/route_scale/r1/no.routes.json | 11 | ||||
-rw-r--r-- | tests/topotests/route_scale/r1/sharpd.conf | 76 | ||||
-rw-r--r-- | tests/topotests/route_scale/r1/zebra.conf | 96 | ||||
-rw-r--r-- | tests/topotests/route_scale/scale_test_common.py | 215 | ||||
-rw-r--r-- | tests/topotests/route_scale/test_route_scale1.py | 77 | ||||
-rw-r--r-- | tests/topotests/route_scale/test_route_scale2.py | 77 |
7 files changed, 568 insertions, 0 deletions
diff --git a/tests/topotests/route_scale/r1/installed.routes.json b/tests/topotests/route_scale/r1/installed.routes.json new file mode 100644 index 0000000..25d209f --- /dev/null +++ b/tests/topotests/route_scale/r1/installed.routes.json @@ -0,0 +1,16 @@ +{ + "routes":[ + { + "fib":32, + "rib":32, + "type":"connected" + }, + { + "fib":1000000, + "rib":1000000, + "type":"sharp" + } + ], + "routesTotal":1000032, + "routesTotalFib":1000032 +} diff --git a/tests/topotests/route_scale/r1/no.routes.json b/tests/topotests/route_scale/r1/no.routes.json new file mode 100644 index 0000000..abebd1b --- /dev/null +++ b/tests/topotests/route_scale/r1/no.routes.json @@ -0,0 +1,11 @@ +{ + "routes":[ + { + "fib":32, + "rib":32, + "type":"connected" + } + ], + "routesTotal":32, + "routesTotalFib":32 +} diff --git a/tests/topotests/route_scale/r1/sharpd.conf b/tests/topotests/route_scale/r1/sharpd.conf new file mode 100644 index 0000000..0848f34 --- /dev/null +++ b/tests/topotests/route_scale/r1/sharpd.conf @@ -0,0 +1,76 @@ +! +nexthop-group one + nexthop 192.168.0.1 r1-eth0 +! +nexthop-group two + nexthop 192.168.0.1 r1-eth0 + nexthop 192.168.1.1 r1-eth1 +! +nexthop-group four + nexthop 192.168.0.1 r1-eth0 + nexthop 192.168.1.1 r1-eth1 + nexthop 192.168.2.1 r1-eth2 + nexthop 192.168.3.1 r1-eth3 +! +nexthop-group eight + nexthop 192.168.0.1 r1-eth0 + nexthop 192.168.1.1 r1-eth1 + nexthop 192.168.2.1 r1-eth2 + nexthop 192.168.3.1 r1-eth3 + nexthop 192.168.4.1 r1-eth4 + nexthop 192.168.5.1 r1-eth5 + nexthop 192.168.6.1 r1-eth6 + nexthop 192.168.7.1 r1-eth7 +! +nexthop-group sixteen + nexthop 192.168.0.1 r1-eth0 + nexthop 192.168.1.1 r1-eth1 + nexthop 192.168.2.1 r1-eth2 + nexthop 192.168.3.1 r1-eth3 + nexthop 192.168.4.1 r1-eth4 + nexthop 192.168.5.1 r1-eth5 + nexthop 192.168.6.1 r1-eth6 + nexthop 192.168.7.1 r1-eth7 + nexthop 192.168.8.1 r1-eth8 + nexthop 192.168.9.1 r1-eth9 + nexthop 192.168.10.1 r1-eth10 + nexthop 192.168.11.1 r1-eth11 + nexthop 192.168.12.1 r1-eth12 + nexthop 192.168.13.1 r1-eth13 + nexthop 192.168.14.1 r1-eth14 + nexthop 192.168.15.1 r1-eth15 +! +nexthop-group thirtytwo + nexthop 192.168.0.1 r1-eth0 + nexthop 192.168.1.1 r1-eth1 + nexthop 192.168.2.1 r1-eth2 + nexthop 192.168.3.1 r1-eth3 + nexthop 192.168.4.1 r1-eth4 + nexthop 192.168.5.1 r1-eth5 + nexthop 192.168.6.1 r1-eth6 + nexthop 192.168.7.1 r1-eth7 + nexthop 192.168.8.1 r1-eth8 + nexthop 192.168.9.1 r1-eth9 + nexthop 192.168.10.1 r1-eth10 + nexthop 192.168.11.1 r1-eth11 + nexthop 192.168.12.1 r1-eth12 + nexthop 192.168.13.1 r1-eth13 + nexthop 192.168.14.1 r1-eth14 + nexthop 192.168.15.1 r1-eth15 + nexthop 192.168.16.1 r1-eth16 + nexthop 192.168.17.1 r1-eth17 + nexthop 192.168.18.1 r1-eth18 + nexthop 192.168.19.1 r1-eth19 + nexthop 192.168.20.1 r1-eth20 + nexthop 192.168.21.1 r1-eth21 + nexthop 192.168.22.1 r1-eth22 + nexthop 192.168.23.1 r1-eth23 + nexthop 192.168.24.1 r1-eth24 + nexthop 192.168.25.1 r1-eth25 + nexthop 192.168.26.1 r1-eth26 + nexthop 192.168.27.1 r1-eth27 + nexthop 192.168.28.1 r1-eth28 + nexthop 192.168.29.1 r1-eth29 + nexthop 192.168.30.1 r1-eth30 + nexthop 192.168.31.1 r1-eth31 +!
\ No newline at end of file diff --git a/tests/topotests/route_scale/r1/zebra.conf b/tests/topotests/route_scale/r1/zebra.conf new file mode 100644 index 0000000..48a01f4 --- /dev/null +++ b/tests/topotests/route_scale/r1/zebra.conf @@ -0,0 +1,96 @@ +int r1-eth0 + ip addr 192.168.0.1/24 +! +int r1-eth1 + ip addr 192.168.1.1/24 +! +int r1-eth2 + ip addr 192.168.2.1/24 +! +int r1-eth3 + ip addr 192.168.3.1/24 +! +int r1-eth4 + ip addr 192.168.4.1/24 +! +int r1-eth5 + ip addr 192.168.5.1/24 +! +int r1-eth6 + ip addr 192.168.6.1/24 +! +int r1-eth7 + ip addr 192.168.7.1/24 +! +int r1-eth8 + ip addr 192.168.8.1/24 +! +int r1-eth9 + ip addr 192.168.9.1/24 +! +int r1-eth10 + ip addr 192.168.10.1/24 +! +int r1-eth11 + ip addr 192.168.11.1/24 +! +int r1-eth12 + ip addr 192.168.12.1/24 +! +int r1-eth13 + ip addr 192.168.13.1/24 +! +int r1-eth14 + ip addr 192.168.14.1/24 +! +int r1-eth15 + ip addr 192.168.15.1/24 +! +int r1-eth16 + ip addr 192.168.16.1/24 +! +int r1-eth17 + ip addr 192.168.17.1/24 +! +int r1-eth18 + ip addr 192.168.18.1/24 +! +int r1-eth19 + ip addr 192.168.19.1/24 +! +int r1-eth20 + ip addr 192.168.20.1/24 +! +int r1-eth21 + ip addr 192.168.21.1/24 +! +int r1-eth22 + ip addr 192.168.22.1/24 +! +int r1-eth23 + ip addr 192.168.23.1/24 +! +int r1-eth24 + ip addr 192.168.24.1/24 +! +int r1-eth25 + ip addr 192.168.25.1/24 +! +int r1-eth26 + ip addr 192.168.26.1/24 +! +int r1-eth27 + ip addr 192.168.27.1/24 +! +int r1-eth28 + ip addr 192.168.28.1/24 +! +int r1-eth29 + ip addr 192.168.29.1/24 +! +int r1-eth30 + ip addr 192.168.30.1/24 +! +int r1-eth31 + ip addr 192.168.31.1/24 +!
\ No newline at end of file diff --git a/tests/topotests/route_scale/scale_test_common.py b/tests/topotests/route_scale/scale_test_common.py new file mode 100644 index 0000000..856a2d0 --- /dev/null +++ b/tests/topotests/route_scale/scale_test_common.py @@ -0,0 +1,215 @@ +#!/usr/bin/env python + +# +# scale_test_common.py +# +# Copyright (c) 2020 by +# Cumulus Networks, Inc. +# Donald Sharp +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +scale_test_common.py: Common routines for testing route scale + +""" + +import os +import re +import sys +import pytest +import json +from functools import partial + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger + + +##################################################### +## +## Network Topology Definition +## +##################################################### + + +def scale_build_common(tgen): + "Build function" + + # Populate routers + for routern in range(1, 2): + tgen.add_router("r{}".format(routern)) + + # Populate switches + for switchn in range(1, 33): + switch = tgen.add_switch("sw{}".format(switchn)) + switch.add_link(tgen.gears["r1"]) + + +def scale_setup_module(module): + "Setup topology" + tgen = Topogen(scale_build_common, module.__name__) + tgen.start_topology() + + router_list = tgen.routers() + for rname, router in router_list.items(): + 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() + # tgen.mininet_cli() + + +def scale_teardown_module(_mod): + "Teardown the pytest environment" + tgen = get_topogen() + + # This function tears down the whole topology. + tgen.stop_topology() + + +def scale_converge_protocols(): + "Wait for protocol convergence" + + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + +def run_one_setup(r1, s): + "Run one ecmp config" + + # Extract params + expected_installed = s["expect_in"] + expected_removed = s["expect_rem"] + + retries = s["retries"] + wait = s["wait"] + + for d in expected_installed["routes"]: + if d["type"] == "sharp": + count = d["rib"] + break + + logger.info("Testing {} routes X {} ecmp".format(count, s["ecmp"])) + + r1.vtysh_cmd( + "sharp install route 1.0.0.0 \ + nexthop-group {} {}".format( + s["nhg"], count + ), + isjson=False, + ) + + test_func = partial( + topotest.router_json_cmp, r1, "show ip route summary json", expected_installed + ) + success, result = topotest.run_and_expect(test_func, None, retries, wait) + assert success, "Route scale test install failed:\n{}".format(result) + + output = r1.vtysh_cmd("sharp data route", isjson=False) + logger.info("{} routes X {} ecmp installed".format(count, s["ecmp"])) + logger.info(output) + r1.vtysh_cmd("sharp remove route 1.0.0.0 {}".format(count), isjson=False) + test_func = partial( + topotest.router_json_cmp, r1, "show ip route summary json", expected_removed + ) + success, result = topotest.run_and_expect(test_func, None, retries, wait) + assert success, "Route scale test remove failed:\n{}".format(result) + + output = r1.vtysh_cmd("sharp data route", isjson=False) + logger.info("{} routes x {} ecmp removed".format(count, s["ecmp"])) + logger.info(output) + + +def route_install_helper(iter): + "Test route install for a variety of ecmp" + + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + r1 = tgen.gears["r1"] + + # Avoid top ecmp case for runs with < 4G memory + output = tgen.net.cmd_raises("free") + m = re.search(r"Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)", output) + total_mem = int(m.group(2)) + if total_mem < 4000000 and iter == 5: + logger.info( + "Limited memory available: {}, skipping x32 testcase".format(total_mem) + ) + return; + + installed_file = "{}/r1/installed.routes.json".format(CWD) + expected_installed = json.loads(open(installed_file).read()) + + removed_file = "{}/r1/no.routes.json".format(CWD) + expected_removed = json.loads(open(removed_file).read()) + + # dict keys of params: ecmp number, corresponding nhg name, timeout, + # number of times to wait + scale_keys = ["ecmp", "nhg", "wait", "retries", "expect_in", "expect_rem"] + + # Table of defaults, used for timeout values and 'expected' objects + scale_defaults = dict( + zip(scale_keys, [None, None, 7, 30, expected_installed, expected_removed]) + ) + + # List of params for each step in the test; note extra time given + # for the highest ecmp steps. Executing 'show' at scale can be costly + # so we widen the interval there too. + scale_steps = [ + [1, "one"], + [2, "two"], + [4, "four"], + [8, "eight"], + [16, "sixteen", 10, 40], + [32, "thirtytwo", 10, 40], + ] + + # Build up a list of dicts with params for each step of the test; + # use defaults where the step doesn't supply a value + scale_setups = [] + s = scale_steps[iter] + + d = dict(zip(scale_keys, s)) + for k in scale_keys: + if k not in d: + d[k] = scale_defaults[k] + + run_one_setup(r1, d) + + +# Mem leak testcase +def scale_test_memory_leak(): + "Run the memory leak test and report results." + tgen = get_topogen() + if not tgen.is_memleak_enabled(): + pytest.skip("Memory leak test/report is disabled") + tgen.report_memory_leaks() diff --git a/tests/topotests/route_scale/test_route_scale1.py b/tests/topotests/route_scale/test_route_scale1.py new file mode 100644 index 0000000..b563883 --- /dev/null +++ b/tests/topotests/route_scale/test_route_scale1.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +# +# test_route_scale1.py +# +# Copyright (c) 2021 by +# Nvidia, Inc. +# Donald Sharp +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +test_route_scale1.py: Testing route scale + +""" +import os +import re +import sys +import pytest +import json +from functools import partial + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger + +from scale_test_common import scale_build_common, scale_setup_module, route_install_helper, scale_test_memory_leak, scale_converge_protocols, scale_teardown_module + + +pytestmark = [pytest.mark.sharpd] + +def build(tgen): + scale_build_common(tgen) + +def setup_module(module): + scale_setup_module(module) + +def teardown_module(_mod): + scale_teardown_module(_mod) + +def test_converge_protocols(): + scale_converge_protocols() + +def test_route_install_2nh(): + route_install_helper(1) + +def test_route_install_4nh(): + route_install_helper(2) + +def test_route_install_16nh(): + route_install_helper(4) + +def test_memory_leak(): + scale_test_memory_leak() + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) diff --git a/tests/topotests/route_scale/test_route_scale2.py b/tests/topotests/route_scale/test_route_scale2.py new file mode 100644 index 0000000..7045995 --- /dev/null +++ b/tests/topotests/route_scale/test_route_scale2.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +# +# test_route_scale2.py +# +# Copyright (c) 2022 by +# Nvidia, Inc. +# Donald Sharp +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NVIDIA DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NVIDIA BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +test_route_scale2.py: Testing route scale + +""" +import os +import re +import sys +import pytest +import json +from functools import partial + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger + +from scale_test_common import scale_build_common, scale_setup_module, route_install_helper, scale_test_memory_leak, scale_converge_protocols, scale_teardown_module + + +pytestmark = [pytest.mark.sharpd] + +def build(tgen): + scale_build_common(tgen) + +def setup_module(module): + scale_setup_module(module) + +def teardown_module(_mod): + scale_teardown_module(_mod) + +def test_converge_protocols(): + scale_converge_protocols() + +def test_route_install_1nh(): + route_install_helper(0) + +def test_route_install_8nh(): + route_install_helper(3) + +def test_route_install_32nh(): + route_install_helper(5) + +def test_memory_leak(): + scale_test_memory_leak() + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) |