summaryrefslogtreecommitdiff
path: root/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2021-10-05 21:25:55 -0300
committerRenato Westphal <renato@opensourcerouting.org>2021-10-05 21:25:55 -0300
commit343e16cec54cc8c6e5df389e3a20efd98e450ff1 (patch)
tree4ee6c027b72b4097e6208c018b2739d8a116d372 /tests/topotests/ospf6_topo2/test_ospf6_topo2.py
parentcb81dd25e5538928c5c866a02ca3bad5dee84527 (diff)
tests: extend topotest to test NSSA ranges
Test NSSA address ranges, including the "cost" and "not-advertise" options. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'tests/topotests/ospf6_topo2/test_ospf6_topo2.py')
-rw-r--r--tests/topotests/ospf6_topo2/test_ospf6_topo2.py100
1 files changed, 99 insertions, 1 deletions
diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
index 303bcd014d..eb8561c404 100644
--- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
+++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
@@ -131,6 +131,8 @@ def build_topo(tgen):
switch.add_link(tgen.gears["r2"])
switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
def setup_module(mod):
"Sets up the pytest environment"
@@ -484,7 +486,7 @@ def test_area_filters():
pytest.skip(tgen.errors)
#
- # Configure import/export filters on r2 (ABR for area 1).
+ # Configure import/export filters on r2 (ABR for area 2).
#
config = """
configure terminal
@@ -544,6 +546,102 @@ def test_area_filters():
expect_ospfv3_routes("r1", routes, wait=30, type="inter-area")
+def test_nssa_range():
+ """
+ Test NSSA ABR ranges.
+ """
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ # Configure new addresses on r4 and enable redistribution of connected
+ # routes.
+ config = """
+ configure terminal
+ interface r4-stubnet
+ ipv6 address 2001:db8:1000::1/128
+ ipv6 address 2001:db8:1000::2/128
+ router ospf6
+ redistribute connected
+ """
+ tgen.gears["r4"].vtysh_cmd(config)
+ logger.info("Expecting NSSA-translated external routes to be added on r3")
+ routes = {"2001:db8:1000::1/128": {}, "2001:db8:1000::2/128": {}}
+ expect_ospfv3_routes("r3", routes, wait=30, type="external-2")
+
+ # Configure an NSSA range on r2 (ABR for area 2).
+ config = """
+ configure terminal
+ router ospf6
+ area 2 nssa range 2001:db8:1000::/64
+ """
+ tgen.gears["r2"].vtysh_cmd(config)
+ logger.info("Expecting summarized routes to be removed from r3")
+ for route in ["2001:db8:1000::1/128", "2001:db8:1000::2/128"]:
+ test_func = partial(dont_expect_route, "r3", route, type="external-2")
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = "{}'s {} summarized route still exists".format("r3", route)
+ assert result is None, assertmsg
+ logger.info("Expecting NSSA range to be added on r3")
+ routes = {
+ "2001:db8:1000::/64": {
+ "metricType":2,
+ "metricCost":20,
+ "metricCostE2":10,
+ }}
+ expect_ospfv3_routes("r3", routes, wait=30, type="external-2", detail=True)
+
+ # Change the NSSA range cost.
+ config = """
+ configure terminal
+ router ospf6
+ area 2 nssa range 2001:db8:1000::/64 cost 1000
+ """
+ tgen.gears["r2"].vtysh_cmd(config)
+ logger.info("Expecting NSSA range to be updated with new cost")
+ routes = {
+ "2001:db8:1000::/64": {
+ "metricType":2,
+ "metricCost":20,
+ "metricCostE2":1000,
+ }}
+ expect_ospfv3_routes("r3", routes, wait=30, type="external-2", detail=True)
+
+ # Configure the NSSA range to not be advertised.
+ config = """
+ configure terminal
+ router ospf6
+ area 2 nssa range 2001:db8:1000::/64 not-advertise
+ """
+ tgen.gears["r2"].vtysh_cmd(config)
+ logger.info("Expecting NSSA summary route to be removed")
+ route = "2001:db8:1000::/64"
+ test_func = partial(dont_expect_route, "r3", route, type="external-2")
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = "{}'s {} NSSA summary route still exists".format("r3", route)
+ assert result is None, assertmsg
+
+ # Remove the NSSA range.
+ config = """
+ configure terminal
+ router ospf6
+ no area 2 nssa range 2001:db8:1000::/64
+ """
+ tgen.gears["r2"].vtysh_cmd(config)
+ logger.info("Expecting previously summarized routes to be re-added")
+ routes = {
+ "2001:db8:1000::1/128": {
+ "metricType":2,
+ "metricCost":20,
+ },
+ "2001:db8:1000::2/128": {
+ "metricType":2,
+ "metricCost":20,
+ },
+ }
+ expect_ospfv3_routes("r3", routes, wait=30, type="external-2", detail=True)
+
+
def teardown_module(_mod):
"Teardown the pytest environment"
tgen = get_topogen()