Merge pull request #4964 from ashish12pant/ecmp_tests

tests: Fix bgp-ecmp-topo2
This commit is contained in:
Martin Winter 2019-10-04 21:02:27 +02:00 committed by GitHub
commit 7310aae9ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 414 additions and 140 deletions

View File

@ -564,6 +564,16 @@
"ipv6": "auto"
}
},
"route_maps": {
"rmap_global": [{
"action": "permit",
"set": {
"ipv6": {
"nexthop": "prefer-global"
}
}
}]
},
"bgp": {
"local_as": "300",
"address_family": {
@ -620,38 +630,198 @@
"neighbor": {
"r2": {
"dest_link": {
"r3-link1": {},
"r3-link2": {},
"r3-link3": {},
"r3-link4": {},
"r3-link5": {},
"r3-link6": {},
"r3-link7": {},
"r3-link8": {},
"r3-link9": {},
"r3-link10": {},
"r3-link11": {},
"r3-link12": {},
"r3-link13": {},
"r3-link14": {},
"r3-link15": {},
"r3-link16": {},
"r3-link17": {},
"r3-link18": {},
"r3-link19": {},
"r3-link20": {},
"r3-link21": {},
"r3-link22": {},
"r3-link23": {},
"r3-link24": {},
"r3-link25": {},
"r3-link26": {},
"r3-link27": {},
"r3-link28": {},
"r3-link29": {},
"r3-link30": {},
"r3-link31": {},
"r3-link32": {}
"r3-link1": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link2": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link3": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link4": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link5": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link6": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link7": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link8": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link9": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link10": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link11": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link12": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link13": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link14": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link15": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link16": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link17": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link18": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link19": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link20": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link21": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link22": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link23": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link24": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link25": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link26": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link27": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link28": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link29": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link30": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link31": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link32": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
}
}
}
}

View File

@ -574,6 +574,16 @@
"ipv6": "auto"
}
},
"route_maps": {
"rmap_global": [{
"action": "permit",
"set": {
"ipv6": {
"nexthop": "prefer-global"
}
}
}]
},
"bgp": {
"local_as": "100",
"address_family": {
@ -630,38 +640,198 @@
"neighbor": {
"r2": {
"dest_link": {
"r3-link1": {},
"r3-link2": {},
"r3-link3": {},
"r3-link4": {},
"r3-link5": {},
"r3-link6": {},
"r3-link7": {},
"r3-link8": {},
"r3-link9": {},
"r3-link10": {},
"r3-link11": {},
"r3-link12": {},
"r3-link13": {},
"r3-link14": {},
"r3-link15": {},
"r3-link16": {},
"r3-link17": {},
"r3-link18": {},
"r3-link19": {},
"r3-link20": {},
"r3-link21": {},
"r3-link22": {},
"r3-link23": {},
"r3-link24": {},
"r3-link25": {},
"r3-link26": {},
"r3-link27": {},
"r3-link28": {},
"r3-link29": {},
"r3-link30": {},
"r3-link31": {},
"r3-link32": {}
"r3-link1": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link2": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link3": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link4": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link5": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link6": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link7": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link8": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link9": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link10": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link11": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link12": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link13": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link14": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link15": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link16": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link17": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link18": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link19": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link20": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link21": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link22": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link23": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link24": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link25": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link26": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link27": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link28": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link29": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link30": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link31": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
},
"r3-link32": {
"route_maps": [{
"name": "rmap_global",
"direction": "in"
}]
}
}
}
}

View File

@ -445,10 +445,10 @@ def __create_bgp_unicast_address_family(topo, input_dict, router, addr_type,
bgp_data = input_dict[router]["bgp"]["address_family"]
neigh_data = bgp_data[addr_type]["unicast"]["neighbor"]
for name, peer_dict in deepcopy(neigh_data).iteritems():
for peer_name, peer_dict in deepcopy(neigh_data).iteritems():
for dest_link, peer in peer_dict["dest_link"].iteritems():
deactivate = None
nh_details = topo[name]
nh_details = topo[peer_name]
# Loopback interface
if "source_link" in peer and peer["source_link"] == "lo":
for destRouterLink, data in sorted(nh_details["links"].

View File

@ -35,11 +35,7 @@ import ConfigParser
import traceback
import socket
import ipaddr
import re
from lib import topotest
from functools import partial
from lib.topolog import logger, logger_config
from lib.topogen import TopoRouter
from lib.topotest import interface_set_status
@ -736,62 +732,6 @@ def retry(attempts=3, wait=2, return_is_str=True, initial_wait=0):
return _retry
def disable_v6_link_local(tgen, router, intf_name=None):
"""
Disables ipv6 link local addresses for a particular interface or
all interfaces
* `tgen`: tgen onject
* `router` : router for which hightest interface should be
calculated
* `intf_name` : Interface name for which v6 link local needs to
be disabled
"""
router_list = tgen.routers()
for rname, rnode in router_list.iteritems():
if rname != router:
continue
linklocal = []
ifaces = router_list[router].run('ip -6 address')
# Fix newlines (make them all the same)
ifaces = ('\n'.join(ifaces.splitlines()) + '\n').splitlines()
interface = None
ll_per_if_count = 0
for line in ifaces:
# Interface name
m = re.search('[0-9]+: ([^:]+)[@if0-9:]+ <', line)
if m:
interface = m.group(1).split("@")[0]
ll_per_if_count = 0
# Interface ip
m = re.search('inet6 (fe80::[0-9a-f]+:[0-9a-f]+:[0-9a-f]+'
':[0-9a-f]+[/0-9]*) scope link', line)
if m:
local = m.group(1)
ll_per_if_count += 1
if ll_per_if_count > 1:
linklocal += [["%s-%s" % (interface, ll_per_if_count), local]]
else:
linklocal += [[interface, local]]
if len(linklocal[0]) > 1:
link_local_dict = {item[0]: item[1] for item in linklocal}
for lname, laddr in link_local_dict.items():
if intf_name is not None and lname != intf_name:
continue
cmd = "ip addr del {} dev {}".format(laddr, lname)
router_list[router].run(cmd)
#############################################
# These APIs, will used by testcase
#############################################
@ -821,8 +761,6 @@ def create_interfaces_cfg(tgen, topo, build=False):
interface_name = destRouterLink
else:
interface_name = data["interface"]
if "ipv6" in data:
disable_v6_link_local(tgen, c_router, interface_name)
interface_data.append("interface {}".format(
str(interface_name)
))
@ -1302,13 +1240,15 @@ def create_route_maps(tgen, input_dict, build=False):
# Weight
if weight:
rmap_data.append("set weight {} \n".format(
rmap_data.append("set weight {}".format(
weight))
if ipv6_data:
nexthop = ipv6_data.setdefault("nexthop",None)
nexthop = ipv6_data.setdefault("nexthop", None)
if nexthop:
rmap_data.append("set ipv6 next-hop \
{}".format(nexthop))
rmap_data.append("set ipv6 next-hop {}".format(
nexthop
))
# Adding MATCH and SET sequence to RMAP if defined
if "match" in rmap_dict:
match_data = rmap_dict["match"]
@ -1569,19 +1509,13 @@ def shutdown_bringup_interface(tgen, dut, intf_name, ifaceaction=False):
errormsg(str) or True
"""
from topotest import interface_set_status
router_list = tgen.routers()
if ifaceaction:
logger.info("Bringing up interface : {}".format(intf_name))
else:
logger.info("Shutting down interface : {}".format(intf_name))
interface_set_status(router_list[dut], intf_name,
ifaceaction)
if ifaceaction:
# Disabling v6 link local once interfac comes up back
disable_v6_link_local(tgen, dut, intf_name=intf_name)
interface_set_status(router_list[dut], intf_name, ifaceaction)
#############################################

View File

@ -1,6 +1,6 @@
# Skip pytests example directory
[pytest]
norecursedirs = .git example-test example-topojson-test lib docker bgp-ecmp-topo2 bgp_rr_ibgp
norecursedirs = .git example-test example-topojson-test lib docker bgp_rr_ibgp
[topogen]
# Default configuration values