Skip to content

Commit

Permalink
black formating of qa
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed May 8, 2020
1 parent 92dc7b6 commit 4436f16
Show file tree
Hide file tree
Showing 31 changed files with 1,399 additions and 1,283 deletions.
73 changes: 37 additions & 36 deletions qa/self/api/receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,48 @@
import sys

match = {
0: ['neighbor 127.0.0.1 update start',] * 20,
1: \
['neighbor 127.0.0.1 announced route %d%d.0.0.0/8 next-hop 1.1.1.1 origin igp as-path [ 1 2 3 4 ] med 100' %
(number,number) for number in range(1,10)
] \
+ \
['neighbor 127.0.0.1 announced route eor %d/%d (%s)' % (afi,safi,text) for (afi,safi,text) in \
(
(1,1,'ipv4 unicast'),
(1,2,'ipv4 multicast'),
(1,4,'ipv4 nlri-mpls'),
(1,128,'ipv4 mpls-vpn'),
(1,133,'ipv4 flow'),
(1,134,'ipv4 flow-vpn'),
(2,1,'ipv6 unicast'),
(2,128,'ipv6 mpls-vpn'),
(2,133,'ipv6 flow'),
(2,134,'ipv6 flow-vpn'),
(25,65,'l2vpn vpls')
)
],
2: ['neighbor 127.0.0.1 update end',] * 20,
3: ['',] * 20,
0: ['neighbor 127.0.0.1 update start',] * 20,
1: [
'neighbor 127.0.0.1 announced route %d%d.0.0.0/8 next-hop 1.1.1.1 origin igp as-path [ 1 2 3 4 ] med 100'
% (number, number)
for number in range(1, 10)
]
+ [
'neighbor 127.0.0.1 announced route eor %d/%d (%s)' % (afi, safi, text)
for (afi, safi, text) in (
(1, 1, 'ipv4 unicast'),
(1, 2, 'ipv4 multicast'),
(1, 4, 'ipv4 nlri-mpls'),
(1, 128, 'ipv4 mpls-vpn'),
(1, 133, 'ipv4 flow'),
(1, 134, 'ipv4 flow-vpn'),
(2, 1, 'ipv6 unicast'),
(2, 128, 'ipv6 mpls-vpn'),
(2, 133, 'ipv6 flow'),
(2, 134, 'ipv6 flow-vpn'),
(25, 65, 'l2vpn vpls'),
)
],
2: ['neighbor 127.0.0.1 update end',] * 20,
3: ['',] * 20,
}

count = 0

while True:
line = sys.stdin.readline().strip()
#print >> sys.stderr, '[%s]' % line.replace('\n','\\n'), start, end
line = sys.stdin.readline().strip()
# print >> sys.stderr, '[%s]' % line.replace('\n','\\n'), start, end

options = match[count % 4]
options = match[count % 4]

if line in options:
sys.stderr.write('%-3d ok %s\n' % (count,line))
sys.stderr.flush()
count += 1
continue
if line in options:
sys.stderr.write('%-3d ok %s\n' % (count, line))
sys.stderr.flush()
count += 1
continue

sys.stderr.write('%-3d failed %s\n' % (count,line))
# sys.stderr.write("---" + line + "---\n")
# sys.stderr.write("---" + str(options) + "---\n")
sys.stderr.flush()
count += 1
sys.stderr.write('%-3d failed %s\n' % (count, line))
# sys.stderr.write("---" + line + "---\n")
# sys.stderr.write("---" + str(options) + "---\n")
sys.stderr.flush()
count += 1
33 changes: 19 additions & 14 deletions qa/self/attribute/api-internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
import sys
import time

def write (data):
sys.stdout.write(data + '\n')
sys.stdout.flush()

def main ():
msg = 'announce attribute next-hop 1.2.3.4 med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ] nlri %s'
write(msg % ' '.join('%d.0.0.0/8' % ip for ip in range(0,224)))
write(msg % ' '.join('10.%d.0.0/16' % ip for ip in range(0,256)))
def write(data):
sys.stdout.write(data + '\n')
sys.stdout.flush()

time.sleep(2)

write('withdraw attribute next-hop 1.2.3.4 med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ] nlri 0.0.0.0/8 1.0.0.0/8')
def main():
msg = 'announce attribute next-hop 1.2.3.4 med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ] nlri %s'
write(msg % ' '.join('%d.0.0.0/8' % ip for ip in range(0, 224)))
write(msg % ' '.join('10.%d.0.0/16' % ip for ip in range(0, 256)))

time.sleep(2)

write(
'withdraw attribute next-hop 1.2.3.4 med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ] nlri 0.0.0.0/8 1.0.0.0/8'
)

time.sleep(10000)

time.sleep(10000)

if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
try:
main()
except KeyboardInterrupt:
pass
55 changes: 29 additions & 26 deletions qa/self/big/api-internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,40 @@
import time
import random

def write (data):
sys.stdout.write(data + '\n')
sys.stdout.flush()

def main ():
count = 0
def write(data):
sys.stdout.write(data + '\n')
sys.stdout.flush()

ip = {}
nexthop="1.2.3.4"

for ip1 in range(0,223):
generated = '%d.0.0.0/8' % (ip1)
ip[generated] = nexthop
def main():
count = 0

for ip1 in range(0,223):
for ip2 in range(0,256):
generated = '%d.%d.0.0/16' % (ip1,ip2)
ip[generated] = nexthop
ip = {}
nexthop = "1.2.3.4"

# initial table dump
for k,v in ip.iteritems():
count += 1
write('announce route %s next-hop %s med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ]' % (k,v))
if count % 100 == 0:
sys.stderr.write('initial : announced %d\n' % count)
for ip1 in range(0, 223):
generated = '%d.0.0.0/8' % (ip1)
ip[generated] = nexthop

for ip1 in range(0, 223):
for ip2 in range(0, 256):
generated = '%d.%d.0.0/16' % (ip1, ip2)
ip[generated] = nexthop

# initial table dump
for k, v in ip.iteritems():
count += 1
write('announce route %s next-hop %s med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ]' % (k, v))
if count % 100 == 0:
sys.stderr.write('initial : announced %d\n' % count)

count &= 0xFFFFFFFE
time.sleep(10000)

count &= 0xFFFFFFFe
time.sleep(10000)

if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
try:
main()
except KeyboardInterrupt:
pass
6 changes: 3 additions & 3 deletions qa/self/big/dump-all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
count = 0

while True:
line = sys.stdin.readline()
sys.stderr.write(line)
sys.stderr.flush()
line = sys.stdin.readline()
sys.stderr.write(line)
sys.stderr.flush()
12 changes: 6 additions & 6 deletions qa/self/big/dump-number.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
count = 0

while True:
line = sys.stdin.readline()
if ' route' in line:
count += 1
if count % 100 == 0:
sys.stderr.write('received %-10d\n' % count)
sys.stderr.flush()
line = sys.stdin.readline()
if ' route' in line:
count += 1
if count % 100 == 0:
sys.stderr.write('received %-10d\n' % count)
sys.stderr.flush()
12 changes: 6 additions & 6 deletions qa/self/big/dump-to-screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
count = 0

while True:
line = sys.stdin.readline()
if ' route' in line:
count += 1
if count % 100 == 0:
sys.stderr.write('received %-10d\n' % count)
sys.stderr.flush()
line = sys.stdin.readline()
if ' route' in line:
count += 1
if count % 100 == 0:
sys.stderr.write('received %-10d\n' % count)
sys.stderr.flush()
28 changes: 14 additions & 14 deletions qa/self/flow/flow-change.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import time

flow="flow route { match { source 10.0.0.1/32; destination 10.0.0.2/32; destination-port =3128; protocol tcp; } then { discard; } }"
flow = "flow route { match { source 10.0.0.1/32; destination 10.0.0.2/32; destination-port =3128; protocol tcp; } then { discard; } }"

# When the parent dies we are seeing continual newlines, so we only access so many before stopping
counter = 1
Expand All @@ -15,17 +15,17 @@
time.sleep(1)

while True:
try:
time.sleep(1)
if counter % 2:
print('announce', flow)
sys.stdout.flush()
else:
print('withdraw', flow)
sys.stdout.flush()
try:
time.sleep(1)
if counter % 2:
print('announce', flow)
sys.stdout.flush()
else:
print('withdraw', flow)
sys.stdout.flush()

counter += 1
except KeyboardInterrupt:
pass
except IOError:
break
counter += 1
except KeyboardInterrupt:
pass
except IOError:
break
42 changes: 22 additions & 20 deletions qa/self/flow/log-syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@
import time
import syslog

def _prefixed (level, message):
now = time.strftime('%a, %d %b %Y %H:%M:%S',time.localtime())
return "%s %-8s %-6d %s" % (now,level,os.getpid(),message)

def _prefixed(level, message):
now = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime())
return "%s %-8s %-6d %s" % (now, level, os.getpid(), message)


syslog.openlog("ExaBGP")

# When the parent dies we are seeing continual newlines, so we only access so many before stopping
counter = 0

while True:
try:
line = sys.stdin.readline().strip()
if line == "":
counter += 1
if counter > 100:
break
continue

counter = 0

print >> sys.stderr, line
syslog.syslog(syslog.LOG_ALERT, _prefixed('INFO',line))
except KeyboardInterrupt:
pass
except IOError:
# most likely a signal during readline
pass
try:
line = sys.stdin.readline().strip()
if line == "":
counter += 1
if counter > 100:
break
continue

counter = 0

print >>sys.stderr, line
syslog.syslog(syslog.LOG_ALERT, _prefixed('INFO', line))
except KeyboardInterrupt:
pass
except IOError:
# most likely a signal during readline
pass
25 changes: 12 additions & 13 deletions qa/self/json/receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
exit = False

while True:
line = sys.stdin.readline().strip()
line = sys.stdin.readline().strip()

if not line:
if exit:
sys.exit(0)
exit = True
else:
exit = False

if not line:
if exit:
sys.exit(0)
exit = True
else:
exit = False

print >> sys.stderr, '\n=====\n'
print >> sys.stderr, line
print >> sys.stderr, '\n---\n'
print >> sys.stderr, pprint.pformat(json.loads(line),indent=3).replace("u'","'")
sys.stderr.flush()
print >>sys.stderr, '\n=====\n'
print >>sys.stderr, line
print >>sys.stderr, '\n---\n'
print >>sys.stderr, pprint.pformat(json.loads(line), indent=3).replace("u'", "'")
sys.stderr.flush()

0 comments on commit 4436f16

Please sign in to comment.