Merge pull request #4617 from LabNConsulting/working/master/bgp2vrf_imp1

topotests/ bgp_l3vpn_to_bgp_vrf: improvements
This commit is contained in:
Mark Stapp 2019-06-27 09:32:52 -04:00 committed by GitHub
commit eae1601c4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 22 deletions

View File

@ -6,14 +6,19 @@ if ret != False and found != None:
luCommand('ce3', 'vtysh -c "show bgp sum"', luCommand('ce3', 'vtysh -c "show bgp sum"',
'.', 'pass', 'See %s sharp routes' % num) '.', 'pass', 'See %s sharp routes' % num)
if num > 0: if num > 0:
rtrs = ['ce1', 'ce2', 'ce3']
for rtr in rtrs:
luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display','.', 'none', 'BGP routes pre remove')
luCommand(rtr, 'ip route show | cat -n | tail','.', 'none', 'Linux routes pre remove')
wait = 2*num/500 wait = 2*num/500
luCommand('ce1', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num)) luCommand('ce1', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num))
luCommand('ce2', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num)) luCommand('ce2', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num))
rtrs = ['ce1', 'ce2', 'ce3']
for rtr in rtrs: for rtr in rtrs:
luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep -c 10\\.\\*/32','^0$', 'wait', 'BGP routes removed', wait) luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display',' 10 route', 'wait', 'BGP routes removed', wait)
luCommand(rtr, 'vtysh -c "show bgp ipv4 uni"','.', 'none', 'BGP routes post remove')
for rtr in rtrs: for rtr in rtrs:
luCommand(rtr, 'ip route show | grep -c \\^10\\.','^0$', 'wait', 'Linux routes removed', wait) luCommand(rtr, 'ip route show | grep -c \\^10\\.','^0$', 'wait', 'Linux routes removed', wait)
luCommand(rtr, 'ip route show','.', 'none', 'Linux routes post remove')
rtrs = ['r1', 'r3', 'r4'] rtrs = ['r1', 'r3', 'r4']
for rtr in rtrs: for rtr in rtrs:
luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr),'^0$','wait','VRF route removed',wait) luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr),'^0$','wait','VRF route removed',wait)

View File

@ -11,14 +11,17 @@ if c > 0:
else: else:
d = r d = r
wait = 2*num/1000 wait = 2*num/1000
mem = {} mem_z = {}
mem_b = {}
rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4'] rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4']
for rtr in rtrs: for rtr in rtrs:
mem[rtr] = {'value': 0, 'units': 'unknown'} mem_z[rtr] = {'value': 0, 'units': 'unknown'}
ret = luCommand(rtr, 'vtysh -c "show memory"', 'bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats') mem_b[rtr] = {'value': 0, 'units': 'unknown'}
ret = luCommand(rtr, 'vtysh -c "show memory"', 'zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats')
found = luLast() found = luLast()
if ret != False and found != None: if ret != False and found != None:
mem[rtr] = {'value': int(found.group(1)), 'units': found.group(2)} mem_z[rtr] = {'value': int(found.group(1)), 'units': found.group(2)}
mem_b[rtr] = {'value': int(found.group(3)), 'units': found.group(4)}
luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'none','check if sharpd running') luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'none','check if sharpd running')
doSharp = True doSharp = True
@ -54,13 +57,20 @@ if doSharp == True:
luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr), str(num), 'wait','See {} linux routes'.format(num), wait) luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr), str(num), 'wait','See {} linux routes'.format(num), wait)
rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4'] rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4']
for rtr in rtrs: for rtr in rtrs:
ret = luCommand(rtr, 'vtysh -c "show memory"', 'bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats') ret = luCommand(rtr, 'vtysh -c "show memory"', 'zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats')
found = luLast() found = luLast()
if ret != False and found != None: if ret != False and found != None:
val = int(found.group(1)) val_z = int(found.group(1))
if mem[rtr]['units'] != found.group(2): if mem_z[rtr]['units'] != found.group(2):
val *= 1000 val_z *= 1000
delta = val - int(mem[rtr]['value']) delta_z = val_z - int(mem_z[rtr]['value'])
ave = float(delta)/float(num) ave_z = float(delta_z)/float(num)
luCommand(rtr, 'vtysh -c "show thread cpu"', '.', 'pass', 'BGPd heap: {0} {1} --> {2} {3} ({4} {1}/route)'.format(mem[rtr]['value'], mem[rtr]['units'], found.group(1), found.group(2), round(ave,4)))
val_b = int(found.group(3))
if mem_b[rtr]['units'] != found.group(4):
val_b *= 1000
delta_b = val_b - int(mem_b[rtr]['value'])
ave_b = float(delta_b)/float(num)
luCommand(rtr, 'vtysh -c "show thread cpu"', '.', 'pass', 'BGPd heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)'.format(mem_b[rtr]['value'], mem_b[rtr]['units'], found.group(3), found.group(4), round(ave_b,4)))
luCommand(rtr, 'vtysh -c "show thread cpu"', '.', 'pass', 'Zebra heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)'.format(mem_z[rtr]['value'], mem_z[rtr]['units'], found.group(1), found.group(2), round(ave_z,4)))
#done #done

View File

@ -37,7 +37,7 @@ class lUtil:
base_log_dir = '.' base_log_dir = '.'
fout_name = 'output.log' fout_name = 'output.log'
fsum_name = 'summary.txt' fsum_name = 'summary.txt'
l_level = 9 l_level = 6
CallOnFail = False CallOnFail = False
l_total = 0 l_total = 0
@ -53,12 +53,12 @@ class lUtil:
fsum = '' fsum = ''
net = '' net = ''
def log(self, str): def log(self, str, level=6):
if self.l_level > 0: if self.l_level > 0:
if self.fout == '': if self.fout == '':
self.fout = open(self.fout_name, 'w', 0) self.fout = open(self.fout_name, 'w', 0)
self.fout.write(str+'\n') self.fout.write(str+'\n')
if self.l_level > 5: if level <= self.l_level:
print(str) print(str)
def summary(self, str): def summary(self, str):
@ -226,14 +226,16 @@ Total %-4d %-4d %d\n\
ret = success ret = success
else: else:
ret = search.group() ret = search.group()
self.log('found:%s:' % ret)
if op != 'fail': if op != 'fail':
success = True success = True
level = 7
else: else:
success = False success = False
level = 5
self.log('found:%s:' % ret, level)
# Experiment: compare matched strings obtained each way # Experiment: compare matched strings obtained each way
if self.l_dotall_experiment and (group_nl_converted != ret): if self.l_dotall_experiment and (group_nl_converted != ret):
self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret)) self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9)
if op == 'pass' or op == 'fail': if op == 'pass' or op == 'fail':
self.result(target, success, result) self.result(target, success, result)
if js != None: if js != None:
@ -265,7 +267,7 @@ LUtil=None
#entry calls #entry calls
def luStart(baseScriptDir='.', baseLogDir='.', net='', def luStart(baseScriptDir='.', baseLogDir='.', net='',
fout='output.log', fsum='summary.txt', level=9): fout='output.log', fsum='summary.txt', level=None):
global LUtil global LUtil
#init class #init class
LUtil=lUtil() LUtil=lUtil()
@ -276,6 +278,7 @@ def luStart(baseScriptDir='.', baseLogDir='.', net='',
LUtil.fout_name = baseLogDir + '/' + fout LUtil.fout_name = baseLogDir + '/' + fout
if fsum != None: if fsum != None:
LUtil.fsum_name = baseLogDir + '/' + fsum LUtil.fsum_name = baseLogDir + '/' + fsum
if level != None:
LUtil.l_level = level LUtil.l_level = level
LUtil.l_dotall_experiment = False LUtil.l_dotall_experiment = False
LUtil.l_dotall_experiment = True LUtil.l_dotall_experiment = True
@ -289,11 +292,11 @@ def luCommand(target, command, regexp='.', op='none', result='', time=10, return
def luLast(usenl=False): def luLast(usenl=False):
if usenl: if usenl:
if LUtil.l_last_nl != None: if LUtil.l_last_nl != None:
LUtil.log('luLast:%s:' % LUtil.l_last_nl.group()) LUtil.log('luLast:%s:' % LUtil.l_last_nl.group(), 7)
return LUtil.l_last_nl return LUtil.l_last_nl
else: else:
if LUtil.l_last != None: if LUtil.l_last != None:
LUtil.log('luLast:%s:' % LUtil.l_last.group()) LUtil.log('luLast:%s:' % LUtil.l_last.group(), 7)
return LUtil.l_last return LUtil.l_last
def luInclude(filename, CallOnFail=None): def luInclude(filename, CallOnFail=None):