import socket
import ipaddr
+from lib import topotest
+
+from functools import partial
from lib.topolog import logger, logger_config
from lib.topogen import TopoRouter
#############################################
# Verification APIs
#############################################
-def verify_rib(tgen, addr_type, dut, input_dict, next_hop=None, protocol=None):
+def _verify_rib(tgen, addr_type, dut, input_dict, next_hop=None, protocol=None):
"""
Data will be read from input_dict or input JSON file, API will generate
same prefixes, which were redistributed by either create_static_routes() or
return True
+def verify_rib(tgen, addr_type, dut, input_dict, next_hop=None, protocol=None):
+ "Wrapper function for `_verify_rib` that tries multiple time to get results."
+
+ # Use currying to hide the parameters and create a test function.
+ test_func = partial(_verify_rib, tgen, addr_type, dut, input_dict, next_hop, protocol)
+
+ # Call the test function and expect it to return True, otherwise try it again.
+ _, result = topotest.run_and_expect(test_func, True, count=20, wait=6)
+
+ # Return as normal.
+ return result
+
+
def verify_admin_distance_for_static_routes(tgen, input_dict):
"""
API to verify admin distance for static routes as defined in input_dict/