diff options
Diffstat (limited to 'test/scenario_test')
30 files changed, 194 insertions, 208 deletions
diff --git a/test/scenario_test/README.md b/test/scenario_test/README.md index 84ab2d71..2b3d9733 100644 --- a/test/scenario_test/README.md +++ b/test/scenario_test/README.md @@ -57,7 +57,7 @@ Execute the following commands inside the VM to install the dependencies: ```shell $ sudo apt-get update - $ sudo apt-get install git python-pip python-dev iputils-arping bridge-utils lv + $ sudo apt-get install git python3-pip python3-dev iputils-arping bridge-utils lv $ sudo wget https://raw.github.com/jpetazzo/pipework/master/pipework -O /usr/local/bin/pipework $ sudo chmod 755 /usr/local/bin/pipework ``` @@ -91,7 +91,7 @@ You also need this operation at every modification to the source code. ```shell $ cd $GOPATH/src/github.com/osrg/gobgp -$ sudo fab -f ./test/lib/base.py make_gobgp_ctn --set tag=gobgp +$ sudo fab2 -r ./test/lib make-gobgp-ctn ``` ## Run test @@ -116,7 +116,7 @@ $ sudo fab -f ./test/lib/base.py make_gobgp_ctn --set tag=gobgp ```shell $ cd $GOPATH/src/github.com/osrg/gobgp/test/scenario_test - $ sudo -E PYTHONPATH=$GOBGP/test python <scenario test name>.py + $ sudo -E PYTHONPATH=$GOBGP/test python3 <scenario test name>.py ... OK ``` diff --git a/test/scenario_test/addpath_test.py b/test/scenario_test/addpath_test.py index 2d71554b..c8a8491b 100644 --- a/test/scenario_test/addpath_test.py +++ b/test/scenario_test/addpath_test.py @@ -18,12 +18,12 @@ import time import unittest import nose -from fabric.api import local from lib import base from lib.base import ( BGP_FSM_ESTABLISHED, assert_several_times, + local, ) from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer @@ -252,7 +252,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/aspath_test.py b/test/scenario_test/aspath_test.py index e88e0de4..c93cc7e5 100644 --- a/test/scenario_test/aspath_test.py +++ b/test/scenario_test/aspath_test.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -28,6 +27,7 @@ from lib import base from lib.base import ( BGP_FSM_ESTABLISHED, assert_several_times, + local, ) from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -173,7 +173,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/bgp_confederation_test.py b/test/scenario_test/bgp_confederation_test.py index f50aa28e..9fdd4a74 100644 --- a/test/scenario_test/bgp_confederation_test.py +++ b/test/scenario_test/bgp_confederation_test.py @@ -13,20 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import -from __future__ import print_function + + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -113,7 +112,7 @@ class GoBGPTestBase(unittest.TestCase): if routes: break time.sleep(1) - self.failIf(len(routes) == 0) + self.assertFalse(len(routes) == 0) # Confirm AS_PATH in confederation is removed self._check_global_rib_first(self.quaggas['q1'], '10.0.0.0/24', [30, 20, 21]) @@ -133,8 +132,8 @@ class GoBGPTestBase(unittest.TestCase): if len(routes[0]['paths']) == 2: break time.sleep(1) - self.failIf(len(routes) != 1) - self.failIf(len(routes[0]['paths']) != 2) + self.assertFalse(len(routes) != 1) + self.assertFalse(len(routes[0]['paths']) != 2) # In g1, there are two routes to 10.0.0.0/24 # confirm the route from q1 is selected as the best path diff --git a/test/scenario_test/bgp_malformed_msg_handling_test.py b/test/scenario_test/bgp_malformed_msg_handling_test.py index b5af69e2..5f0c4ce4 100644 --- a/test/scenario_test/bgp_malformed_msg_handling_test.py +++ b/test/scenario_test/bgp_malformed_msg_handling_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer @@ -101,7 +100,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index e7ac9ec1..87add9a9 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import json import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -34,6 +33,7 @@ from lib.base import ( BGP_ATTR_TYPE_LOCAL_PREF, wait_for_completion, assert_several_times, + local, ) from lib.gobgp import ( GoBGPContainer, @@ -77,13 +77,13 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) def test_02_check_gobgp_global_rib(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): # paths expected to exist in gobgp's global rib - routes = q.routes.keys() + routes = list(q.routes.keys()) timeout = 120 interval = 1 count = 0 @@ -108,7 +108,7 @@ class GoBGPTestBase(unittest.TestCase): # check gobgp properly add it's own asn to aspath def test_03_check_gobgp_adj_out_rib(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): for path in self.gobgp.get_adj_rib_out(q): asns = path['aspath'] self.assertTrue(self.gobgp.asn in asns) @@ -117,7 +117,7 @@ class GoBGPTestBase(unittest.TestCase): def test_04_check_quagga_global_rib(self): interval = 1 timeout = int(120 / interval) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): done = False for _ in range(timeout): if done: @@ -130,7 +130,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertEqual(len(global_rib), len(self.quaggas)) - for c in self.quaggas.itervalues(): + for c in self.quaggas.values(): for r in c.routes: self.assertTrue(r in global_rib) done = True @@ -208,8 +208,8 @@ class GoBGPTestBase(unittest.TestCase): paths = self.gobgp.get_adj_rib_out(q1, '10.0.6.0/24') if len(paths) > 0: path = paths[0] - print "{0}'s nexthop is {1}".format(path['nlri']['prefix'], - path['nexthop']) + print("{0}'s nexthop is {1}".format(path['nlri']['prefix'], + path['nexthop'])) n_addrs = [i[1].split('/')[0] for i in self.gobgp.ip_addrs] if path['nexthop'] in n_addrs: break @@ -229,7 +229,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertEqual(len(path['aspath']), 0) def test_11_check_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): paths = self.gobgp.get_adj_rib_out(q, '10.10.0.0/24') self.assertEqual(len(paths), 1) path = paths[0] @@ -245,11 +245,11 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(3) - for route in q1.routes.iterkeys(): + for route in q1.routes.keys(): dst = self.gobgp.get_global_rib(route) self.assertEqual(len(dst), 0) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): if q is q1: continue paths = self.gobgp.get_adj_rib_out(q, route) @@ -397,7 +397,7 @@ class GoBGPTestBase(unittest.TestCase): wait_for_completion(lambda: len(g1.get_global_rib(prefix)) == 0) wait_for_completion(lambda: len(g2.get_global_rib(prefix)) == 0) - ret = json.loads(r.next()) + ret = json.loads(next(r)) self.assertEqual(ret[0]['nlri']['prefix'], prefix) self.assertTrue('withdrawal' in ret[0]) @@ -416,12 +416,12 @@ class GoBGPTestBase(unittest.TestCase): cnt2 = 0 g = next_prefix() - n = g.next() + n = next(g) for path in g1.local("gobgp global rib", capture=True).split('\n')[1:]: if [elem for elem in path.split(' ') if elem != ''][1] == n: try: cnt2 += 1 - n = g.next() + n = next(g) except StopIteration: break @@ -473,7 +473,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/bgp_unnumbered_test.py b/test/scenario_test/bgp_unnumbered_test.py index 42aec3b9..7ebb50da 100644 --- a/test/scenario_test/bgp_unnumbered_test.py +++ b/test/scenario_test/bgp_unnumbered_test.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import unittest -from fabric.api import local from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer import sys import os @@ -92,7 +91,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/bgp_zebra_nht_test.py b/test/scenario_test/bgp_zebra_nht_test.py index 9042a0a0..7dd61212 100644 --- a/test/scenario_test/bgp_zebra_nht_test.py +++ b/test/scenario_test/bgp_zebra_nht_test.py @@ -17,7 +17,6 @@ import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -27,6 +26,7 @@ from lib.base import ( assert_several_times, Bridge, BGP_FSM_ESTABLISHED, + local, ) from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaOSPFContainer @@ -285,7 +285,7 @@ class ZebraNHTTest(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/bgp_zebra_test.py b/test/scenario_test/bgp_zebra_test.py index a8787e22..a9f2a0b2 100644 --- a/test/scenario_test/bgp_zebra_test.py +++ b/test/scenario_test/bgp_zebra_test.py @@ -13,14 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import -from __future__ import print_function import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -29,6 +26,7 @@ from lib import base from lib.base import ( Bridge, BGP_FSM_ESTABLISHED, + local, ) from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer diff --git a/test/scenario_test/ci-scripts/jenkins-build-script.sh b/test/scenario_test/ci-scripts/jenkins-build-script.sh index 6baf2193..5424a0ef 100644 --- a/test/scenario_test/ci-scripts/jenkins-build-script.sh +++ b/test/scenario_test/ci-scripts/jenkins-build-script.sh @@ -33,7 +33,7 @@ do done sudo docker rmi $GOBGP_IMAGE -sudo fab -f $GOBGP/test/lib/base.py make_gobgp_ctn:tag=$GOBGP_IMAGE +sudo fab2 -r $GOBGP/test/lib make-gobgp-ctn [ "$?" != 0 ] && exit "$?" cd $GOBGP/gobgpd diff --git a/test/scenario_test/evpn_test.py b/test/scenario_test/evpn_test.py index 7e227b05..6490cf58 100644 --- a/test/scenario_test/evpn_test.py +++ b/test/scenario_test/evpn_test.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + from itertools import combinations import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -29,6 +28,7 @@ from lib import base from lib.base import ( BGP_FSM_ESTABLISHED, BGP_ATTR_TYPE_EXTENDED_COMMUNITIES, + local, ) from lib.gobgp import GoBGPContainer @@ -145,7 +145,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/flow_spec_test.py b/test/scenario_test/flow_spec_test.py index 0c77261b..c7a43ce7 100644 --- a/test/scenario_test/flow_spec_test.py +++ b/test/scenario_test/flow_spec_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer from lib.yabgp import YABGPContainer @@ -411,7 +410,7 @@ class FlowSpecTest(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/global_policy_test.py b/test/scenario_test/global_policy_test.py index 5c1aea87..239464b7 100644 --- a/test/scenario_test/global_policy_test.py +++ b/test/scenario_test/global_policy_test.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -29,6 +28,7 @@ from lib.base import ( BGP_FSM_IDLE, BGP_FSM_ESTABLISHED, BGP_ATTR_TYPE_COMMUNITIES, + local, ) from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer @@ -80,11 +80,11 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) def test_02_check_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0) def test_03_add_peer(self): @@ -95,7 +95,7 @@ class GoBGPTestBase(unittest.TestCase): q.add_route('10.10.0.0/24') self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) self.quaggas['q4'] = q - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0) def test_04_disable_peer(self): @@ -103,7 +103,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.disable_peer(q3) self.gobgp.wait_for(expected_state=BGP_FSM_IDLE, peer=q3) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): if q.name == 'q3': continue self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0) @@ -113,7 +113,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.enable_peer(q3) self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q3) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0) def test_06_disable_peer2(self): @@ -127,7 +127,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.disable_peer(q3) self.gobgp.wait_for(expected_state=BGP_FSM_IDLE, peer=q3) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): if q.name == 'q3': continue self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0) @@ -139,11 +139,11 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.local('gobgp policy statement st0 add action accept') self.gobgp.local('gobgp policy add p0 st0') self.gobgp.local('gobgp global policy export add p0 default reject') - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.softreset(q, type='out') def test_08_check_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): if q.name == 'q3': continue paths = self.gobgp.get_adj_rib_out(q) @@ -155,11 +155,11 @@ class GoBGPTestBase(unittest.TestCase): def test_09_change_global_policy(self): self.gobgp.local('gobgp policy statement st0 add action community add 65100:10') self.gobgp.local('gobgp global policy export set p0 default accept') - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.softreset(q, type='out') def test_10_check_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): if q.name == 'q3': continue paths = self.gobgp.get_adj_rib_out(q) @@ -185,7 +185,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.local('gobgp policy statement st1 add action local-pref 300') self.gobgp.local('gobgp policy add p1 st1') self.gobgp.local('gobgp global policy export set p1 default reject') - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.softreset(q, type='out') def test_13_check_adj_rib_out(self): @@ -201,7 +201,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.local('gobgp policy statement st2 add condition route-type local') self.gobgp.local('gobgp policy add p2 st2') self.gobgp.local('gobgp global policy export set p2 default reject') - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.softreset(q, type='out') q1 = self.quaggas['q1'] @@ -212,14 +212,14 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(1) self.assertEqual(len(self.gobgp.get_adj_rib_out(q1)), 1) - self.assertEqual(self.gobgp.get_adj_rib_out(q1)[0]['nlri']['prefix'], u'10.20.0.0/24') + self.assertEqual(self.gobgp.get_adj_rib_out(q1)[0]['nlri']['prefix'], '10.20.0.0/24') def test_15_route_type_condition_internal(self): self.gobgp.local('gobgp policy statement st22 add action accept') self.gobgp.local('gobgp policy statement st22 add condition route-type internal') self.gobgp.local('gobgp policy add p2 st22') self.gobgp.local('gobgp policy del p2 st2') - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.softreset(q, type='out') q1 = self.quaggas['q1'] @@ -231,14 +231,14 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(1) self.assertEqual(len(self.gobgp.get_adj_rib_out(q1)), 1) - self.assertEqual(self.gobgp.get_adj_rib_out(q1)[0]['nlri']['prefix'], u'10.30.0.0/24') + self.assertEqual(self.gobgp.get_adj_rib_out(q1)[0]['nlri']['prefix'], '10.30.0.0/24') def test_16_route_type_condition_external(self): self.gobgp.local('gobgp policy statement st222 add action accept') self.gobgp.local('gobgp policy statement st222 add condition route-type external') self.gobgp.local('gobgp policy add p2 st222') self.gobgp.local('gobgp policy del p2 st22') - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.softreset(q, type='out') q1 = self.quaggas['q1'] @@ -292,7 +292,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/graceful_restart_test.py b/test/scenario_test/graceful_restart_test.py index a97c9642..59dfe226 100644 --- a/test/scenario_test/graceful_restart_test.py +++ b/test/scenario_test/graceful_restart_test.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -30,6 +29,7 @@ from lib.base import ( BGP_FSM_ACTIVE, BGP_FSM_ESTABLISHED, GRACEFUL_RESTART_TIME, + local, ) from lib.gobgp import GoBGPContainer @@ -196,7 +196,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/ibgp_router_test.py b/test/scenario_test/ibgp_router_test.py index 4b709681..ba8382c0 100644 --- a/test/scenario_test/ibgp_router_test.py +++ b/test/scenario_test/ibgp_router_test.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + from itertools import combinations import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -29,6 +28,7 @@ from lib import base from lib.base import ( BGP_FSM_IDLE, BGP_FSM_ESTABLISHED, + local, ) from lib.base import wait_for_completion from lib.gobgp import GoBGPContainer @@ -69,13 +69,13 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) def test_02_check_gobgp_global_rib(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): # paths expected to exist in gobgp's global rib - routes = q.routes.keys() + routes = list(q.routes.keys()) timeout = 120 interval = 1 count = 0 @@ -98,7 +98,7 @@ class GoBGPTestBase(unittest.TestCase): raise Exception('timeout') def test_03_check_gobgp_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): paths = self.gobgp.get_adj_rib_out(q) # bgp speaker mustn't forward iBGP routes to iBGP peers self.assertEqual(len(paths), 0) @@ -113,7 +113,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertEqual(len(path['aspath']), 0) def test_05_check_gobgp_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): paths = self.gobgp.get_adj_rib_out(q) self.assertEqual(len(paths), len(self.gobgp.routes)) path = paths[0] @@ -127,7 +127,7 @@ class GoBGPTestBase(unittest.TestCase): def test_06_check_quagga_global_rib(self): interval = 1 timeout = int(120 / interval) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): done = False for _ in range(timeout): if done: @@ -147,7 +147,7 @@ class GoBGPTestBase(unittest.TestCase): if rr['prefix'] == r: self.assertEqual(rr['nexthop'], local_addr) - for r in q.routes.keys(): + for r in list(q.routes.keys()): self.assertTrue(r in (p['prefix'] for p in global_rib)) for rr in global_rib: if rr['prefix'] == r: @@ -194,7 +194,7 @@ class GoBGPTestBase(unittest.TestCase): peer_info = self.gobgp.peers[q3] neigh_addr = peer_info['neigh_addr'].split('/')[0] - for prefix in q3.routes.iterkeys(): + for prefix in q3.routes.keys(): paths = self.gobgp.get_adj_rib_out(q1, prefix) self.assertEqual(len(paths), 1) path = paths[0] @@ -212,14 +212,14 @@ class GoBGPTestBase(unittest.TestCase): del self.quaggas['q3'] self.gobgp.wait_for(expected_state=BGP_FSM_IDLE, peer=q3) - for route in q3.routes.iterkeys(): + for route in q3.routes.keys(): dst = self.gobgp.get_global_rib(route) self.assertEqual(len(dst), 0) - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): paths = self.gobgp.get_adj_rib_out(q) # only gobgp's locally generated routes must exists - print paths + print(paths) self.assertEqual(len(paths), len(self.gobgp.routes)) def test_12_disable_ibgp_peer(self): @@ -227,7 +227,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.disable_peer(q1) self.gobgp.wait_for(expected_state=BGP_FSM_IDLE, peer=q1) - for route in q1.routes.iterkeys(): + for route in q1.routes.keys(): dst = self.gobgp.get_global_rib(route) self.assertEqual(len(dst), 0) @@ -237,7 +237,7 @@ class GoBGPTestBase(unittest.TestCase): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q1) def test_14_check_gobgp_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): paths = self.gobgp.get_adj_rib_out(q) # only gobgp's locally generated routes must exists self.assertEqual(len(paths), len(self.gobgp.routes)) @@ -293,7 +293,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/long_lived_graceful_restart_test.py b/test/scenario_test/long_lived_graceful_restart_test.py index 171f204d..0ea38ff1 100644 --- a/test/scenario_test/long_lived_graceful_restart_test.py +++ b/test/scenario_test/long_lived_graceful_restart_test.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + from itertools import chain import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -30,6 +29,7 @@ from lib.base import ( BGP_FSM_ACTIVE, BGP_FSM_ESTABLISHED, LONG_LIVED_GRACEFUL_RESTART_TIME, + local, ) from lib.gobgp import GoBGPContainer @@ -166,7 +166,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_reflector_test.py b/test/scenario_test/route_reflector_test.py index 53654c34..7fbf576c 100644 --- a/test/scenario_test/route_reflector_test.py +++ b/test/scenario_test/route_reflector_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -92,17 +91,17 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) def test_02_check_gobgp_global_rib(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): # paths expected to exist in gobgp's global rib def f(): state = self.gobgp.get_neighbor_state(q) self.assertEqual(state, BGP_FSM_ESTABLISHED) - routes = q.routes.keys() + routes = list(q.routes.keys()) global_rib = [p['prefix'] for p in self.gobgp.get_global_rib()] for p in global_rib: if p in routes: @@ -112,16 +111,16 @@ class GoBGPTestBase(unittest.TestCase): wait_for(f) def test_03_check_gobgp_adj_rib_out(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): paths = [p['nlri']['prefix'] for p in self.gobgp.get_adj_rib_out(q)] - for qq in self.quaggas.itervalues(): + for qq in self.quaggas.values(): if q == qq: continue if self.gobgp.peers[q]['is_rr_client']: - for p in qq.routes.keys(): + for p in list(qq.routes.keys()): self.assertTrue(p in paths) else: - for p in qq.routes.keys(): + for p in list(qq.routes.keys()): if self.gobgp.peers[qq]['is_rr_client']: self.assertTrue(p in paths) else: @@ -262,7 +261,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_as2_test.py b/test/scenario_test/route_server_as2_test.py index 75babb15..c5d62e58 100644 --- a/test/scenario_test/route_server_as2_test.py +++ b/test/scenario_test/route_server_as2_test.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import unittest import sys import time -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -28,6 +27,7 @@ from lib import base from lib.base import ( BGP_FSM_IDLE, BGP_FSM_ESTABLISHED, + local, ) from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer @@ -76,11 +76,11 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) def test_02_check_gobgp_local_rib(self): - for rs_client in self.quaggas.itervalues(): + for rs_client in self.quaggas.values(): done = False for _ in range(self.retry_limit): if done: @@ -111,7 +111,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_ipv4_v6_test.py b/test/scenario_test/route_server_ipv4_v6_test.py index 28b438d2..f40b47de 100644 --- a/test/scenario_test/route_server_ipv4_v6_test.py +++ b/test/scenario_test/route_server_ipv4_v6_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -77,7 +76,7 @@ class GoBGPIPv6Test(unittest.TestCase): cls.ipv6s = {'q3': q3, 'q4': q4} def check_gobgp_local_rib(self, ctns, rf): - for rs_client in ctns.itervalues(): + for rs_client in ctns.values(): done = False for _ in range(self.retry_limit): if done: @@ -93,7 +92,7 @@ class GoBGPIPv6Test(unittest.TestCase): self.assertEqual(len(local_rib), (len(ctns) - 1)) - for c in ctns.itervalues(): + for c in ctns.values(): if rs_client != c: for r in c.routes: self.assertTrue(r in local_rib) @@ -105,7 +104,7 @@ class GoBGPIPv6Test(unittest.TestCase): raise AssertionError def check_rs_client_rib(self, ctns, rf): - for rs_client in ctns.itervalues(): + for rs_client in ctns.values(): done = False for _ in range(self.retry_limit): if done: @@ -118,7 +117,7 @@ class GoBGPIPv6Test(unittest.TestCase): self.assertEqual(len(global_rib), len(ctns)) - for c in ctns.itervalues(): + for c in ctns.values(): for r in c.routes: self.assertTrue(r in global_rib) @@ -130,7 +129,7 @@ class GoBGPIPv6Test(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) def test_02_check_ipv4_peer_rib(self): @@ -142,7 +141,7 @@ class GoBGPIPv6Test(unittest.TestCase): self.check_rs_client_rib(self.ipv6s, 'ipv6') def test_04_add_in_policy_to_reject_all(self): - for q in self.gobgp.peers.itervalues(): + for q in self.gobgp.peers.values(): self.gobgp.local('gobgp neighbor {0} policy import set default reject'.format(q['neigh_addr'].split('/')[0])) def test_05_check_ipv4_peer_rib(self): @@ -158,11 +157,11 @@ class GoBGPIPv6Test(unittest.TestCase): time.sleep(1) def test_08_check_rib(self): - for q in self.ipv4s.itervalues(): + for q in self.ipv4s.values(): self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0) self.assertEqual(len(q.get_global_rib()), len(q.routes)) - for q in self.ipv6s.itervalues(): + for q in self.ipv6s.values(): self.assertEqual(len(self.gobgp.get_adj_rib_out(q, rf='ipv6')), 0) self.assertEqual(len(q.get_global_rib(rf='ipv6')), len(q.routes)) @@ -170,7 +169,7 @@ class GoBGPIPv6Test(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_malformed_test.py b/test/scenario_test/route_server_malformed_test.py index 08a6467e..1d60a27a 100644 --- a/test/scenario_test/route_server_malformed_test.py +++ b/test/scenario_test/route_server_malformed_test.py @@ -13,20 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest import inspect -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer @@ -42,7 +41,7 @@ def register_scenario(cls): def lookup_scenario(name): - for value in _SCENARIOS.values(): + for value in list(_SCENARIOS.values()): if value.__name__ == name: return value return None @@ -522,14 +521,14 @@ class TestGoBGPBase(unittest.TestCase): cls.parser_option = parser_option cls.executors = [] if idx == 0: - print 'unset test-index. run all test sequential' - for _, v in _SCENARIOS.items(): + print('unset test-index. run all test sequential') + for _, v in list(_SCENARIOS.items()): for k, m in inspect.getmembers(v, inspect.isfunction): if k == 'executor': cls.executor = m cls.executors.append(cls.executor) elif idx not in _SCENARIOS: - print 'invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS)) + print('invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS))) sys.exit(1) else: for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction): @@ -545,7 +544,7 @@ class TestGoBGPBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_policy_grpc_test.py b/test/scenario_test/route_server_policy_grpc_test.py index 63ec6558..20661819 100644 --- a/test/scenario_test/route_server_policy_grpc_test.py +++ b/test/scenario_test/route_server_policy_grpc_test.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest import inspect -from fabric.api import local import nose from nose.tools import ( assert_true, @@ -35,6 +34,7 @@ from lib.base import ( BGP_FSM_ESTABLISHED, BGP_ATTR_TYPE_COMMUNITIES, BGP_ATTR_TYPE_EXTENDED_COMMUNITIES, + local, ) from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -52,7 +52,7 @@ def register_scenario(cls): def lookup_scenario(name): - for value in _SCENARIOS.values(): + for value in list(_SCENARIOS.values()): if value.__name__ == name: return value return None @@ -822,9 +822,9 @@ class ImportPolicyAsPathLengthCondition(object): g1.local('gobgp neighbor {0} policy import add policy0'.format(g1.peers[q2]['neigh_addr'].split('/')[0])) # this will be blocked - e1.add_route('192.168.100.0/24', aspath=range(e1.asn, e1.asn - 10, -1)) + e1.add_route('192.168.100.0/24', aspath=list(range(e1.asn, e1.asn - 10, -1))) # this will pass - e1.add_route('192.168.200.0/24', aspath=range(e1.asn, e1.asn - 8, -1)) + e1.add_route('192.168.200.0/24', aspath=list(range(e1.asn, e1.asn - 8, -1))) for c in [e1, q1, q2]: g1.wait_for(BGP_FSM_ESTABLISHED, c) @@ -878,9 +878,9 @@ class ImportPolicyAsPathCondition(object): g1.local('gobgp neighbor {0} policy import add policy0'.format(g1.peers[q2]['neigh_addr'].split('/')[0])) # this will be blocked - e1.add_route('192.168.100.0/24', aspath=range(e1.asn, e1.asn - 10, -1)) + e1.add_route('192.168.100.0/24', aspath=list(range(e1.asn, e1.asn - 10, -1))) # this will pass - e1.add_route('192.168.200.0/24', aspath=range(e1.asn - 1, e1.asn - 10, -1)) + e1.add_route('192.168.200.0/24', aspath=list(range(e1.asn - 1, e1.asn - 10, -1))) for c in [e1, q1, q2]: g1.wait_for(BGP_FSM_ESTABLISHED, c) @@ -2687,14 +2687,14 @@ class TestGoBGPBase(unittest.TestCase): cls.parser_option = parser_option cls.executors = [] if idx == 0: - print 'unset test-index. run all test sequential' - for _, v in _SCENARIOS.items(): + print('unset test-index. run all test sequential') + for _, v in list(_SCENARIOS.items()): for k, m in inspect.getmembers(v, inspect.isfunction): if k == 'executor': cls.executor = m cls.executors.append(cls.executor) elif idx not in _SCENARIOS: - print 'invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS)) + print('invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS))) sys.exit(1) else: for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction): @@ -2710,7 +2710,7 @@ class TestGoBGPBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py index f1b93e43..2c6bd4a0 100644 --- a/test/scenario_test/route_server_policy_test.py +++ b/test/scenario_test/route_server_policy_test.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest import inspect -from fabric.api import local import nose from nose.tools import ( assert_true, @@ -35,6 +34,7 @@ from lib.base import ( BGP_FSM_ESTABLISHED, BGP_ATTR_TYPE_COMMUNITIES, BGP_ATTR_TYPE_EXTENDED_COMMUNITIES, + local, ) from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -52,7 +52,7 @@ def register_scenario(cls): def lookup_scenario(name): - for value in _SCENARIOS.values(): + for value in list(_SCENARIOS.values()): if value.__name__ == name: return value return None @@ -925,9 +925,9 @@ class ImportPolicyAsPathLengthCondition(object): g1.add_policy(policy, q2, 'import') # this will be blocked - e1.add_route('192.168.100.0/24', aspath=range(e1.asn, e1.asn - 10, -1)) + e1.add_route('192.168.100.0/24', aspath=list(range(e1.asn, e1.asn - 10, -1))) # this will pass - e1.add_route('192.168.200.0/24', aspath=range(e1.asn, e1.asn - 8, -1)) + e1.add_route('192.168.200.0/24', aspath=list(range(e1.asn, e1.asn - 8, -1))) for c in [e1, q1, q2]: g1.wait_for(BGP_FSM_ESTABLISHED, c) @@ -985,9 +985,9 @@ class ImportPolicyAsPathCondition(object): g1.add_policy(policy, q2, 'import') # this will be blocked - e1.add_route('192.168.100.0/24', aspath=range(e1.asn, e1.asn - 10, -1)) + e1.add_route('192.168.100.0/24', aspath=list(range(e1.asn, e1.asn - 10, -1))) # this will pass - e1.add_route('192.168.200.0/24', aspath=range(e1.asn - 1, e1.asn - 10, -1)) + e1.add_route('192.168.200.0/24', aspath=list(range(e1.asn - 1, e1.asn - 10, -1))) for c in [e1, q1, q2]: g1.wait_for(BGP_FSM_ESTABLISHED, c) @@ -3150,7 +3150,7 @@ class ImportPolicyRejectImplicitWithdraw(object): lookup_scenario("ImportPolicyRejectImplicitWithdraw").check3(env) -class TestGoBGPBase(): +class TestGoBGPBase(unittest.TestCase): wait_per_retry = 5 retry_limit = 10 @@ -3162,14 +3162,14 @@ class TestGoBGPBase(): cls.parser_option = parser_option cls.executors = [] if idx == 0: - print 'unset test-index. run all test sequential' - for _, v in _SCENARIOS.items(): + print('unset test-index. run all test sequential') + for _, v in list(_SCENARIOS.items()): for k, m in inspect.getmembers(v, inspect.isfunction): if k == 'executor': cls.executor = m cls.executors.append(cls.executor) elif idx not in _SCENARIOS: - print 'invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS)) + print('invalid test-index. # of scenarios: {0}'.format(len(_SCENARIOS))) sys.exit(1) else: for k, m in inspect.getmembers(_SCENARIOS[idx], inspect.isfunction): @@ -3185,7 +3185,7 @@ class TestGoBGPBase(): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_softreset_test.py b/test/scenario_test/route_server_softreset_test.py index 8e0fe374..b801a819 100644 --- a/test/scenario_test/route_server_softreset_test.py +++ b/test/scenario_test/route_server_softreset_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer @@ -61,7 +60,7 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(initial_wait_time) - for cli in cls.clients.itervalues(): + for cli in cls.clients.values(): g1.add_peer(cli, is_rs_client=True, passwd='passwd', passive=True, prefix_limit=10) cli.add_peer(g1, passwd='passwd') @@ -69,7 +68,7 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for cli in self.clients.itervalues(): + for cli in self.clients.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=cli) def test_02_softresetin_test1(self): @@ -137,7 +136,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_test.py b/test/scenario_test/route_server_test.py index 58630881..4f89de8c 100644 --- a/test/scenario_test/route_server_test.py +++ b/test/scenario_test/route_server_test.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -28,6 +27,7 @@ from lib import base from lib.base import ( BGP_FSM_ACTIVE, BGP_FSM_ESTABLISHED, + local, ) from lib.gobgp import GoBGPContainer from lib.quagga import QuaggaBGPContainer @@ -74,7 +74,7 @@ class GoBGPTestBase(unittest.TestCase): cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3} def check_gobgp_local_rib(self): - for rs_client in self.quaggas.itervalues(): + for rs_client in self.quaggas.values(): done = False for _ in range(self.retry_limit): if done: @@ -90,7 +90,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertEqual(len(local_rib), (len(self.quaggas) - 1)) - for c in self.quaggas.itervalues(): + for c in self.quaggas.values(): if rs_client != c: for r in c.routes: self.assertTrue(r in local_rib) @@ -102,7 +102,7 @@ class GoBGPTestBase(unittest.TestCase): raise AssertionError def check_rs_client_rib(self): - for rs_client in self.quaggas.itervalues(): + for rs_client in self.quaggas.values(): done = False for _ in range(self.retry_limit): if done: @@ -115,7 +115,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertEqual(len(global_rib), len(self.quaggas)) - for c in self.quaggas.itervalues(): + for c in self.quaggas.values(): for r in c.routes: self.assertTrue(r in global_rib) @@ -127,7 +127,7 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for q in self.quaggas.itervalues(): + for q in self.quaggas.values(): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) # check advertised routes are stored in route-server's local-rib @@ -223,8 +223,8 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(self.wait_per_retry) for path in q1.get_global_rib(): if path['prefix'] == target_prefix: - print "{0}'s nexthop is {1}".format(path['prefix'], - path['nexthop']) + print("{0}'s nexthop is {1}".format(path['prefix'], + path['nexthop'])) n_addrs = [i[1].split('/')[0] for i in expected_nexthop.ip_addrs] if path['nexthop'] in n_addrs: @@ -251,7 +251,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/route_server_test2.py b/test/scenario_test/route_server_test2.py index 08b984ae..e070bc0b 100644 --- a/test/scenario_test/route_server_test2.py +++ b/test/scenario_test/route_server_test2.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer from lib.exabgp import ExaBGPContainer @@ -53,7 +52,7 @@ class GoBGPTestBase(unittest.TestCase): initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) - for cli in cls.clients.values(): + for cli in list(cls.clients.values()): # Omit "passwd" to avoid a issue on ExaBGP version 4.0.5: # https://github.com/Exa-Networks/exabgp/issues/766 g1.add_peer(cli, is_rs_client=True, passive=True, prefix_limit=10) @@ -67,7 +66,7 @@ class GoBGPTestBase(unittest.TestCase): # test each neighbor state is turned establish def test_01_neighbor_established(self): - for cli in self.clients.values(): + for cli in list(self.clients.values()): self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=cli) def test_02_add_neighbor(self): @@ -103,7 +102,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/rtc_test.py b/test/scenario_test/rtc_test.py index 98a91c70..d5620a26 100644 --- a/test/scenario_test/rtc_test.py +++ b/test/scenario_test/rtc_test.py @@ -13,20 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + from itertools import combinations import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer @@ -986,7 +985,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/run_all_tests.sh b/test/scenario_test/run_all_tests.sh index 8c956e47..3aaa8c0e 100755 --- a/test/scenario_test/run_all_tests.sh +++ b/test/scenario_test/run_all_tests.sh @@ -34,51 +34,51 @@ PIDS=() export PYTHONPATH=$GOBGP/test:$PYTHONPATH # route server test -python route_server_test.py --gobgp-image $GOBGP_IMAGE --test-prefix rs -s -x --with-xunit --xunit-file=${WS}/nosetest.xml & +python3 route_server_test.py --gobgp-image $GOBGP_IMAGE --test-prefix rs -s -x --with-xunit --xunit-file=${WS}/nosetest.xml & PIDS=("${PIDS[@]}" $!) # route server ipv4 ipv6 test -python route_server_ipv4_v6_test.py --gobgp-image $GOBGP_IMAGE --test-prefix v6 -s -x --with-xunit --xunit-file=${WS}/nosetest_ip.xml & +python3 route_server_ipv4_v6_test.py --gobgp-image $GOBGP_IMAGE --test-prefix v6 -s -x --with-xunit --xunit-file=${WS}/nosetest_ip.xml & PIDS=("${PIDS[@]}" $!) # bgp router test -python bgp_router_test.py --gobgp-image $GOBGP_IMAGE --test-prefix bgp -s -x --with-xunit --xunit-file=${WS}/nosetest_bgp.xml & +python3 bgp_router_test.py --gobgp-image $GOBGP_IMAGE --test-prefix bgp -s -x --with-xunit --xunit-file=${WS}/nosetest_bgp.xml & PIDS=("${PIDS[@]}" $!) # ibgp router test -python ibgp_router_test.py --gobgp-image $GOBGP_IMAGE --test-prefix ibgp -s -x --with-xunit --xunit-file=${WS}/nosetest_ibgp.xml & +python3 ibgp_router_test.py --gobgp-image $GOBGP_IMAGE --test-prefix ibgp -s -x --with-xunit --xunit-file=${WS}/nosetest_ibgp.xml & PIDS=("${PIDS[@]}" $!) # evpn router test -python evpn_test.py --gobgp-image $GOBGP_IMAGE --test-prefix evpn -s -x --with-xunit --xunit-file=${WS}/nosetest_evpn.xml & +python3 evpn_test.py --gobgp-image $GOBGP_IMAGE --test-prefix evpn -s -x --with-xunit --xunit-file=${WS}/nosetest_evpn.xml & PIDS=("${PIDS[@]}" $!) # flowspec test -python flow_spec_test.py --gobgp-image $GOBGP_IMAGE --test-prefix flow -s -x --with-xunit --xunit-file=${WS}/nosetest_flow.xml & +python3 flow_spec_test.py --gobgp-image $GOBGP_IMAGE --test-prefix flow -s -x --with-xunit --xunit-file=${WS}/nosetest_flow.xml & PIDS=("${PIDS[@]}" $!) # route reflector test -python route_reflector_test.py --gobgp-image $GOBGP_IMAGE --test-prefix rr -s -x --with-xunit --xunit-file=${WS}/nosetest_rr.xml & +python3 route_reflector_test.py --gobgp-image $GOBGP_IMAGE --test-prefix rr -s -x --with-xunit --xunit-file=${WS}/nosetest_rr.xml & PIDS=("${PIDS[@]}" $!) # zebra test -python bgp_zebra_test.py --gobgp-image $GOBGP_IMAGE --test-prefix zebra -s -x --with-xunit --xunit-file=${WS}/nosetest_zebra.xml & +python3 bgp_zebra_test.py --gobgp-image $GOBGP_IMAGE --test-prefix zebra -s -x --with-xunit --xunit-file=${WS}/nosetest_zebra.xml & PIDS=("${PIDS[@]}" $!) # global policy test -python global_policy_test.py --gobgp-image $GOBGP_IMAGE --test-prefix gpol -s -x --with-xunit --xunit-file=${WS}/nosetest_global_policy.xml & +python3 global_policy_test.py --gobgp-image $GOBGP_IMAGE --test-prefix gpol -s -x --with-xunit --xunit-file=${WS}/nosetest_global_policy.xml & PIDS=("${PIDS[@]}" $!) # route server as2 test -python route_server_as2_test.py --gobgp-image $GOBGP_IMAGE --test-prefix as2 -s -x --with-xunit --xunit-file=${WS}/nosetest_rs_as2.xml & +python3 route_server_as2_test.py --gobgp-image $GOBGP_IMAGE --test-prefix as2 -s -x --with-xunit --xunit-file=${WS}/nosetest_rs_as2.xml & PIDS=("${PIDS[@]}" $!) # graceful restart test -python graceful_restart_test.py --gobgp-image $GOBGP_IMAGE --test-prefix gr -s -x --with-xunit --xunit-file=${WS}/nosetest_rs_gr.xml & +python3 graceful_restart_test.py --gobgp-image $GOBGP_IMAGE --test-prefix gr -s -x --with-xunit --xunit-file=${WS}/nosetest_rs_gr.xml & PIDS=("${PIDS[@]}" $!) # bgp unnumbered test -python bgp_unnumbered_test.py --gobgp-image $GOBGP_IMAGE --test-prefix un -s -x --with-xunit --xunit-file=${WS}/nosetest_rs_un.xml & +python3 bgp_unnumbered_test.py --gobgp-image $GOBGP_IMAGE --test-prefix un -s -x --with-xunit --xunit-file=${WS}/nosetest_rs_un.xml & PIDS=("${PIDS[@]}" $!) for (( i = 0; i < ${#PIDS[@]}; ++i )) @@ -92,11 +92,11 @@ done PIDS=() # route server malformed message test -NUM=$(python route_server_malformed_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}') +NUM=$(python3 route_server_malformed_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}') PARALLEL_NUM=10 for (( i = 1; i < $(( $NUM + 1)); ++i )) do - python route_server_malformed_test.py --gobgp-image $GOBGP_IMAGE --test-prefix mal$i --test-index $i -s -x --gobgp-log-level debug --with-xunit --xunit-file=${WS}/nosetest_malform${i}.xml & + python3 route_server_malformed_test.py --gobgp-image $GOBGP_IMAGE --test-prefix mal$i --test-index $i -s -x --gobgp-log-level debug --with-xunit --xunit-file=${WS}/nosetest_malform${i}.xml & PIDS=("${PIDS[@]}" $!) sleep 3 done @@ -110,14 +110,14 @@ do done # route server policy test -NUM=$(python route_server_policy_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}') +NUM=$(python3 route_server_policy_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}') PARALLEL_NUM=25 for (( i = 0; i < $(( NUM / PARALLEL_NUM + 1)); ++i )) do PIDS=() for (( j = $((PARALLEL_NUM * $i + 1)); j < $((PARALLEL_NUM * ($i+1) + 1)); ++j)) do - python route_server_policy_test.py --gobgp-image $GOBGP_IMAGE --test-prefix p$j --test-index $j -s -x --gobgp-log-level debug --with-xunit --xunit-file=${WS}/nosetest_policy${j}.xml & + python3 route_server_policy_test.py --gobgp-image $GOBGP_IMAGE --test-prefix p$j --test-index $j -s -x --gobgp-log-level debug --with-xunit --xunit-file=${WS}/nosetest_policy${j}.xml & PIDS=("${PIDS[@]}" $!) if [ $j -eq $NUM ]; then break @@ -136,14 +136,14 @@ do done # route server policy grpc test -NUM=$(python route_server_policy_grpc_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}') +NUM=$(python3 route_server_policy_grpc_test.py --test-index -1 -s 2> /dev/null | awk '/invalid/{print $NF}') PARALLEL_NUM=25 for (( i = 0; i < $(( NUM / PARALLEL_NUM + 1)); ++i )) do PIDS=() for (( j = $((PARALLEL_NUM * $i + 1)); j < $((PARALLEL_NUM * ($i+1) + 1)); ++j)) do - python route_server_policy_grpc_test.py --gobgp-image $GOBGP_IMAGE --test-prefix pg$j --test-index $j -s -x --gobgp-log-level debug --with-xunit --xunit-file=${WS}/nosetest_policy_grpc${j}.xml & + python3 route_server_policy_grpc_test.py --gobgp-image $GOBGP_IMAGE --test-prefix pg$j --test-index $j -s -x --gobgp-log-level debug --with-xunit --xunit-file=${WS}/nosetest_policy_grpc${j}.xml & PIDS=("${PIDS[@]}" $!) if [ $j -eq $NUM ]; then break diff --git a/test/scenario_test/vrf_neighbor_test.py b/test/scenario_test/vrf_neighbor_test.py index 333b14f6..6b67e968 100644 --- a/test/scenario_test/vrf_neighbor_test.py +++ b/test/scenario_test/vrf_neighbor_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer @@ -171,7 +170,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/vrf_neighbor_test2.py b/test/scenario_test/vrf_neighbor_test2.py index 6aa6a63e..a2502929 100644 --- a/test/scenario_test/vrf_neighbor_test2.py +++ b/test/scenario_test/vrf_neighbor_test2.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option @@ -29,6 +28,7 @@ from lib.base import ( BGP_FSM_ACTIVE, BGP_FSM_ESTABLISHED, wait_for_completion, + local, ) from lib.gobgp import GoBGPContainer @@ -138,7 +138,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], diff --git a/test/scenario_test/zapi_v3_test.py b/test/scenario_test/zapi_v3_test.py index b312e876..cd6348da 100644 --- a/test/scenario_test/zapi_v3_test.py +++ b/test/scenario_test/zapi_v3_test.py @@ -13,19 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import + import sys import time import unittest -from fabric.api import local import nose from lib.noseplugin import OptionParser, parser_option from lib import base -from lib.base import BGP_FSM_ESTABLISHED +from lib.base import BGP_FSM_ESTABLISHED, local from lib.gobgp import GoBGPContainer @@ -97,7 +96,7 @@ class GoBGPTestBase(unittest.TestCase): if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: - print "docker not found" + print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], |