summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2024-08-30 14:41:08 +0200
committerLouis Scalbert <louis.scalbert@6wind.com>2024-08-30 16:24:57 +0200
commit7f587c9c9d0291bae775cc0c3e2c8c7f8267407c (patch)
tree4b923c5b9219d6a0dcfa5c5f9ba076da59a8ac6c
parent7028e399865bf1f21c286e2c11c3c90e9b0e3fe3 (diff)
tests: check show ip nhrp shorcut in nhrp_redundancy
Check show ip nhrp shorcut in nhrp_redundancy Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json5
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json9
-rw-r--r--tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py53
3 files changed, 67 insertions, 0 deletions
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
index 0000000000..78563cb902
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json
@@ -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
index 0000000000..40a7086b1c
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json
@@ -0,0 +1,9 @@
+{
+ "table":[
+ {
+ "type":"dynamic",
+ "prefix":"5.5.5.0/24",
+ "via":"176.16.1.5"
+ }
+ ]
+}
diff --git a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
index 7026674014..9b4933e43d 100644
--- a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
+++ b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
@@ -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."