Skip to content

Commit

Permalink
tests: check show ip nhrp shorcut in nhrp_redundancy
Browse files Browse the repository at this point in the history
Check show ip nhrp shorcut in nhrp_redundancy

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Aug 30, 2024
1 parent 7028e39 commit 7f587c9
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"attr":{
"entriesCount":0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"table":[
{
"type":"dynamic",
"prefix":"5.5.5.0/24",
"via":"176.16.1.5"
}
]
}
53 changes: 53 additions & 0 deletions tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down Expand Up @@ -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"
Expand All @@ -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."
Expand Down

0 comments on commit 7f587c9

Please sign in to comment.