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>
This commit is contained in:
Louis Scalbert 2024-08-30 14:41:08 +02:00
parent 7028e39986
commit 7f587c9c9d
3 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"attr":{
"entriesCount":0
}
}

View File

@ -0,0 +1,9 @@
{
"table":[
{
"type":"dynamic",
"prefix":"5.5.5.0/24",
"via":"176.16.1.5"
}
]
}

View File

@ -363,6 +363,33 @@ def test_redundancy_shortcut():
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name) assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg 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(): def test_redundancy_shortcut_backup():
""" """
@ -449,6 +476,19 @@ def test_redundancy_shortcut_backup():
output = nhc1.vtysh_cmd("show ip route nhrp") output = nhc1.vtysh_cmd("show ip route nhrp")
logger.info(output) 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 # Now verify shortcut is purged with lack of traffic
json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, nhc1.name) json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found" assertmsg = "No nhrp_route file found"
@ -466,6 +506,19 @@ def test_redundancy_shortcut_backup():
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name) assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg 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(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."