]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: add tests for OSPFv3 NSSA/Stub
authorKaushik <kaushiknath.null@gmail.com>
Thu, 25 Mar 2021 11:43:15 +0000 (04:43 -0700)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Fri, 4 Jun 2021 10:23:10 +0000 (07:23 -0300)
New test verification:
 * Stub and NSSA areas contain no external routes

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
tests/topotests/ospf6_topo2/r2/ospf6d.conf
tests/topotests/ospf6_topo2/r2/zebra.conf
tests/topotests/ospf6_topo2/r4/ospf6d.conf [new file with mode: 0644]
tests/topotests/ospf6_topo2/r4/zebra.conf [new file with mode: 0644]
tests/topotests/ospf6_topo2/test_ospf6_topo2.dot
tests/topotests/ospf6_topo2/test_ospf6_topo2.png
tests/topotests/ospf6_topo2/test_ospf6_topo2.py

index d4bb0e2a412b7b4ee06107e630ec96e851043e78..e88e965c78333f35cbb80d55273d138e2acb7ad6 100644 (file)
@@ -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
 !
index 891945a4e7eb6e95c62120fd33d4cc07954baa8e..559f502b0c69d7af813eace1663f67e3b02e1580 100644 (file)
@@ -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 (file)
index 0000000..813c0ab
--- /dev/null
@@ -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 (file)
index 0000000..86cb972
--- /dev/null
@@ -0,0 +1,5 @@
+ipv6 forwarding
+!
+interface r4-eth0
+ ipv6 address 2001:db8:3::2/64
+!
index ba7a36f2b558e85c85532a39e9f7a73c61b7f6c4..238ec7a5a0030da96a31a7cb7fd7ec89aff79ecc 100644 (file)
@@ -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"];
   }
 }
index ee1de607368f251e0a653bb965b13c141b3edcd0..4e79559a60f803450775a174c91e8743d43127d3 100644 (file)
Binary files a/tests/topotests/ospf6_topo2/test_ospf6_topo2.png and b/tests/topotests/ospf6_topo2/test_ospf6_topo2.png differ
index efc8565bb3d925ad207e2aaee2c9420a50d23378..828929263253721768c18d5d8e62bfd42b44607f 100644 (file)
@@ -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():