diff --git a/tests/topotests/ospf6_topo2/r2/ospf6d.conf b/tests/topotests/ospf6_topo2/r2/ospf6d.conf index d4bb0e2a41..e88e965c78 100644 --- a/tests/topotests/ospf6_topo2/r2/ospf6d.conf +++ b/tests/topotests/ospf6_topo2/r2/ospf6d.conf @@ -6,12 +6,18 @@ interface r2-eth1 ipv6 ospf6 hello-interval 2 ipv6 ospf6 dead-interval 10 ! +interface r2-eth2 + ipv6 ospf6 hello-interval 2 + ipv6 ospf6 dead-interval 10 +! router ospf6 ospf6 router-id 10.254.254.2 redistribute connected redistribute static default-information originate always metric 123 area 0.0.0.1 stub + area 0.0.0.2 nssa interface r2-eth0 area 0.0.0.1 interface r2-eth1 area 0.0.0.0 + interface r2-eth2 area 0.0.0.2 ! diff --git a/tests/topotests/ospf6_topo2/r2/zebra.conf b/tests/topotests/ospf6_topo2/r2/zebra.conf index 891945a4e7..559f502b0c 100644 --- a/tests/topotests/ospf6_topo2/r2/zebra.conf +++ b/tests/topotests/ospf6_topo2/r2/zebra.conf @@ -6,3 +6,6 @@ interface r2-eth0 interface r2-eth1 ipv6 address 2001:db8:2::2/64 ! +interface r2-eth2 + ipv6 address 2001:db8:3::1/64 +! diff --git a/tests/topotests/ospf6_topo2/r4/ospf6d.conf b/tests/topotests/ospf6_topo2/r4/ospf6d.conf new file mode 100644 index 0000000000..813c0abff2 --- /dev/null +++ b/tests/topotests/ospf6_topo2/r4/ospf6d.conf @@ -0,0 +1,9 @@ +interface r4-eth0 + ipv6 ospf6 hello-interval 2 + ipv6 ospf6 dead-interval 10 +! +router ospf6 + ospf6 router-id 10.254.254.4 + area 0.0.0.2 nssa + interface r4-eth0 area 0.0.0.2 +! diff --git a/tests/topotests/ospf6_topo2/r4/zebra.conf b/tests/topotests/ospf6_topo2/r4/zebra.conf new file mode 100644 index 0000000000..86cb972a9f --- /dev/null +++ b/tests/topotests/ospf6_topo2/r4/zebra.conf @@ -0,0 +1,5 @@ +ipv6 forwarding +! +interface r4-eth0 + ipv6 address 2001:db8:3::2/64 +! diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.dot b/tests/topotests/ospf6_topo2/test_ospf6_topo2.dot index ba7a36f2b5..238ec7a5a0 100644 --- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.dot +++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.dot @@ -34,6 +34,12 @@ graph template { fillcolor="#f08080", style=filled, ]; + r4 [ + shape=doubleoctagon + label="r4", + fillcolor="#f08080", + style=filled, + ]; # Switches sw1 [ @@ -62,10 +68,16 @@ graph template { } subgraph cluster1 { + label="area 0.0.0.2"; + r4 -- sw3 [label="eth0\n.2"]; + } + + subgraph cluster2 { label="area 0.0.0.0"; r2 -- sw1 [label="eth0\n.1"]; r2 -- sw2 [label="eth1\n.2"]; + r2 -- sw3 [label="eth2\n.1"]; + r3 -- sw2 [label="eth0\n.1"]; - r3 -- sw3 [label="eth1\n.2"]; } } diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.png b/tests/topotests/ospf6_topo2/test_ospf6_topo2.png index ee1de60736..4e79559a60 100644 Binary files a/tests/topotests/ospf6_topo2/test_ospf6_topo2.png and b/tests/topotests/ospf6_topo2/test_ospf6_topo2.png differ diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py index efc8565bb3..8289292632 100644 --- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py +++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py @@ -54,8 +54,8 @@ class OSPFv3Topo2(Topo): "Build function" tgen = get_topogen(self) - # Create 3 routers - for routern in range(1, 4): + # Create 4 routers + for routern in range(1, 5): tgen.add_router("r{}".format(routern)) switch = tgen.add_switch("s1") @@ -66,6 +66,10 @@ class OSPFv3Topo2(Topo): switch.add_link(tgen.gears["r2"]) switch.add_link(tgen.gears["r3"]) + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r4"]) + def setup_module(mod): "Sets up the pytest environment" @@ -110,7 +114,52 @@ def test_wait_protocol_convergence(): expect_neighbor_full("r1", "10.254.254.2") expect_neighbor_full("r2", "10.254.254.1") expect_neighbor_full("r2", "10.254.254.3") + expect_neighbor_full("r2", "10.254.254.4") expect_neighbor_full("r3", "10.254.254.2") + expect_neighbor_full("r4", "10.254.254.2") + + +def test_ospfv3_expected_route_types(): + "Test routers route type to determine if NSSA/Stub is working as expected." + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info("waiting for protocols to converge") + + def expect_ospf6_route_types(router, expected_summary): + "Expect the correct route types." + logger.info("waiting OSPFv3 router '{}'".format(router)) + test_func = partial( + topotest.router_json_cmp, + tgen.gears[router], + "show ipv6 ospf6 route summary json", + expected_summary, + ) + _, result = topotest.run_and_expect(test_func, None, count=10, wait=1) + assertmsg = '"{}" convergence failure'.format(router) + assert result is None, assertmsg + + # Stub router: no external routes. + expect_ospf6_route_types( + "r1", + { + "numberOfIntraAreaRoutes": 1, + "numberOfInterAreaRoutes": 3, + "numberOfExternal1Routes": 0, + "numberOfExternal2Routes": 0, + }, + ) + # NSSA router: no external routes. + expect_ospf6_route_types( + "r4", + { + "numberOfIntraAreaRoutes": 1, + "numberOfInterAreaRoutes": 2, + "numberOfExternal1Routes": 0, + "numberOfExternal2Routes": 0, + }, + ) def test_ospf6_default_route():