]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: test_ospf_p2mp.py - check for full adjacencies and basic DB info
authorLou Berger <lberger@labn.net>
Fri, 21 Oct 2022 16:44:45 +0000 (16:44 +0000)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Thu, 27 Oct 2022 03:47:33 +0000 (03:47 +0000)
Signed-off-by: Lou Berger <lberger@labn.net>
(cherry picked from commit 675ba67d89b1bc3fc2364ff2aabc50392456d1d0)

tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py

index 3b84a99cdfe13fd4fe0286cc8fa6f75671bf67ae..e131fba0c350cb9017b5fedfbd28538d758ce1d7 100644 (file)
@@ -47,10 +47,12 @@ from lib.common_config import (
     step,
     create_interfaces_cfg,
     topo_daemons,
+    retry,
+    run_frr_cmd,
 )
 from lib.topolog import logger
 from lib.topojson import build_config_from_json
-from lib.topotest import frr_unicode
+from lib.topotest import frr_unicode, json_cmp
 
 from lib.ospf import (
     verify_ospf_interface,
@@ -378,6 +380,158 @@ def test_ospf_p2mp_tc1_p0(request):
     write_test_footer(tc_name)
 
 
+@retry(retry_timeout=30)
+def verify_ospf_json(tgen, dut, input_dict, cmd="show ip ospf database json"):
+    del tgen
+    show_ospf_json = run_frr_cmd(dut, cmd, isjson=True)
+    if not bool(show_ospf_json):
+        return "ospf is not running"
+    result = json_cmp(show_ospf_json, input_dict)
+    return str(result) if result else None
+
+
+@pytest.mark.parametrize("tgen", [2], indirect=True)
+def test_ospf_nbrs(tgen):
+    db_full = {
+        "areas": {
+            "0.0.0.0": {
+                "routerLinkStates": [
+                    {
+                        "lsId": "100.1.1.0",
+                        "advertisedRouter": "100.1.1.0",
+                        "numOfRouterLinks": 6,
+                    },
+                    {
+                        "lsId": "100.1.1.1",
+                        "advertisedRouter": "100.1.1.1",
+                        "numOfRouterLinks": 6,
+                    },
+                    {
+                        "lsId": "100.1.1.2",
+                        "advertisedRouter": "100.1.1.2",
+                        "numOfRouterLinks": 6,
+                    },
+                    {
+                        "lsId": "100.1.1.3",
+                        "advertisedRouter": "100.1.1.3",
+                        "numOfRouterLinks": 7,
+                    },
+                ]
+            }
+        }
+    }
+    input = [
+        [
+            "r0",
+            "show ip ospf n json",
+            {
+                "neighbors": {
+                    "100.1.1.1": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.2": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.3": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                }
+            },
+        ],
+        [
+            "r1",
+            "show ip ospf n json",
+            {
+                "neighbors": {
+                    "100.1.1.0": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.2": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.3": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                }
+            },
+        ],
+        [
+            "r2",
+            "show ip ospf n json",
+            {
+                "neighbors": {
+                    "100.1.1.0": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.1": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.3": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                }
+            },
+        ],
+        [
+            "r3",
+            "show ip ospf n json",
+            {
+                "neighbors": {
+                    "100.1.1.0": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.1": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                    "100.1.1.2": [
+                        {
+                            "state": "Full/DROther",
+                        }
+                    ],
+                }
+            },
+        ],
+        ["r0", "show ip ospf database json", db_full],
+        ["r1", "show ip ospf database json", db_full],
+        ["r2", "show ip ospf database json", db_full],
+        ["r3", "show ip ospf database json", db_full],
+        ["r0", "show ip ospf database json", db_full],
+        ["r0", "show ip ospf database router json", {}],
+        ["r0", "show ip ospf interface traffic json", {}],
+        ["r1", "show ip ospf interface traffic json", {}],
+        ["r2", "show ip ospf interface traffic json", {}],
+        ["r3", "show ip ospf interface traffic json", {}],
+    ]
+    for cmd_set in input:
+        step("test_ospf: %s - %s" % (cmd_set[0], cmd_set[1]))
+        assert (
+            verify_ospf_json(tgen, tgen.gears[cmd_set[0]], cmd_set[2], cmd_set[1])
+            is None
+        )
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))