]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: check if OSPF opaque attributes are installed in the RIB
authorRenato Westphal <renato@opensourcerouting.org>
Tue, 21 Sep 2021 02:23:47 +0000 (23:23 -0300)
committerDavid Lamparter <equinox@opensourcerouting.org>
Sat, 15 Jan 2022 16:22:27 +0000 (17:22 +0100)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
tests/topotests/zebra_opaque/r3/ospf6d.conf [new file with mode: 0644]
tests/topotests/zebra_opaque/r3/ospfd.conf [new file with mode: 0644]
tests/topotests/zebra_opaque/r3/zebra.conf [new file with mode: 0644]
tests/topotests/zebra_opaque/r4/ospf6d.conf [new file with mode: 0644]
tests/topotests/zebra_opaque/r4/ospfd.conf [new file with mode: 0644]
tests/topotests/zebra_opaque/r4/zebra.conf [new file with mode: 0644]
tests/topotests/zebra_opaque/test_zebra_opaque.py

diff --git a/tests/topotests/zebra_opaque/r3/ospf6d.conf b/tests/topotests/zebra_opaque/r3/ospf6d.conf
new file mode 100644 (file)
index 0000000..bf3d18c
--- /dev/null
@@ -0,0 +1,8 @@
+!
+interface r3-eth0
+ ipv6 ospf6 area 0
+ ipv6 ospf6 hello-interval 2
+ ipv6 ospf6 dead-interval 10
+!
+router ospf6
+!
diff --git a/tests/topotests/zebra_opaque/r3/ospfd.conf b/tests/topotests/zebra_opaque/r3/ospfd.conf
new file mode 100644 (file)
index 0000000..fdc7a97
--- /dev/null
@@ -0,0 +1,8 @@
+!
+interface r3-eth0
+ ip ospf area 0
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
+router ospf
+!
diff --git a/tests/topotests/zebra_opaque/r3/zebra.conf b/tests/topotests/zebra_opaque/r3/zebra.conf
new file mode 100644 (file)
index 0000000..744f2f1
--- /dev/null
@@ -0,0 +1,5 @@
+!
+int r3-eth0
+ ip address 192.168.1.1/24
+ ipv6 address 2001:db8:1::1/64
+!
diff --git a/tests/topotests/zebra_opaque/r4/ospf6d.conf b/tests/topotests/zebra_opaque/r4/ospf6d.conf
new file mode 100644 (file)
index 0000000..3b6846f
--- /dev/null
@@ -0,0 +1,8 @@
+!
+interface r4-eth0
+ ipv6 ospf6 area 0
+ ipv6 ospf6 hello-interval 2
+ ipv6 ospf6 dead-interval 10
+!
+router ospf6
+!
diff --git a/tests/topotests/zebra_opaque/r4/ospfd.conf b/tests/topotests/zebra_opaque/r4/ospfd.conf
new file mode 100644 (file)
index 0000000..6e08bee
--- /dev/null
@@ -0,0 +1,8 @@
+!
+interface r4-eth0
+ ip ospf area 0
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
+router ospf
+!
diff --git a/tests/topotests/zebra_opaque/r4/zebra.conf b/tests/topotests/zebra_opaque/r4/zebra.conf
new file mode 100644 (file)
index 0000000..5916f5f
--- /dev/null
@@ -0,0 +1,5 @@
+!
+int r4-eth0
+ ip address 192.168.1.2/24
+ ipv6 address 2001:db8:1::2/64
+!
index 2983df3ed671ba6f48bf7bdc641825e30862d66a..202e28a178fa626595c7c82c31e64aa710a6e3fc 100644 (file)
@@ -35,11 +35,11 @@ sys.path.append(os.path.join(CWD, "../"))
 from lib import topotest
 from lib.topogen import Topogen, TopoRouter, get_topogen
 
-pytestmark = [pytest.mark.bgpd]
+pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd, pytest.mark.ospf6d]
 
 
 def setup_module(mod):
-    topodef = {"s1": ("r1", "r2")}
+    topodef = {"s1": ("r1", "r2"), "s2": ("r3", "r4")}
     tgen = Topogen(topodef, mod.__name__)
     tgen.start_topology()
 
@@ -52,6 +52,12 @@ def setup_module(mod):
         router.load_config(
             TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
         )
+        router.load_config(
+            TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname))
+        )
+        router.load_config(
+            TopoRouter.RD_OSPF6, os.path.join(CWD, "{}/ospf6d.conf".format(rname))
+        )
 
     tgen.start_router()
 
@@ -67,8 +73,6 @@ def test_zebra_opaque():
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
-    router = tgen.gears["r1"]
-
     def _bgp_converge(router):
         output = json.loads(router.vtysh_cmd("show ip route 192.168.1.0/24 json"))
         expected = {
@@ -81,11 +85,45 @@ def test_zebra_opaque():
         }
         return topotest.json_cmp(output, expected)
 
+    def _ospf_converge(router):
+        output = json.loads(router.vtysh_cmd("show ip route 192.168.1.0/24 json"))
+        expected = {
+            "192.168.1.0/24": [
+                {
+                    "ospfPathType": "Intra-Area",
+                    "ospfAreaId": "0.0.0.0",
+                }
+            ]
+        }
+        return topotest.json_cmp(output, expected)
+
+    def _ospf6_converge(router):
+        output = json.loads(router.vtysh_cmd("show ipv6 route 2001:db8:1::/64 json"))
+        expected = {
+            "2001:db8:1::/64": [
+                {
+                    "ospfPathType": "Intra-Area",
+                    "ospfAreaId": "0.0.0.0",
+                }
+            ]
+        }
+        return topotest.json_cmp(output, expected)
+
+    router = tgen.gears["r1"]
     test_func = functools.partial(_bgp_converge, router)
     success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
-
     assert result is None, 'Cannot see BGP community aliases "{}"'.format(router)
 
+    router = tgen.gears["r3"]
+    test_func = functools.partial(_ospf_converge, router)
+    success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert result is None, 'Cannot see OSPFv2 opaque attributes "{}"'.format(router)
+
+    router = tgen.gears["r3"]
+    test_func = functools.partial(_ospf6_converge, router)
+    success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert result is None, 'Cannot see OSPFv3 opaque attributes "{}"'.format(router)
+
 
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]