summaryrefslogtreecommitdiffhomepage
path: root/test/lib/fabfile.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/fabfile.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/fabfile.py')
-rw-r--r--test/lib/fabfile.py28
1 files changed, 28 insertions, 0 deletions
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')