[vstest]: convert the tests to python3

Signed-off-by: Guohan Lu <lguohan@gmail.com>
This commit is contained in:
Guohan Lu 2020-07-19 03:39:49 +00:00
parent b3ae7858ca
commit aa9e1e2f43
3 changed files with 25 additions and 25 deletions

View File

@ -6,7 +6,7 @@ import json
import random import random
def output(dvs, title): def output(dvs, title):
print "=========================== %s ===========================" % title print("=========================== %s ===========================" % title)
exit_cod, sum_res = dvs.runcmd(["vtysh", "-c", "show ip bgp sum"]) exit_cod, sum_res = dvs.runcmd(["vtysh", "-c", "show ip bgp sum"])
exit_code, all_route = dvs.runcmd(["vtysh", "-c", "show ip bgp"]) exit_code, all_route = dvs.runcmd(["vtysh", "-c", "show ip bgp"])
exit_code, neig_1 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.1"]) exit_code, neig_1 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.1"])
@ -14,22 +14,22 @@ def output(dvs, title):
exit_code, received_route_1 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.1 routes"]) exit_code, received_route_1 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.1 routes"])
exit_code, announce_route_3 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.3 advertised-routes"]) exit_code, announce_route_3 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.3 advertised-routes"])
exit_code, received_route_3 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.3 routes"]) exit_code, received_route_3 = dvs.runcmd(["vtysh", "-c", "show ip bgp neighbors 10.0.0.3 routes"])
print "Summary:" print("Summary:")
print sum_res print(sum_res)
print "Received routes:" print("Received routes:")
print "10.0.0.1" print("10.0.0.1")
print received_route_1 print(received_route_1)
print "10.0.0.3" print("10.0.0.3")
print received_route_3 print(received_route_3)
print "Announces routes:" print("Announces routes:")
print "10.0.0.1" print("10.0.0.1")
print announce_route_1 print(announce_route_1)
print "10.0.0.3" print("10.0.0.3")
print announce_route_3 print(announce_route_3)
print "Neighbors" print("Neighbors")
print "10.0.0.1" print("10.0.0.1")
print neig_1 print(neig_1)
print "======================================================" print("======================================================")
def mkdir(path): def mkdir(path):
if not os.path.exists(path): if not os.path.exists(path):
@ -66,11 +66,11 @@ def run_exa(dvs, idx, cfg):
remove(fifo_out_path) remove(fifo_out_path)
os.mkfifo(fifo_in_path) os.mkfifo(fifo_in_path)
os.mkfifo(fifo_out_path) os.mkfifo(fifo_out_path)
os.chmod(fifo_in_path, 0666) os.chmod(fifo_in_path, 0o666)
os.chmod(fifo_out_path, 0666) os.chmod(fifo_out_path, 0o666)
print "!!! Start exabgp instance %d" % idx print("!!! Start exabgp instance %d" % idx)
cmd = "exabgp -d --env %s %s" % (get_target_env(idx), cfg) cmd = "exabgp -d --env %s %s" % (get_target_env(idx), cfg)
print "Cmd is ___ %s ___" % cmd print("Cmd is ___ %s ___" % cmd)
return dvs.servers[idx].runcmd_async(cmd) return dvs.servers[idx].runcmd_async(cmd)
def run_exacli(dvs, idx, cmd): def run_exacli(dvs, idx, cmd):

View File

@ -17,7 +17,7 @@ def test_InvalidNexthop(dvs, testlog):
time.sleep(5) time.sleep(5)
print dvs.runcmd("supervisorctl status") print(dvs.runcmd("supervisorctl status"))
p = dvs.servers[0].runcmd_async("exabgp -d bgp/files/invalid_nexthop/invalid_nexthop.conf") p = dvs.servers[0].runcmd_async("exabgp -d bgp/files/invalid_nexthop/invalid_nexthop.conf")
@ -28,6 +28,6 @@ def test_InvalidNexthop(dvs, testlog):
p.terminate() p.terminate()
p = p.wait() p = p.wait()
print exit_code, output print(exit_code, output)
assert "3333::/64" in output assert "3333::/64" in output

View File

@ -36,8 +36,8 @@ def test_bounce(dvs, testlog):
p2.terminate() p2.terminate()
p2 = p2.wait() p2 = p2.wait()
print sum_res print(sum_res)
print announce_route print(announce_route)
assert "1.1.1.1/32" in all_route assert "1.1.1.1/32" in all_route
assert "1.1.1.1/32" not in announce_route assert "1.1.1.1/32" not in announce_route
assert "2.2.2.2/32" in all_route assert "2.2.2.2/32" in all_route