summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml8
-rw-r--r--test/lib/bagpipe.py10
-rw-r--r--test/lib/base.py63
-rw-r--r--test/lib/bird.py19
-rw-r--r--test/lib/exabgp.py14
-rw-r--r--test/lib/fabfile.py28
-rw-r--r--test/lib/gobgp.py49
-rw-r--r--test/lib/quagga.py45
-rw-r--r--test/lib/yabgp.py23
-rw-r--r--test/lib/yabgp_helper.py4
-rw-r--r--test/pip-requires.txt4
-rw-r--r--test/scenario_test/README.md6
-rw-r--r--test/scenario_test/addpath_test.py4
-rw-r--r--test/scenario_test/aspath_test.py6
-rw-r--r--test/scenario_test/bgp_confederation_test.py13
-rw-r--r--test/scenario_test/bgp_malformed_msg_handling_test.py7
-rw-r--r--test/scenario_test/bgp_router_test.py34
-rw-r--r--test/scenario_test/bgp_unnumbered_test.py7
-rw-r--r--test/scenario_test/bgp_zebra_nht_test.py4
-rw-r--r--test/scenario_test/bgp_zebra_test.py4
-rw-r--r--test/scenario_test/ci-scripts/jenkins-build-script.sh2
-rw-r--r--test/scenario_test/evpn_test.py6
-rw-r--r--test/scenario_test/flow_spec_test.py7
-rw-r--r--test/scenario_test/global_policy_test.py38
-rw-r--r--test/scenario_test/graceful_restart_test.py6
-rw-r--r--test/scenario_test/ibgp_router_test.py32
-rw-r--r--test/scenario_test/long_lived_graceful_restart_test.py6
-rw-r--r--test/scenario_test/route_reflector_test.py21
-rw-r--r--test/scenario_test/route_server_as2_test.py10
-rw-r--r--test/scenario_test/route_server_ipv4_v6_test.py23
-rw-r--r--test/scenario_test/route_server_malformed_test.py15
-rw-r--r--test/scenario_test/route_server_policy_grpc_test.py22
-rw-r--r--test/scenario_test/route_server_policy_test.py24
-rw-r--r--test/scenario_test/route_server_softreset_test.py11
-rw-r--r--test/scenario_test/route_server_test.py20
-rw-r--r--test/scenario_test/route_server_test2.py11
-rw-r--r--test/scenario_test/rtc_test.py7
-rwxr-xr-xtest/scenario_test/run_all_tests.sh36
-rw-r--r--test/scenario_test/vrf_neighbor_test.py7
-rw-r--r--test/scenario_test/vrf_neighbor_test2.py6
-rw-r--r--test/scenario_test/zapi_v3_test.py7
41 files changed, 335 insertions, 334 deletions
diff --git a/.travis.yml b/.travis.yml
index 014372d2..9cb5c7d4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@ _node_js: &_node_js
_python: &_python
language: python
- python: "2.7"
+ python: "3.6"
_docker: &_docker
<<: *_python
@@ -30,10 +30,10 @@ _docker: &_docker
- test $TRAVIS_OS_NAME == "linux" && sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
- test $TRAVIS_OS_NAME == "linux" && sudo sysctl -w net.ipv6.conf.docker0.disable_ipv6=1
install:
- - pip install -r test/pip-requires.txt
- - fab -f test/lib/base.py make_gobgp_ctn:tag=$DOCKER_IMAGE,from_image=$FROM_IMAGE
+ - pip3 install -r test/pip-requires.txt
+ - fab -r test/lib make-gobgp-ctn --tag $DOCKER_IMAGE --from-image $FROM_IMAGE
script:
- - PYTHONPATH=test python test/scenario_test/$TEST --gobgp-image $DOCKER_IMAGE -x -s
+ - PYTHONPATH=test python3 test/scenario_test/$TEST --gobgp-image $DOCKER_IMAGE -x -s
services:
- docker
diff --git a/test/lib/bagpipe.py b/test/lib/bagpipe.py
index efca1c4e..43e1dcc0 100644
--- a/test/lib/bagpipe.py
+++ b/test/lib/bagpipe.py
@@ -13,14 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
-
-from fabric import colors
-from fabric.api import local
from lib.base import (
BGPContainer,
CmdBuffer,
+ yellow,
+ local,
)
@@ -49,7 +47,7 @@ class BagpipeContainer(BGPContainer):
c << '[BGP]'
if len(self.ip_addrs) > 0:
c << 'local_address={0}'.format(self.ip_addrs[0][1].split('/')[0])
- for info in self.peers.values():
+ for info in list(self.peers.values()):
c << 'peers={0}'.format(info['neigh_addr'].split('/')[0])
c << 'my_as={0}'.format(self.asn)
c << 'enable_rtc=True'
@@ -62,7 +60,7 @@ class BagpipeContainer(BGPContainer):
c << 'dataplane_driver = DummyDataplaneDriver'
with open('{0}/bgp.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow(str(c))
+ print(yellow(str(c)))
f.writelines(str(c))
def reload_config(self):
diff --git a/test/lib/base.py b/test/lib/base.py
index 6ae99e4c..da0ff489 100644
--- a/test/lib/base.py
+++ b/test/lib/base.py
@@ -13,21 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
import os
import time
import itertools
-from fabric.api import local, lcd
-from fabric import colors
-from fabric.state import env, output
+from invoke import run
+
+import textwrap
+from colored import fg, attr
+
try:
from docker import Client
except ImportError:
from docker import APIClient as Client
import netaddr
+
DEFAULT_TEST_PREFIX = ''
DEFAULT_TEST_BASE_DIR = '/tmp/gobgp'
TEST_PREFIX = DEFAULT_TEST_PREFIX
@@ -82,8 +84,19 @@ FLOWSPEC_NAME_TO_TYPE = {
TEST_CONTAINER_LABEL = 'gobgp-test'
TEST_NETWORK_LABEL = TEST_CONTAINER_LABEL
-env.abort_exception = RuntimeError
-output.stderr = False
+
+def local(s, capture=False):
+ print('[localhost] local:', s)
+ _env = {'NOSE_NOLOGCAPTURE': '1' if capture else '0'}
+ return run(s, hide=True, env=_env).stdout.strip()
+
+
+def yellow(s):
+ return fg('yellow') + str(s) + attr('reset')
+
+
+def indent(s):
+ return textwrap.indent(str(s), ' '*4, lambda line: True)
def community_str(i):
@@ -158,27 +171,6 @@ class CmdBuffer(list):
return self.delim.join(self)
-def make_gobgp_ctn(tag='gobgp', local_gobgp_path='', from_image='osrg/quagga'):
- if local_gobgp_path == '':
- local_gobgp_path = os.getcwd()
-
- c = CmdBuffer()
- c << 'FROM {0}'.format(from_image)
- c << 'ENV GO111MODULE on'
- c << 'ADD gobgp /tmp/gobgp'
- c << 'RUN cd /tmp/gobgp && go install ./cmd/gobgpd ./cmd/gobgp'
-
- rindex = local_gobgp_path.rindex('gobgp')
- if rindex < 0:
- raise Exception('{0} seems not gobgp dir'.format(local_gobgp_path))
-
- workdir = local_gobgp_path[:rindex]
- with lcd(workdir):
- local('echo \'{0}\' > Dockerfile'.format(str(c)))
- local('docker build -t {0} .'.format(tag))
- local('rm Dockerfile')
-
-
class Bridge(object):
def __init__(self, name, subnet='', with_ip=True, self_ip=False):
self.name = name
@@ -222,7 +214,7 @@ class Bridge(object):
capture=True)
def next_ip_address(self):
- return "{0}/{1}".format(self._ip_generator.next(),
+ return "{0}/{1}".format(next(self._ip_generator),
self.subnet.prefixlen)
def addif(self, ctn, ip_addr=''):
@@ -234,7 +226,7 @@ class Bridge(object):
if self.subnet.version == 6:
ip = '--ip6 {0}'.format(ip_addr)
local("docker network connect {0} {1} {2}".format(ip, self.name, ctn.docker_name()))
- i = [x for x in Client(timeout=60, version='auto').inspect_network(self.id)['Containers'].values() if x['Name'] == ctn.docker_name()][0]
+ i = [x for x in list(Client(timeout=60, version='auto').inspect_network(self.id)['Containers'].values()) if x['Name'] == ctn.docker_name()][0]
if self.subnet.version == 4:
eth = 'eth{0}'.format(len(ctn.ip_addrs))
addr = i['IPv4Address']
@@ -302,7 +294,7 @@ class Container(object):
def pipework(self, bridge, ip_addr, intf_name=""):
if not self.is_running:
- print colors.yellow('call run() before pipeworking')
+ print(yellow('call run() before pipeworking'))
return
c = CmdBuffer(' ')
c << "pipework {0}".format(bridge.name)
@@ -460,7 +452,7 @@ class BGPContainer(Container):
def _extract_routes(self, families):
routes = {}
- for prefix, paths in self.routes.items():
+ for prefix, paths in list(self.routes.items()):
if paths and paths[0]['rf'] in families:
routes[prefix] = paths
return routes
@@ -550,7 +542,7 @@ class BGPContainer(Container):
count = 0
while True:
res = self.local(cmd, capture=True)
- print colors.yellow(res)
+ print(yellow(res))
if ('1 packets received' in res or '1 received' in res) and '0% packet loss' in res:
break
time.sleep(interval)
@@ -564,10 +556,9 @@ class BGPContainer(Container):
count = 0
while True:
state = self.get_neighbor_state(peer)
- y = colors.yellow
- print y("{0}'s peer {1} state: {2}".format(self.router_id,
- peer.router_id,
- state))
+ print(yellow("{0}'s peer {1} state: {2}".format(self.router_id,
+ peer.router_id,
+ state)))
if state == expected_state:
return
diff --git a/test/lib/bird.py b/test/lib/bird.py
index 9f210bcf..b2afb66a 100644
--- a/test/lib/bird.py
+++ b/test/lib/bird.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 time
-from fabric import colors
-from fabric.api import local
-from fabric.utils import indent
+import time
from lib.base import (
BGPContainer,
CmdBuffer,
try_several_times,
wait_for_completion,
+ yellow,
+ indent,
+ local,
)
@@ -64,7 +63,7 @@ class BirdContainer(BGPContainer):
def create_config(self):
c = CmdBuffer()
c << 'router id {0};'.format(self.router_id)
- for peer, info in self.peers.iteritems():
+ for peer, info in self.peers.items():
c << 'protocol bgp {'
c << ' local as {0};'.format(self.asn)
n_addr = info['neigh_addr'].split('/')[0]
@@ -73,8 +72,8 @@ class BirdContainer(BGPContainer):
c << '}'
with open('{0}/bird.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new bird.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
+ print(yellow('[{0}\'s new bird.conf]'.format(self.name)))
+ print(yellow(indent(str(c))))
f.writelines(str(c))
def reload_config(self):
@@ -122,6 +121,6 @@ class RawBirdContainer(BirdContainer):
def create_config(self):
with open('{0}/bird.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new bird.conf]'.format(self.name))
- print colors.yellow(indent(self.config))
+ print(yellow('[{0}\'s new bird.conf]'.format(self.name)))
+ print(yellow(indent(self.config)))
f.writelines(self.config)
diff --git a/test/lib/exabgp.py b/test/lib/exabgp.py
index 1326dd86..ad129e87 100644
--- a/test/lib/exabgp.py
+++ b/test/lib/exabgp.py
@@ -13,15 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
-
-from fabric import colors
from lib.base import (
BGPContainer,
CmdBuffer,
try_several_times,
wait_for_completion,
+ yellow,
)
@@ -68,7 +66,7 @@ class ExaBGPContainer(BGPContainer):
# Manpage of exabgp.conf(5):
# https://github.com/Exa-Networks/exabgp/blob/master/doc/man/exabgp.conf.5
cmd = CmdBuffer('\n')
- for peer, info in self.peers.iteritems():
+ for peer, info in self.peers.items():
cmd << 'neighbor {0} {{'.format(info['neigh_addr'].split('/')[0])
cmd << ' router-id {0};'.format(self.router_id)
cmd << ' local-address {0};'.format(info['local_addr'].split('/')[0])
@@ -94,8 +92,8 @@ class ExaBGPContainer(BGPContainer):
cmd << '}'
with open('{0}/exabgpd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new exabgpd.conf]'.format(self.name))
- print colors.yellow(str(cmd))
+ print(yellow('[{0}\'s new exabgpd.conf]'.format(self.name)))
+ print(yellow(str(cmd)))
f.write(str(cmd))
def _is_running(self):
@@ -306,6 +304,6 @@ class RawExaBGPContainer(ExaBGPContainer):
def create_config(self):
with open('{0}/exabgpd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new exabgpd.conf]'.format(self.name))
- print colors.yellow(self.config)
+ print(yellow('[{0}\'s new exabgpd.conf]'.format(self.name)))
+ print(yellow(self.config))
f.write(self.config)
diff --git a/test/lib/fabfile.py b/test/lib/fabfile.py
new file mode 100644
index 00000000..c50b7e22
--- /dev/null
+++ b/test/lib/fabfile.py
@@ -0,0 +1,28 @@
+import os
+from fabric import task
+from invoke import run as local
+from base import CmdBuffer
+
+
+@task
+def make_gobgp_ctn(ctx, tag='gobgp',
+ local_gobgp_path='',
+ from_image='osrg/quagga'):
+ if local_gobgp_path == '':
+ local_gobgp_path = os.getcwd()
+
+ c = CmdBuffer()
+ c << 'FROM {0}'.format(from_image)
+ c << 'ENV GO111MODULE on'
+ c << 'ADD gobgp /tmp/gobgp'
+ c << 'RUN cd /tmp/gobgp && go install ./cmd/gobgpd ./cmd/gobgp'
+
+ rindex = local_gobgp_path.rindex('gobgp')
+ if rindex < 0:
+ raise Exception('{0} seems not gobgp dir'.format(local_gobgp_path))
+
+ workdir = local_gobgp_path[:rindex]
+ os.chdir(workdir)
+ local('echo \'{0}\' > Dockerfile'.format(str(c)))
+ local('docker build -t {0} .'.format(tag))
+ local('rm Dockerfile')
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index 9dbb4b90..9384fd2a 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
+
import collections
import json
@@ -22,9 +22,6 @@ from threading import Thread
import subprocess
import os
-from fabric import colors
-from fabric.api import local
-from fabric.utils import indent
import netaddr
import toml
import yaml
@@ -45,6 +42,9 @@ from lib.base import (
BGP_FSM_IDLE,
BGP_FSM_ACTIVE,
BGP_FSM_ESTABLISHED,
+ yellow,
+ indent,
+ local,
)
@@ -111,8 +111,7 @@ class GoBGPContainer(BGPContainer):
c << '#!/bin/sh'
c << '/go/bin/gobgpd -f {0}/gobgpd.conf -l {1} -p {2} -t {3} > ' \
'{0}/gobgpd.log 2>&1'.format(self.SHARED_VOLUME, self.log_level, '-r' if graceful_restart else '', self.config_format)
-
- cmd = 'echo "{0:s}" > {1}/start.sh'.format(c, self.config_dir)
+ cmd = 'echo "{0:s}" > {1}/start.sh'.format(str(c), self.config_dir)
local(cmd, capture=True)
cmd = "chmod 755 {0}/start.sh".format(self.config_dir)
local(cmd, capture=True)
@@ -212,7 +211,7 @@ class GoBGPContainer(BGPContainer):
def _get_rib(self, dests_dict):
dests = []
- for k, v in dests_dict.items():
+ for k, v in list(dests_dict.items()):
for p in v:
p["nexthop"] = self._get_nexthop(p)
p["aspath"] = self._get_as_path(p)
@@ -282,7 +281,7 @@ class GoBGPContainer(BGPContainer):
adj_type,
prefix, rf)
output = self.local(cmd, capture=True)
- ret = [p[0] for p in json.loads(output).itervalues()]
+ ret = [p[0] for p in json.loads(output).values()]
for p in ret:
p["nexthop"] = self._get_nexthop(p)
p["aspath"] = self._get_as_path(p)
@@ -313,7 +312,7 @@ class GoBGPContainer(BGPContainer):
def clear_policy(self):
self.policies = {}
- for info in self.peers.itervalues():
+ for info in self.peers.values():
info['policies'] = {}
self.prefix_set = []
self.neighbor_set = []
@@ -352,7 +351,7 @@ class GoBGPContainer(BGPContainer):
self._create_config_ospfd()
def _merge_dict(self, dct, merge_dct):
- for k, v in merge_dct.iteritems():
+ for k, v in merge_dct.items():
if (k in dct and isinstance(dct[k], dict)
and isinstance(merge_dct[k], collections.Mapping)):
self._merge_dict(dct[k], merge_dct[k])
@@ -380,7 +379,7 @@ class GoBGPContainer(BGPContainer):
if self.zebra and self.zapi_version == 2:
config['global']['use-multiple-paths'] = {'config': {'enabled': True}}
- for peer, info in self.peers.iteritems():
+ for peer, info in self.peers.items():
afi_safi_list = []
if info['interface'] != '':
afi_safi_list.append({'config': {'afi-safi-name': 'ipv4-unicast'}})
@@ -481,7 +480,7 @@ class GoBGPContainer(BGPContainer):
if len(info.get('default-policy', [])) + len(info.get('policies', [])) > 0:
n['apply-policy'] = {'config': {}}
- for typ, p in info.get('policies', {}).iteritems():
+ for typ, p in info.get('policies', {}).items():
n['apply-policy']['config']['{0}-policy-list'.format(typ)] = [p['name']]
def _f(v):
@@ -491,7 +490,7 @@ class GoBGPContainer(BGPContainer):
return 'accept-route'
raise Exception('invalid default policy type {0}'.format(v))
- for typ, d in info.get('default-policy', {}).iteritems():
+ for typ, d in info.get('default-policy', {}).items():
n['apply-policy']['config']['default-{0}-policy'.format(typ)] = _f(d)
if info['treat_as_withdraw']:
@@ -510,7 +509,7 @@ class GoBGPContainer(BGPContainer):
config['defined-sets']['bgp-defined-sets'] = self.bgp_set
policy_list = []
- for p in self.policies.itervalues():
+ for p in self.policies.values():
policy = {'name': p['name']}
if 'statements' in p:
policy['statements'] = p['statements']
@@ -525,7 +524,7 @@ class GoBGPContainer(BGPContainer):
'version': self.zapi_version}}
with open('{0}/gobgpd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new gobgpd.conf]'.format(self.name))
+ print(yellow('[{0}\'s new gobgpd.conf]'.format(self.name)))
if self.config_format is 'toml':
raw = toml.dumps(config)
elif self.config_format is 'yaml':
@@ -534,7 +533,8 @@ class GoBGPContainer(BGPContainer):
raw = json.dumps(config)
else:
raise Exception('invalid config_format {0}'.format(self.config_format))
- print colors.yellow(indent(raw))
+ raw = raw.strip()
+ print(yellow(indent(raw)))
f.write(raw)
def _create_config_zebra(self):
@@ -549,9 +549,10 @@ class GoBGPContainer(BGPContainer):
c << ''
with open('{0}/zebra.conf'.format(self.quagga_config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new zebra.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
- f.writelines(str(c))
+ print(yellow('[{0}\'s new zebra.conf]'.format(self.name)))
+ c = str(c).strip()
+ print(yellow(indent(c)))
+ f.writelines(c)
def _create_config_ospfd(self):
c = CmdBuffer()
@@ -560,14 +561,14 @@ class GoBGPContainer(BGPContainer):
c << 'router ospf'
for redistribute in self.ospfd_config.get('redistributes', []):
c << ' redistribute {0}'.format(redistribute)
- for network, area in self.ospfd_config.get('networks', {}).items():
+ for network, area in list(self.ospfd_config.get('networks', {}).items()):
c << ' network {0} area {1}'.format(network, area)
c << 'log file {0}/ospfd.log'.format(self.QUAGGA_VOLUME)
c << ''
with open('{0}/ospfd.conf'.format(self.quagga_config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new ospfd.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
+ print(yellow('[{0}\'s new ospfd.conf]'.format(self.name)))
+ print(yellow(indent(str(c))))
f.writelines(str(c))
def reload_config(self):
@@ -671,6 +672,6 @@ class RawGoBGPContainer(GoBGPContainer):
def create_config(self):
with open('{0}/gobgpd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new gobgpd.conf]'.format(self.name))
- print colors.yellow(indent(self.config))
+ print(yellow('[{0}\'s new gobgpd.conf]'.format(self.name)))
+ print(yellow(indent(self.config)))
f.write(self.config)
diff --git a/test/lib/quagga.py b/test/lib/quagga.py
index 4f24c784..52ef8c33 100644
--- a/test/lib/quagga.py
+++ b/test/lib/quagga.py
@@ -13,12 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
-import re
-from fabric import colors
-from fabric.utils import indent
+import re
import netaddr
from lib.base import (
@@ -31,6 +28,8 @@ from lib.base import (
BGP_FSM_ESTABLISHED,
BGP_ATTR_TYPE_MULTI_EXIT_DISC,
BGP_ATTR_TYPE_LOCAL_PREF,
+ yellow,
+ indent,
)
@@ -188,7 +187,7 @@ class QuaggaBGPContainer(BGPContainer):
c << 'password zebra'
c << 'router bgp {0}'.format(self.asn)
c << 'bgp router-id {0}'.format(self.router_id)
- if any(info['graceful_restart'] for info in self.peers.itervalues()):
+ if any(info['graceful_restart'] for info in self.peers.values()):
c << 'bgp graceful-restart'
if 'global' in self.bgpd_config:
@@ -198,7 +197,7 @@ class QuaggaBGPContainer(BGPContainer):
c << 'bgp confederation peers {0}'.format(' '.join([str(i) for i in conf['member-as-list']]))
version = 4
- for peer, info in self.peers.iteritems():
+ for peer, info in self.peers.items():
version = netaddr.IPNetwork(info['neigh_addr']).version
n_addr = info['neigh_addr'].split('/')[0]
if version == 6:
@@ -208,7 +207,7 @@ class QuaggaBGPContainer(BGPContainer):
c << 'neighbor {0} advertisement-interval 1'.format(n_addr)
if info['is_rs_client']:
c << 'neighbor {0} route-server-client'.format(n_addr)
- for typ, p in info['policies'].iteritems():
+ for typ, p in info['policies'].items():
c << 'neighbor {0} route-map {1} {2}'.format(n_addr, p['name'],
typ)
if info['passwd']:
@@ -228,7 +227,7 @@ class QuaggaBGPContainer(BGPContainer):
else:
c << 'redistribute connected'
- for name, policy in self.policies.iteritems():
+ for name, policy in self.policies.items():
c << 'access-list {0} {1} {2}'.format(name, policy['type'],
policy['match'])
c << 'route-map {0} permit 10'.format(name)
@@ -242,8 +241,8 @@ class QuaggaBGPContainer(BGPContainer):
c << 'log file {0}/bgpd.log'.format(self.SHARED_VOLUME)
with open('{0}/bgpd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new bgpd.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
+ print(yellow('[{0}\'s new bgpd.conf]'.format(self.name)))
+ print(yellow(indent(str(c))))
f.writelines(str(c))
def _create_config_zebra(self):
@@ -258,9 +257,10 @@ class QuaggaBGPContainer(BGPContainer):
c << ''
with open('{0}/zebra.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new zebra.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
- f.writelines(str(c))
+ print(yellow('[{0}\'s new zebra.conf]'.format(self.name)))
+ c = str(c).strip()
+ print(yellow(indent(c)))
+ f.writelines(c)
def vtysh(self, cmd, config=True):
if not isinstance(cmd, list):
@@ -420,8 +420,8 @@ class RawQuaggaBGPContainer(QuaggaBGPContainer):
def create_config(self):
with open('{0}/bgpd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new bgpd.conf]'.format(self.name))
- print colors.yellow(indent(self.config))
+ print(yellow('[{0}\'s new bgpd.conf]'.format(self.name)))
+ print(yellow(indent(self.config)))
f.writelines(self.config)
@@ -478,7 +478,7 @@ class QuaggaOSPFContainer(OSPFContainer):
c = CmdBuffer()
c << 'hostname zebra'
c << 'password zebra'
- for name, settings in self.zebra_config.get('interfaces', {}).items():
+ for name, settings in list(self.zebra_config.get('interfaces', {}).items()):
c << 'interface {0}'.format(name)
for setting in settings:
c << str(setting)
@@ -492,9 +492,10 @@ class QuaggaOSPFContainer(OSPFContainer):
c << ''
with open('{0}/zebra.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new zebra.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
- f.writelines(str(c))
+ print(yellow('[{0}\'s new zebra.conf]'.format(self.name)))
+ c = str(c).strip()
+ print(yellow(indent(c)))
+ f.writelines(c)
def _create_config_ospfd(self):
c = CmdBuffer()
@@ -503,15 +504,15 @@ class QuaggaOSPFContainer(OSPFContainer):
c << 'router ospf'
for redistribute in self.ospfd_config.get('redistributes', []):
c << ' redistribute {0}'.format(redistribute)
- for network, area in self.ospfd_config.get('networks', {}).items():
+ for network, area in list(self.ospfd_config.get('networks', {}).items()):
self.networks[network] = area # for superclass
c << ' network {0} area {1}'.format(network, area)
c << 'log file {0}/ospfd.log'.format(self.SHARED_VOLUME)
c << ''
with open('{0}/ospfd.conf'.format(self.config_dir), 'w') as f:
- print colors.yellow('[{0}\'s new ospfd.conf]'.format(self.name))
- print colors.yellow(indent(str(c)))
+ print(yellow('[{0}\'s new ospfd.conf]'.format(self.name)))
+ print(yellow(indent(str(c))))
f.writelines(str(c))
def _start_zebra(self):
diff --git a/test/lib/yabgp.py b/test/lib/yabgp.py
index fb13620b..0f06c306 100644
--- a/test/lib/yabgp.py
+++ b/test/lib/yabgp.py
@@ -13,22 +13,21 @@
# 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 json
import os
-from fabric import colors
-from fabric.api import local
-from fabric.utils import indent
-
from lib.base import (
FLOWSPEC_NAME_TO_TYPE,
BGPContainer,
CmdBuffer,
try_several_times,
wait_for_completion,
+ yellow,
+ indent,
+ local,
)
@@ -47,7 +46,7 @@ class YABGPContainer(BGPContainer):
import lib
mod_dir = os.path.dirname(lib.__file__)
local('docker cp {0}/yabgp_helper.py'
- ' {1}:/root/'.format(mod_dir, self.name))
+ ' {1}:/root/'.format(mod_dir, self.docker_name()))
def _start_yabgp(self):
self.local(
@@ -80,7 +79,7 @@ class YABGPContainer(BGPContainer):
c << 'format = json'
if self.peers:
- info = next(iter(self.peers.values()))
+ info = next(iter(list(self.peers.values())))
remote_as = info['remote_as']
neigh_addr = info['neigh_addr'].split('/')[0]
local_as = info['local_as'] or self.asn
@@ -93,8 +92,8 @@ class YABGPContainer(BGPContainer):
c << 'local_addr = {0}'.format(local_addr)
with open('{0}/yabgp.ini'.format(self.config_dir), 'w') as f:
- print(colors.yellow('[{0}\'s new yabgp.ini]'.format(self.name)))
- print(colors.yellow(indent(str(c))))
+ print(yellow('[{0}\'s new yabgp.ini]'.format(self.name)))
+ print(yellow(indent(str(c))))
f.writelines(str(c))
def reload_config(self):
@@ -401,7 +400,7 @@ class YABGPContainer(BGPContainer):
local_pref=None, identifier=None, reload_config=True):
self.routes.setdefault(route, [])
- for info in self.peers.values():
+ for info in list(self.peers.values()):
peer = info['neigh_addr'].split('/')[0]
if rf in ['ipv4', 'ipv6']:
@@ -449,7 +448,7 @@ class YABGPContainer(BGPContainer):
return
rf = withdraw['rf']
- for info in self.peers.values():
+ for info in list(self.peers.values()):
peer = info['neigh_addr'].split('/')[0]
if rf in ['ipv4', 'ipv6']:
diff --git a/test/lib/yabgp_helper.py b/test/lib/yabgp_helper.py
index 287daeaa..e13a312f 100644
--- a/test/lib/yabgp_helper.py
+++ b/test/lib/yabgp_helper.py
@@ -1,7 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
-from __future__ import absolute_import
-from __future__ import print_function
import json
import logging
diff --git a/test/pip-requires.txt b/test/pip-requires.txt
index 8b9dbd9a..965ccdd3 100644
--- a/test/pip-requires.txt
+++ b/test/pip-requires.txt
@@ -1,8 +1,10 @@
nose
toml
pyyaml
-fabric<2.0.0
+fabric
netaddr
nsenter
docker-py
ryu
+colored
+invoke
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()],