input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
logger.info("Verifying %s routes on r3", addr_type)
+
+ # Only test the count of nexthops; the actual nexthop addresses
+ # can vary and are not deterministic.
+ #
result = verify_rib(
tgen,
addr_type,
input_dict_1,
next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
protocol=protocol,
+ count_only=True
)
+
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result
)
input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
logger.info("Verifying %s routes on r3", addr_type)
+
+ # Test only the count of nexthops, not the specific nexthop addresses -
+ # they're not deterministic
+ #
result = verify_rib(
tgen,
addr_type,
input_dict_1,
next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
protocol=protocol,
+ count_only=True
)
+
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result
)
tag=None,
metric=None,
fib=None,
+ count_only=False
):
"""
Data will be read from input_dict or input JSON file, API will generate
* `next_hop`[optional]: next_hop which needs to be verified,
default: static
* `protocol`[optional]: protocol, default = None
+ * `count_only`[optional]: count of nexthops only, not specific addresses,
+ default = False
Usage
-----
for rib_r in rib_routes_json[st_rt][0]["nexthops"]
]
- if found_hops:
+ # Check only the count of nexthops
+ if count_only:
+ if len(next_hop) == len(found_hops):
+ nh_found = True
+ else:
+ errormsg = (
+ "Nexthops are missing for "
+ "route {} in RIB of router {}: "
+ "expected {}, found {}\n".format(
+ st_rt, dut, len(next_hop),
+ len(found_hops)
+ )
+ )
+ return errormsg
+
+ # Check the actual nexthops
+ elif found_hops:
missing_list_of_nexthops = set(
found_hops
).difference(next_hop)