From aa9e1e2f437f201d1ca3513c690666494690fbf2 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sun, 19 Jul 2020 03:39:49 +0000 Subject: [PATCH] [vstest]: convert the tests to python3 Signed-off-by: Guohan Lu --- platform/vs/tests/bgp/test_gr_livelock.py | 42 +++++++++---------- platform/vs/tests/bgp/test_invalid_nexthop.py | 4 +- platform/vs/tests/bgp/test_no_export.py | 4 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/platform/vs/tests/bgp/test_gr_livelock.py b/platform/vs/tests/bgp/test_gr_livelock.py index 5f85bfc239..cd72ffef3e 100644 --- a/platform/vs/tests/bgp/test_gr_livelock.py +++ b/platform/vs/tests/bgp/test_gr_livelock.py @@ -6,7 +6,7 @@ import json import random def output(dvs, title): - print "=========================== %s ===========================" % title + print("=========================== %s ===========================" % title) 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, 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, 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"]) - print "Summary:" - print sum_res - print "Received routes:" - print "10.0.0.1" - print received_route_1 - print "10.0.0.3" - print received_route_3 - print "Announces routes:" - print "10.0.0.1" - print announce_route_1 - print "10.0.0.3" - print announce_route_3 - print "Neighbors" - print "10.0.0.1" - print neig_1 - print "======================================================" + print("Summary:") + print(sum_res) + print("Received routes:") + print("10.0.0.1") + print(received_route_1) + print("10.0.0.3") + print(received_route_3) + print("Announces routes:") + print("10.0.0.1") + print(announce_route_1) + print("10.0.0.3") + print(announce_route_3) + print("Neighbors") + print("10.0.0.1") + print(neig_1) + print("======================================================") def mkdir(path): if not os.path.exists(path): @@ -66,11 +66,11 @@ def run_exa(dvs, idx, cfg): remove(fifo_out_path) os.mkfifo(fifo_in_path) os.mkfifo(fifo_out_path) - os.chmod(fifo_in_path, 0666) - os.chmod(fifo_out_path, 0666) - print "!!! Start exabgp instance %d" % idx + os.chmod(fifo_in_path, 0o666) + os.chmod(fifo_out_path, 0o666) + print("!!! Start exabgp instance %d" % idx) 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) def run_exacli(dvs, idx, cmd): diff --git a/platform/vs/tests/bgp/test_invalid_nexthop.py b/platform/vs/tests/bgp/test_invalid_nexthop.py index 24f3d8790b..3e8acd94e2 100644 --- a/platform/vs/tests/bgp/test_invalid_nexthop.py +++ b/platform/vs/tests/bgp/test_invalid_nexthop.py @@ -17,7 +17,7 @@ def test_InvalidNexthop(dvs, testlog): 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") @@ -28,6 +28,6 @@ def test_InvalidNexthop(dvs, testlog): p.terminate() p = p.wait() - print exit_code, output + print(exit_code, output) assert "3333::/64" in output diff --git a/platform/vs/tests/bgp/test_no_export.py b/platform/vs/tests/bgp/test_no_export.py index 61858bc782..b2c7c5e7cb 100644 --- a/platform/vs/tests/bgp/test_no_export.py +++ b/platform/vs/tests/bgp/test_no_export.py @@ -36,8 +36,8 @@ def test_bounce(dvs, testlog): p2.terminate() p2 = p2.wait() - print sum_res - print announce_route + print(sum_res) + print(announce_route) assert "1.1.1.1/32" in all_route assert "1.1.1.1/32" not in announce_route assert "2.2.2.2/32" in all_route