summaryrefslogtreecommitdiffstats
path: root/tests/topotests/fpm_testing_topo1
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/fpm_testing_topo1')
-rw-r--r--tests/topotests/fpm_testing_topo1/r1/fpm_counters.json8
-rw-r--r--tests/topotests/fpm_testing_topo1/r1/fpm_stub.conf0
-rw-r--r--tests/topotests/fpm_testing_topo1/r1/routes_summ.json27
-rw-r--r--tests/topotests/fpm_testing_topo1/r1/routes_summ_removed.json20
-rw-r--r--tests/topotests/fpm_testing_topo1/r1/sharpd.conf0
-rw-r--r--tests/topotests/fpm_testing_topo1/r1/zebra.conf5
-rw-r--r--tests/topotests/fpm_testing_topo1/test_fpm_topo1.py135
7 files changed, 195 insertions, 0 deletions
diff --git a/tests/topotests/fpm_testing_topo1/r1/fpm_counters.json b/tests/topotests/fpm_testing_topo1/r1/fpm_counters.json
new file mode 100644
index 0000000..05a6731
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/r1/fpm_counters.json
@@ -0,0 +1,8 @@
+{
+ "connected":true,
+ "useNHG":true,
+ "useRouteReplace":true,
+ "disabled":false,
+ "address":"127.0.0.1",
+ "port":2620
+}
diff --git a/tests/topotests/fpm_testing_topo1/r1/fpm_stub.conf b/tests/topotests/fpm_testing_topo1/r1/fpm_stub.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/r1/fpm_stub.conf
diff --git a/tests/topotests/fpm_testing_topo1/r1/routes_summ.json b/tests/topotests/fpm_testing_topo1/r1/routes_summ.json
new file mode 100644
index 0000000..e9157bc
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/r1/routes_summ.json
@@ -0,0 +1,27 @@
+{
+ "routes":[
+ {
+ "fib":1,
+ "rib":1,
+ "fibOffLoaded":0,
+ "fibTrapped":0,
+ "type":"connected"
+ },
+ {
+ "fib":1,
+ "rib":1,
+ "fibOffLoaded":0,
+ "fibTrapped":0,
+ "type":"local"
+ },
+ {
+ "fib":10000,
+ "rib":10000,
+ "fibOffLoaded":0,
+ "fibTrapped":0,
+ "type":"sharp"
+ }
+ ],
+ "routesTotal":10002,
+ "routesTotalFib":10002
+}
diff --git a/tests/topotests/fpm_testing_topo1/r1/routes_summ_removed.json b/tests/topotests/fpm_testing_topo1/r1/routes_summ_removed.json
new file mode 100644
index 0000000..8585b2b
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/r1/routes_summ_removed.json
@@ -0,0 +1,20 @@
+{
+ "routes":[
+ {
+ "fib":1,
+ "rib":1,
+ "fibOffLoaded":0,
+ "fibTrapped":0,
+ "type":"connected"
+ },
+ {
+ "fib":1,
+ "rib":1,
+ "fibOffLoaded":0,
+ "fibTrapped":0,
+ "type":"local"
+ }
+ ],
+ "routesTotal":2,
+ "routesTotalFib":2
+}
diff --git a/tests/topotests/fpm_testing_topo1/r1/sharpd.conf b/tests/topotests/fpm_testing_topo1/r1/sharpd.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/r1/sharpd.conf
diff --git a/tests/topotests/fpm_testing_topo1/r1/zebra.conf b/tests/topotests/fpm_testing_topo1/r1/zebra.conf
new file mode 100644
index 0000000..c7b1646
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/r1/zebra.conf
@@ -0,0 +1,5 @@
+fpm address 127.0.0.1
+
+interface r1-eth0
+ ip address 192.168.44.1/24
+!
diff --git a/tests/topotests/fpm_testing_topo1/test_fpm_topo1.py b/tests/topotests/fpm_testing_topo1/test_fpm_topo1.py
new file mode 100644
index 0000000..22fc50b
--- /dev/null
+++ b/tests/topotests/fpm_testing_topo1/test_fpm_topo1.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+#
+# test_route_scale1.py
+#
+# Copyright (c) 2024 by
+# Nvidia, Inc.
+# Donald Sharp
+#
+
+"""
+test_fpm_topo1.py: Testing FPM module
+
+"""
+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
+
+
+pytestmark = [pytest.mark.fpm, pytest.mark.sharpd]
+
+
+def build_topo(tgen):
+ "Build function"
+
+ # Populate routers
+ tgen.add_router("r1")
+
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["r1"])
+
+
+def setup_module(module):
+ "Setup topology"
+
+ # fpm_stub = os.system("which fpm-stub")
+ # if fpm-stub:
+ # pytest.skip("")
+
+ tgen = Topogen(build_topo, 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)),
+ "-M dplane_fpm_nl",
+ )
+ router.load_config(
+ TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname))
+ )
+ router.load_config(
+ TopoRouter.RD_FPM_LISTENER,
+ os.path.join(CWD, "{}/fpm_stub.conf".format(rname)),
+ )
+
+ tgen.start_router()
+
+
+def teardown_module(_mod):
+ "Teardown the pytest environment"
+
+ tgen = get_topogen()
+
+ # This function tears down the whole topology.
+ tgen.stop_topology()
+
+
+def test_fpm_connection_made():
+ "Test that the fpm starts up and a connection is made"
+
+ tgen = get_topogen()
+ router = tgen.gears["r1"]
+
+ fpm_counters = "{}/r1/fpm_counters.json".format(CWD)
+ expected = json.loads(open(fpm_counters).read())
+
+ test_func = partial(
+ topotest.router_json_cmp, router, "show fpm status json", expected
+ )
+
+ success, result = topotest.run_and_expect(test_func, None, 30, 1)
+ assert success, "Unable to connect to the fpm:\n{}".format(result)
+
+
+def test_fpm_install_routes():
+ "Test that simple routes installed appears to work"
+
+ tgen = get_topogen()
+ router = tgen.gears["r1"]
+
+ # Let's install 10000 routes
+ router.vtysh_cmd("sharp install routes 10.0.0.0 nexthop 192.168.44.33 10000")
+ routes_file = "{}/r1/routes_summ.json".format(CWD)
+ expected = json.loads(open(routes_file).read())
+
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip route summ json", expected
+ )
+
+ success, result = topotest.run_and_expect(test_func, None, 60, 1)
+ assert success, "Unable to successfully install 10000 routes: {}".format(result)
+
+ # Let's remove 10000 routes
+ router.vtysh_cmd("sharp remove routes 10.0.0.0 10000")
+
+ routes_file_removed = "{}/r1/routes_summ_removed.json".format(CWD)
+ expected = json.loads(open(routes_file_removed).read())
+
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip route summ json", expected
+ )
+
+ success, result = topotest.run_and_expect(test_func, None, 60, 1)
+ assert success, "Unable to remove 10000 routes: {}".format(result)
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))