mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 07:48:07 +00:00
tests: address coverity / styling issues in topotests
Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
This commit is contained in:
parent
cd72ad0133
commit
23f3a92e34
@ -2516,8 +2516,9 @@ def verify_best_path_as_per_admin_distance(
|
|||||||
|
|
||||||
|
|
||||||
@retry(attempts=5, wait=2, return_is_str=True, initial_wait=2)
|
@retry(attempts=5, wait=2, return_is_str=True, initial_wait=2)
|
||||||
def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None,
|
def verify_bgp_rib(
|
||||||
aspath=None, multi_nh=None):
|
tgen, addr_type, dut, input_dict, next_hop=None, aspath=None, multi_nh=None
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
This API is to verify whether bgp rib has any
|
This API is to verify whether bgp rib has any
|
||||||
matching route for a nexthop.
|
matching route for a nexthop.
|
||||||
@ -2663,25 +2664,35 @@ aspath=None, multi_nh=None):
|
|||||||
if not isinstance(next_hop, list):
|
if not isinstance(next_hop, list):
|
||||||
next_hop = [next_hop]
|
next_hop = [next_hop]
|
||||||
list1 = next_hop
|
list1 = next_hop
|
||||||
found_hops = [rib_r["ip"] for rib_r in
|
found_hops = [
|
||||||
rib_routes_json["routes"][
|
rib_r["ip"]
|
||||||
st_rt][0]["nexthops"]]
|
for rib_r in rib_routes_json["routes"][st_rt][0][
|
||||||
|
"nexthops"
|
||||||
|
]
|
||||||
|
]
|
||||||
list2 = found_hops
|
list2 = found_hops
|
||||||
missing_list_of_nexthops = \
|
missing_list_of_nexthops = set(list2).difference(list1)
|
||||||
set(list2).difference(list1)
|
additional_nexthops_in_required_nhs = set(
|
||||||
additional_nexthops_in_required_nhs = \
|
list1
|
||||||
set(list1).difference(list2)
|
).difference(list2)
|
||||||
|
|
||||||
if list2:
|
if list2:
|
||||||
if additional_nexthops_in_required_nhs:
|
if additional_nexthops_in_required_nhs:
|
||||||
logger.info("Missing nexthop %s for route"\
|
logger.info(
|
||||||
" %s in RIB of router %s\n", \
|
"Missing nexthop %s for route"
|
||||||
additional_nexthops_in_required_nhs, \
|
" %s in RIB of router %s\n",
|
||||||
st_rt, dut)
|
|
||||||
errormsg=("Nexthop {} is Missing for "\
|
|
||||||
"route {} in RIB of router {}\n".format(
|
|
||||||
additional_nexthops_in_required_nhs,
|
additional_nexthops_in_required_nhs,
|
||||||
st_rt, dut))
|
st_rt,
|
||||||
|
dut,
|
||||||
|
)
|
||||||
|
errormsg = (
|
||||||
|
"Nexthop {} is Missing for "
|
||||||
|
"route {} in RIB of router {}\n".format(
|
||||||
|
additional_nexthops_in_required_nhs,
|
||||||
|
st_rt,
|
||||||
|
dut,
|
||||||
|
)
|
||||||
|
)
|
||||||
return errormsg
|
return errormsg
|
||||||
else:
|
else:
|
||||||
nh_found = True
|
nh_found = True
|
||||||
@ -3869,6 +3880,7 @@ def verify_attributes_for_evpn_routes(
|
|||||||
return errormsg
|
return errormsg
|
||||||
|
|
||||||
if rt == "auto":
|
if rt == "auto":
|
||||||
|
vni_dict = {}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[DUT: %s]: Verifying auto-rt value for " "evpn route %s:",
|
"[DUT: %s]: Verifying auto-rt value for " "evpn route %s:",
|
||||||
dut,
|
dut,
|
||||||
@ -3876,8 +3888,6 @@ def verify_attributes_for_evpn_routes(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if rt_peer:
|
if rt_peer:
|
||||||
vni_dict = {}
|
|
||||||
|
|
||||||
rnode = tgen.routers()[rt_peer]
|
rnode = tgen.routers()[rt_peer]
|
||||||
show_bgp_json = run_frr_cmd(
|
show_bgp_json = run_frr_cmd(
|
||||||
rnode, "show bgp vrf all summary json", isjson=True
|
rnode, "show bgp vrf all summary json", isjson=True
|
||||||
|
@ -336,16 +336,15 @@ def start_router_daemons(tgen, router, daemons):
|
|||||||
router_list = tgen.routers()
|
router_list = tgen.routers()
|
||||||
|
|
||||||
# Start daemons
|
# Start daemons
|
||||||
result = router_list[router].startDaemons(daemons)
|
res = router_list[router].startDaemons(daemons)
|
||||||
return result
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errormsg = traceback.format_exc()
|
errormsg = traceback.format_exc()
|
||||||
logger.error(errormsg)
|
logger.error(errormsg)
|
||||||
return errormsg
|
res = errormsg
|
||||||
|
|
||||||
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
|
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
|
||||||
return True
|
return res
|
||||||
|
|
||||||
|
|
||||||
def kill_mininet_routers_process(tgen):
|
def kill_mininet_routers_process(tgen):
|
||||||
@ -1376,12 +1375,14 @@ def generate_ips(network, no_of_ips):
|
|||||||
return ipaddress_list
|
return ipaddress_list
|
||||||
start_ip = ipaddress.IPv4Address(unicode(start_ip))
|
start_ip = ipaddress.IPv4Address(unicode(start_ip))
|
||||||
step = 2 ** (32 - mask)
|
step = 2 ** (32 - mask)
|
||||||
if addr_type == "ipv6":
|
elif addr_type == "ipv6":
|
||||||
if start_ip == "0::0" and mask == 0 and no_of_ips == 1:
|
if start_ip == "0::0" and mask == 0 and no_of_ips == 1:
|
||||||
ipaddress_list.append("{}/{}".format(start_ip, mask))
|
ipaddress_list.append("{}/{}".format(start_ip, mask))
|
||||||
return ipaddress_list
|
return ipaddress_list
|
||||||
start_ip = ipaddress.IPv6Address(unicode(start_ip))
|
start_ip = ipaddress.IPv6Address(unicode(start_ip))
|
||||||
step = 2 ** (128 - mask)
|
step = 2 ** (128 - mask)
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
next_ip = start_ip
|
next_ip = start_ip
|
||||||
count = 0
|
count = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user