summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/common_check.py
diff options
context:
space:
mode:
authorMark Stapp <mjs.ietf@gmail.com>2024-07-09 13:48:37 -0400
committerGitHub <noreply@github.com>2024-07-09 13:48:37 -0400
commit7d08b297219ee58ece6c6548557075fe6f46a0f6 (patch)
tree4f5cdf1016881b77750a485e660994145dd42c94 /tests/topotests/lib/common_check.py
parent685712df44c4b4da91853db6ca30bf23e388d826 (diff)
parent731f74e35fa2c1636208f4bf64650d2d00a199b4 (diff)
Merge pull request #16342 from pguibert6WIND/duplicate_fib_proposal
Duplicate fib proposal
Diffstat (limited to 'tests/topotests/lib/common_check.py')
-rw-r--r--tests/topotests/lib/common_check.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/topotests/lib/common_check.py b/tests/topotests/lib/common_check.py
index be3241fd20..19f02dbadc 100644
--- a/tests/topotests/lib/common_check.py
+++ b/tests/topotests/lib/common_check.py
@@ -10,11 +10,13 @@ import json
from lib import topotest
-def ip_check_path_selection(router, ipaddr_str, expected, vrf_name=None):
+def ip_check_path_selection(
+ router, ipaddr_str, expected, vrf_name=None, check_fib=False
+):
if vrf_name:
- cmdstr = f'show ip route vrf {vrf_name} {ipaddr_str} json'
+ cmdstr = f"show ip route vrf {vrf_name} {ipaddr_str} json"
else:
- cmdstr = f'show ip route {ipaddr_str} json'
+ cmdstr = f"show ip route {ipaddr_str} json"
try:
output = json.loads(router.vtysh_cmd(cmdstr))
except:
@@ -25,6 +27,21 @@ def ip_check_path_selection(router, ipaddr_str, expected, vrf_name=None):
num_nh_expected = len(expected[ipaddr_str][0]["nexthops"])
num_nh_observed = len(output[ipaddr_str][0]["nexthops"])
if num_nh_expected == num_nh_observed:
+ if check_fib:
+ # special case: when fib flag is unset,
+ # an extra test should be done to check that the flag is really unset
+ for nh_output, nh_expected in zip(
+ output[ipaddr_str][0]["nexthops"],
+ expected[ipaddr_str][0]["nexthops"],
+ ):
+ if (
+ "fib" in nh_output.keys()
+ and nh_output["fib"]
+ and ("fib" not in nh_expected.keys() or not nh_expected["fib"])
+ ):
+ return "{}, prefix {} nexthop {} has the fib flag set, whereas it is not expected".format(
+ router.name, ipaddr_str, nh_output["ip"]
+ )
return ret
return "{}, prefix {} does not have the correct number of nexthops : observed {}, expected {}".format(
router.name, ipaddr_str, num_nh_observed, num_nh_expected
@@ -37,9 +54,9 @@ def iproute2_check_path_selection(router, ipaddr_str, expected, vrf_name=None):
return None
if vrf_name:
- cmdstr = f'ip -json route show vrf {vrf_name} {ipaddr_str}'
+ cmdstr = f"ip -json route show vrf {vrf_name} {ipaddr_str}"
else:
- cmdstr = f'ip -json route show {ipaddr_str}'
+ cmdstr = f"ip -json route show {ipaddr_str}"
try:
output = json.loads(cmdstr)
except: