summaryrefslogtreecommitdiffhomepage
path: root/test/lib/yabgp.py
diff options
context:
space:
mode:
authorFranza Cavalcante <franza.cavalcante@bestateless.com>2019-06-20 16:46:18 -0600
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-06-22 19:53:11 +0900
commit8c90684b276d994d09b3dc0d5a030900bbb39929 (patch)
tree4fd885a311aaf800fcf7527ec06f9effd072fedb /test/lib/yabgp.py
parent7c2f0967afba5e91e0ad1c76e9f71c4f578d5844 (diff)
Python3 support to gobgp tests
This PR removes dependencies on old Fabric version, as it's not supported by Python3. The current Fabric versions don't support the colors and indent used previously, so we found substitute methods from other libraries and defined these in the library files. The local function from fabric is now just a wrapper to invoke's run function. All the files were processed through 2to3 command. All the tests were executed and we don't see any difference on the outputs when running Python2 or Python3. The creation of gobgp container is removed from base.py into fabfile.py, in order to comply with Fabric2 changes and simplify dependencies.
Diffstat (limited to 'test/lib/yabgp.py')
-rw-r--r--test/lib/yabgp.py23
1 files changed, 11 insertions, 12 deletions
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']: