]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotest: Add test for isis json cmds. 10701/head
authorJavier Garcia <javier.martin.garcia@ibm.com>
Fri, 25 Feb 2022 11:10:54 +0000 (12:10 +0100)
committerJavier Garcia <javier.martin.garcia@ibm.com>
Wed, 2 Mar 2022 15:21:29 +0000 (16:21 +0100)
Signed-off-by: Javier Garcia <javier.martin.garcia@ibm.com>
tests/isisd/test_fuzz_isis_tlv.c
tests/isisd/test_isis_spf.c
tests/topotests/isis_topo1/test_isis_topo1.py

index 97aade6578486b79f2fd66b587fe3b8de707a871..8f0b92d0fcd49b9173639f106217a29381e0f052 100644 (file)
@@ -108,12 +108,12 @@ static int test(FILE *input, FILE *output)
        }
 
        fprintf(output, "Unpack log:\n%s", log);
-       const char *s_tlvs = isis_format_tlvs(tlvs);
+       const char *s_tlvs = isis_format_tlvs(tlvs, NULL);
        fprintf(output, "Unpacked TLVs:\n%s", s_tlvs);
 
        struct isis_item *orig_auth = tlvs->isis_auth.head;
        tlvs->isis_auth.head = NULL;
-       s_tlvs = isis_format_tlvs(tlvs);
+       s_tlvs = isis_format_tlvs(tlvs, NULL);
        struct isis_tlvs *tlv_copy = isis_copy_tlvs(tlvs);
        tlvs->isis_auth.head = orig_auth;
        isis_free_tlvs(tlvs);
@@ -133,7 +133,7 @@ static int test(FILE *input, FILE *output)
        }
 
        char *orig_tlvs = XSTRDUP(MTYPE_TMP, s_tlvs);
-       s_tlvs = isis_format_tlvs(tlvs);
+       s_tlvs = isis_format_tlvs(tlvs, NULL);
 
        if (strcmp(orig_tlvs, s_tlvs)) {
                fprintf(output,
@@ -166,7 +166,7 @@ static int test(FILE *input, FILE *output)
                        fprintf(output, "Could not pack fragment, too large.\n");
                        assert(0);
                }
-               sbuf_push(&fragment_format, 0, "%s", isis_format_tlvs(tlvs));
+               sbuf_push(&fragment_format, 0, "%s", isis_format_tlvs(tlvs, NULL));
                isis_free_tlvs(tlvs);
        }
        list_delete(&fragments);
index a30f33ccade1797d4f347023f1387674747785f1..971aba4c46f54961b2aeac3a512a7d5c4aa70b7b 100644 (file)
@@ -294,7 +294,7 @@ static int test_run(struct vty *vty, const struct isis_topology *topology,
 
                /* Print the LDPDB. */
                if (CHECK_FLAG(flags, F_DISPLAY_LSPDB))
-                       show_isis_database_lspdb(vty, area, level - 1,
+                       show_isis_database_lspdb_vty(vty, area, level - 1,
                                                 &area->lspdb[level - 1], NULL,
                                                 ISIS_UI_LEVEL_DETAIL);
 
index 94c5faf2e0be8b9e8891f326f59ffcd1875ffd6c..014722387f70cf1c2a77e972d708fb24ce3c75fe 100644 (file)
@@ -236,6 +236,94 @@ def test_isis_linux_route6_installation():
         assert topotest.json_cmp(actual, expected) is None, assertmsg
 
 
+def test_isis_summary_json():
+    "Check json struct in show isis summary json"
+
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    logger.info("Checking 'show isis summary json'")
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis summary json", isjson=True)
+        assertmsg = "Test isis summary json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['vrf'] == "default", assertmsg
+        assert json_output['areas'][0]['area'] == "1", assertmsg
+        assert json_output['areas'][0]['levels'][0]['id'] != '3', assertmsg
+
+
+def test_isis_interface_json():
+    "Check json struct in show isis interface json"
+
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    logger.info("Checking 'show isis interface json'")
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis interface json", isjson=True)
+        assertmsg = "Test isis interface json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['areas'][0]['circuits'][0]['interface']['name'] == rname+"-eth0", assertmsg
+
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis interface detail json", isjson=True)
+        assertmsg = "Test isis interface json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['areas'][0]['circuits'][0]['interface']['name'] == rname+"-eth0", assertmsg
+
+
+def test_isis_neighbor_json():
+    "Check json struct in show isis neighbor json"
+
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    #tgen.mininet_cli()
+    logger.info("Checking 'show isis neighbor json'")
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis neighbor json", isjson=True)
+        assertmsg = "Test isis neighbor json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['areas'][0]['circuits'][0]['interface'] == rname+"-eth0", assertmsg
+
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis neighbor detail json", isjson=True)
+        assertmsg = "Test isis neighbor json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['areas'][0]['circuits'][0]['interface']['name'] == rname+"-eth0", assertmsg
+
+
+def test_isis_database_json():
+    "Check json struct in show isis database json"
+
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    #tgen.mininet_cli()
+    logger.info("Checking 'show isis database json'")
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis database json", isjson=True)
+        assertmsg = "Test isis database json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['areas'][0]['area']['name'] == "1", assertmsg
+        assert json_output['areas'][0]['levels'][0]['id'] != '3', assertmsg
+
+    for rname, router in tgen.routers().items():
+        logger.info("Checking router %s", rname)
+        json_output = tgen.gears[rname].vtysh_cmd("show isis database detail json", isjson=True)
+        assertmsg = "Test isis database json failed in '{}' data '{}'".format(rname, json_output)
+        assert json_output['areas'][0]['area']['name'] == "1", assertmsg
+        assert json_output['areas'][0]['levels'][0]['id'] != '3', assertmsg
+
+
 def test_memory_leak():
     "Run the memory leak test and report results."
     tgen = get_topogen()