summaryrefslogtreecommitdiffstats
path: root/tests/topotests/ospf_suppress_fa
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:32 +0000
commit35cadacd2bb9383686753731e31bd7e145fb2506 (patch)
tree4489adbde75a837989533837185b2b8369a0bf68 /tests/topotests/ospf_suppress_fa
parentAdding debian version 9.1-0.1. (diff)
downloadfrr-35cadacd2bb9383686753731e31bd7e145fb2506.tar.xz
frr-35cadacd2bb9383686753731e31bd7e145fb2506.zip
Merging upstream version 10.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/ospf_suppress_fa')
-rw-r--r--tests/topotests/ospf_suppress_fa/r1/initial.json44
-rw-r--r--tests/topotests/ospf_suppress_fa/r1/neighbor.json13
-rw-r--r--tests/topotests/ospf_suppress_fa/r1/post.json44
-rw-r--r--tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py87
4 files changed, 150 insertions, 38 deletions
diff --git a/tests/topotests/ospf_suppress_fa/r1/initial.json b/tests/topotests/ospf_suppress_fa/r1/initial.json
new file mode 100644
index 0000000..f0e6110
--- /dev/null
+++ b/tests/topotests/ospf_suppress_fa/r1/initial.json
@@ -0,0 +1,44 @@
+{
+ "routerId":"10.0.12.1",
+ "asExternalLinkStates":[
+ {
+ "options":"*|-|-|-|-|-|E|-",
+ "lsaFlags":6,
+ "lsaType":"AS-external-LSA",
+ "linkStateId":"3.3.1.1",
+ "advertisingRouter":"10.0.23.2",
+ "networkMask":32,
+ "metricType":"E2 (Larger than any link state path)",
+ "tos":0,
+ "metric":20,
+ "forwardAddress":"10.0.23.3",
+ "externalRouteTag":0
+ },
+ {
+ "options":"*|-|-|-|-|-|E|-",
+ "lsaFlags":6,
+ "lsaType":"AS-external-LSA",
+ "linkStateId":"3.3.2.2",
+ "advertisingRouter":"10.0.23.2",
+ "networkMask":32,
+ "metricType":"E2 (Larger than any link state path)",
+ "tos":0,
+ "metric":20,
+ "forwardAddress":"10.0.23.3",
+ "externalRouteTag":0
+ },
+ {
+ "options":"*|-|-|-|-|-|E|-",
+ "lsaFlags":6,
+ "lsaType":"AS-external-LSA",
+ "linkStateId":"3.3.3.3",
+ "advertisingRouter":"10.0.23.2",
+ "networkMask":32,
+ "metricType":"E2 (Larger than any link state path)",
+ "tos":0,
+ "metric":20,
+ "forwardAddress":"10.0.23.3",
+ "externalRouteTag":0
+ }
+ ]
+}
diff --git a/tests/topotests/ospf_suppress_fa/r1/neighbor.json b/tests/topotests/ospf_suppress_fa/r1/neighbor.json
new file mode 100644
index 0000000..417fcbe
--- /dev/null
+++ b/tests/topotests/ospf_suppress_fa/r1/neighbor.json
@@ -0,0 +1,13 @@
+{
+ "neighbors":{
+ "10.0.23.2":[
+ {
+ "nbrPriority":1,
+ "converged":"Full",
+ "role":"DROther",
+ "ifaceAddress":"10.0.12.2",
+ "ifaceName":"r1-eth0:10.0.12.1"
+ }
+ ]
+ }
+}
diff --git a/tests/topotests/ospf_suppress_fa/r1/post.json b/tests/topotests/ospf_suppress_fa/r1/post.json
new file mode 100644
index 0000000..98cbf8f
--- /dev/null
+++ b/tests/topotests/ospf_suppress_fa/r1/post.json
@@ -0,0 +1,44 @@
+{
+ "routerId":"10.0.12.1",
+ "asExternalLinkStates":[
+ {
+ "options":"*|-|-|-|-|-|E|-",
+ "lsaFlags":6,
+ "lsaType":"AS-external-LSA",
+ "linkStateId":"3.3.1.1",
+ "advertisingRouter":"10.0.23.2",
+ "networkMask":32,
+ "metricType":"E2 (Larger than any link state path)",
+ "tos":0,
+ "metric":20,
+ "forwardAddress":"0.0.0.0",
+ "externalRouteTag":0
+ },
+ {
+ "options":"*|-|-|-|-|-|E|-",
+ "lsaFlags":6,
+ "lsaType":"AS-external-LSA",
+ "linkStateId":"3.3.2.2",
+ "advertisingRouter":"10.0.23.2",
+ "networkMask":32,
+ "metricType":"E2 (Larger than any link state path)",
+ "tos":0,
+ "metric":20,
+ "forwardAddress":"0.0.0.0",
+ "externalRouteTag":0
+ },
+ {
+ "options":"*|-|-|-|-|-|E|-",
+ "lsaFlags":6,
+ "lsaType":"AS-external-LSA",
+ "linkStateId":"3.3.3.3",
+ "advertisingRouter":"10.0.23.2",
+ "networkMask":32,
+ "metricType":"E2 (Larger than any link state path)",
+ "tos":0,
+ "metric":20,
+ "forwardAddress":"0.0.0.0",
+ "externalRouteTag":0
+ }
+ ]
+}
diff --git a/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py b/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py
index d5583ac..8b3fc58 100644
--- a/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py
+++ b/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py
@@ -22,6 +22,8 @@ test_ospf_unset_suppress_fa()
import os
import sys
+import json
+from functools import partial
import re
import pytest
@@ -33,6 +35,7 @@ sys.path.append(os.path.join(CWD, "../"))
# Import topogen and topotest helpers
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
+from lib.topolog import logger
# Required to instantiate the topology builder class.
@@ -75,6 +78,7 @@ def setup_module(mod):
TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
)
+ logger.info("Module Setup")
tgen.start_router()
@@ -93,7 +97,17 @@ def test_converge_protocols():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- topotest.sleep(10, "Waiting for OSPF convergence")
+ router = tgen.gears["r1"]
+ json_file = "{}/r1/neighbor.json".format(CWD)
+ expected = json.loads(open(json_file).read())
+
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip ospf neighbor json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "r1 has not converged"
+
+ logger.info("Converged Protocol")
def ospf_configure_suppress_fa(router_name, area):
@@ -114,58 +128,55 @@ def ospf_unconfigure_suppress_fa(router_name, area):
router.vtysh_cmd("conf t\nrouter ospf\narea {} nssa\nexit\n".format(area))
-def ospf_get_lsa_type5(router_name):
- "Return a dict with link state id as key and forwarding addresses as value"
-
- result = dict()
- tgen = get_topogen()
- router = tgen.gears[router_name]
- cmd = "show ip ospf database external\n"
- output = topotest.normalize_text(router.vtysh_cmd(cmd))
- for line in output.splitlines():
- re0 = re.match(r"\s+Link State ID: (\S+) \(External Network Number\)", line)
- if re0:
- lsa = re0.group(1)
- re1 = re.match(r"\s+Forward Address: (\S+)", line)
- if re1:
- result[lsa] = re1.group(1)
- return result
-
-
-@pytest.fixture(scope="module", name="original")
def test_ospf_set_suppress_fa():
"Test OSPF area [x] nssa suppress-fa"
+ logger.info("Testing Turning on/off suppress-fa")
+ tgen = get_topogen()
+
# Get current forwarding address for each LSA type-5 in r1
- initial = ospf_get_lsa_type5("r1")
+ logger.info("Get Initial State")
+ router = tgen.gears["r1"]
+ json_file = "{}/r1/initial.json".format(CWD)
+ expected_initial = json.loads(open(json_file).read())
+
+ test_func_initial = partial(
+ topotest.router_json_cmp,
+ router,
+ "show ip ospf data external json",
+ expected_initial,
+ )
+ _, result = topotest.run_and_expect(test_func_initial, None, count=30, wait=1)
+ assert result is None, "Unable to get expected initial states"
+ logger.info("Configure suppress-fa")
# Configure suppres-fa in r2 area 1
ospf_configure_suppress_fa("r2", "1")
- topotest.sleep(10, "Waiting for OSPF convergence")
- # Check forwarding address on r1 for all statics is 0.0.0.0
- assertmsg = "Forwarding address is not 0.0.0.0 after enabling OSPF suppress-fa"
- suppress = ospf_get_lsa_type5("r1")
- for prefix in suppress:
- assert suppress[prefix] == "0.0.0.0", assertmsg
+ logger.info("Ensure that OSPF has converged on new values")
+ json_file = "{}/r1/post.json".format(CWD)
+ expected_post = json.loads(open(json_file).read())
- # Return the original forwarding addresses so we can compare them
- # in the test_ospf_unset_supress_fa
- return initial
+ test_func_post = partial(
+ topotest.router_json_cmp,
+ router,
+ "show ip ospf data external json",
+ expected_post,
+ )
+ _, result = topotest.run_and_expect(test_func_post, None, count=30, wait=1)
+ assert result is None, "Unable to get expected state after turning on suppress-fa"
-def test_ospf_unset_supress_fa(original):
- "Test OSPF no area [x] nssa suppress-fa"
+ logger.info("Test OSPF no area [x] nssa suppress-fa")
# Remove suppress-fa in r2 area 1
ospf_unconfigure_suppress_fa("r2", "1")
- topotest.sleep(10, "Waiting for OSPF convergence")
- # Check forwarding address is the original value on r1 for all statics
- assertmsg = "Forwarding address is not correct after removing OSPF suppress-fa"
- restore = ospf_get_lsa_type5("r1")
- for prefix in restore:
- assert restore[prefix] == original[prefix], assertmsg
+ logger.info("Has OSPF returned to original values")
+ _, result = topotest.run_and_expect(test_func_post, None, count=30, wait=1)
+ assert (
+ result is None
+ ), "Unable to return to original state after turning off suppress-fa"
if __name__ == "__main__":