]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: check show ip nhrp shorcut in nhrp_redundancy
authorLouis Scalbert <louis.scalbert@6wind.com>
Fri, 30 Aug 2024 12:41:08 +0000 (14:41 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 30 Aug 2024 14:24:57 +0000 (16:24 +0200)
Check show ip nhrp shorcut in nhrp_redundancy

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json [new file with mode: 0644]
tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json [new file with mode: 0644]
tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py

diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json
new file mode 100644 (file)
index 0000000..78563cb
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "attr":{
+    "entriesCount":0
+  }
+}
diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json
new file mode 100644 (file)
index 0000000..40a7086
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "table":[
+    {
+      "type":"dynamic",
+      "prefix":"5.5.5.0/24",
+      "via":"176.16.1.5"
+    }
+  ]
+}
index 70266740148bbe6370a96ae36e0c8ba457f9fe36..9b4933e43d587c55e8c982090606bdd126ef5ef5 100644 (file)
@@ -363,6 +363,33 @@ def test_redundancy_shortcut():
     assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
     assert result is None, assertmsg
 
+    json_file = "{}/{}/nhrp_shortcut_present.json".format(CWD, nhc1.name)
+    expected = json.loads(open(json_file).read())
+    test_func = partial(
+        topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+    output = nhc1.vtysh_cmd("show ip nhrp shortcut")
+    logger.info(output)
+
+    assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+    assert result is None, assertmsg
+
+    # check the shortcut disappears because of no traffic
+    json_file = "{}/{}/nhrp_shortcut_absent.json".format(CWD, nhc1.name)
+    expected = json.loads(open(json_file).read())
+    test_func = partial(
+        topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+    output = nhc1.vtysh_cmd("show ip nhrp shortcut")
+    logger.info(output)
+
+    assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+    assert result is None, assertmsg
+
 
 def test_redundancy_shortcut_backup():
     """
@@ -449,6 +476,19 @@ def test_redundancy_shortcut_backup():
     output = nhc1.vtysh_cmd("show ip route nhrp")
     logger.info(output)
 
+    json_file = "{}/{}/nhrp_shortcut_present.json".format(CWD, nhc1.name)
+    expected = json.loads(open(json_file).read())
+    test_func = partial(
+        topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+    output = nhc1.vtysh_cmd("show ip nhrp shortcut")
+    logger.info(output)
+
+    assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+    assert result is None, assertmsg
+
     # Now verify shortcut is purged with lack of traffic
     json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, nhc1.name)
     assertmsg = "No nhrp_route file found"
@@ -466,6 +506,19 @@ def test_redundancy_shortcut_backup():
     assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
     assert result is None, assertmsg
 
+    json_file = "{}/{}/nhrp_shortcut_absent.json".format(CWD, nhc1.name)
+    expected = json.loads(open(json_file).read())
+    test_func = partial(
+        topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+    output = nhc1.vtysh_cmd("show ip nhrp shortcut")
+    logger.info(output)
+
+    assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+    assert result is None, assertmsg
+
 
 def test_memory_leak():
     "Run the memory leak test and report results."