Skip to content

Commit

Permalink
topotests: add tests for OSPFv3 NSSA/Stub
Browse files Browse the repository at this point in the history
New test verification:
 * Stub and NSSA areas contain no external routes

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
  • Loading branch information
KaushikNiral authored and rzalamena committed Jun 4, 2021
1 parent 4f785c0 commit d87586c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tests/topotests/ospf6_topo2/r2/ospf6d.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
!
3 changes: 3 additions & 0 deletions tests/topotests/ospf6_topo2/r2/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
!
9 changes: 9 additions & 0 deletions tests/topotests/ospf6_topo2/r4/ospf6d.conf
Original file line number Diff line number Diff line change
@@ -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
!
5 changes: 5 additions & 0 deletions tests/topotests/ospf6_topo2/r4/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ipv6 forwarding
!
interface r4-eth0
ipv6 address 2001:db8:3::2/64
!
14 changes: 13 additions & 1 deletion tests/topotests/ospf6_topo2/test_ospf6_topo2.dot
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ graph template {
fillcolor="#f08080",
style=filled,
];
r4 [
shape=doubleoctagon
label="r4",
fillcolor="#f08080",
style=filled,
];

# Switches
sw1 [
Expand Down Expand Up @@ -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"];
}
}
Binary file modified tests/topotests/ospf6_topo2/test_ospf6_topo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 51 additions & 2 deletions tests/topotests/ospf6_topo2/test_ospf6_topo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def build(self, *_args, **_opts):
"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")
Expand All @@ -66,6 +66,10 @@ def build(self, *_args, **_opts):
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"
Expand Down Expand Up @@ -110,7 +114,52 @@ def expect_neighbor_full(router, neighbor):
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():
Expand Down

0 comments on commit d87586c

Please sign in to comment.