summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-03-30 15:18:43 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-04-17 23:05:59 +0900
commit47ab84e34caeb7c89b26271bf84959011bc8ed19 (patch)
tree593380c833af9adbb14e2abf0a27337faf7b77f4 /test
parent616ae9f2cd960e9e7b49bbceee4a0424806b8ef2 (diff)
test/lib/gobgp: Use local GoBGP executables in contaier
Currently, to reflect the modification of the local source code or to switch the base image for GoBGP container, it is required to re-build the GoBGP container image, and this take a long time to test or debug with the scenario tests. This patch fixes to use the local GoBGP executables (gobgp and gobgpd) in container, and enables to reflect the changes without rebuidling container image. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/lib/base.py23
-rw-r--r--test/lib/gobgp.py8
-rw-r--r--test/scenario_test/README.md3
-rw-r--r--test/scenario_test/ci-scripts/jenkins-build-script.sh7
-rwxr-xr-xtest/scenario_test/ci-scripts/travis-build-script.sh2
-rwxr-xr-xtest/scenario_test/ci-scripts/travis-install-script.sh5
6 files changed, 16 insertions, 32 deletions
diff --git a/test/lib/base.py b/test/lib/base.py
index 4b4ff4ef..2618d720 100644
--- a/test/lib/base.py
+++ b/test/lib/base.py
@@ -97,29 +97,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 << 'ADD gobgp /go/src/github.com/osrg/gobgp/'
- c << 'RUN go get github.com/osrg/gobgp/gobgpd'
- c << 'RUN go install github.com/osrg/gobgp/gobgpd'
- c << 'RUN go get github.com/osrg/gobgp/gobgp'
- c << 'RUN go install github.com/osrg/gobgp/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
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index 14fbfe1f..0251a807 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -47,7 +47,8 @@ def extract_path_attribute(path, typ):
class GoBGPContainer(BGPContainer):
-
+ LOCAL_GOPATH = os.environ['GOPATH']
+ CONTAINER_GOPATH = '/go'
SHARED_VOLUME = '/root/shared_volume'
QUAGGA_VOLUME = '/etc/quagga'
@@ -56,6 +57,11 @@ class GoBGPContainer(BGPContainer):
zapi_version=2, ospfd_config=None):
super(GoBGPContainer, self).__init__(name, asn, router_id,
ctn_image_name)
+ # Add volume to export local GoBGP executables into container.
+ self.shared_volumes.append(
+ (self.LOCAL_GOPATH + '/bin/', self.CONTAINER_GOPATH + '/bin/'))
+
+ # Add volume to export config files into container.
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
self.log_level = log_level
diff --git a/test/scenario_test/README.md b/test/scenario_test/README.md
index f8d1364e..5663d936 100644
--- a/test/scenario_test/README.md
+++ b/test/scenario_test/README.md
@@ -77,7 +77,8 @@ 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
+$ go install ./gobgp/
+$ go install ./gobgpd/
```
## <a name="section3"> Run test
diff --git a/test/scenario_test/ci-scripts/jenkins-build-script.sh b/test/scenario_test/ci-scripts/jenkins-build-script.sh
index 6baf2193..64b14c63 100644
--- a/test/scenario_test/ci-scripts/jenkins-build-script.sh
+++ b/test/scenario_test/ci-scripts/jenkins-build-script.sh
@@ -33,11 +33,10 @@ do
done
sudo docker rmi $GOBGP_IMAGE
-sudo fab -f $GOBGP/test/lib/base.py make_gobgp_ctn:tag=$GOBGP_IMAGE
-[ "$?" != 0 ] && exit "$?"
-cd $GOBGP/gobgpd
-$GOROOT/bin/go get -v
+cd $GOBGP
+$GOROOT/bin/go get -v ./gobgp/
+$GOROOT/bin/go get -v ./gobgpd/
cd $GOBGP/test/scenario_test
./run_all_tests.sh
diff --git a/test/scenario_test/ci-scripts/travis-build-script.sh b/test/scenario_test/ci-scripts/travis-build-script.sh
index 4fd654db..1ed4e05e 100755
--- a/test/scenario_test/ci-scripts/travis-build-script.sh
+++ b/test/scenario_test/ci-scripts/travis-build-script.sh
@@ -2,4 +2,4 @@
echo "travis-build-script.sh"
-sudo PYTHONPATH=test python test/scenario_test/$TEST --gobgp-image $DOCKER_IMAGE -x -s
+PYTHONPATH=test python test/scenario_test/$TEST --gobgp-image $DOCKER_IMAGE -x -s
diff --git a/test/scenario_test/ci-scripts/travis-install-script.sh b/test/scenario_test/ci-scripts/travis-install-script.sh
index 5270ac21..72bdc79d 100755
--- a/test/scenario_test/ci-scripts/travis-install-script.sh
+++ b/test/scenario_test/ci-scripts/travis-install-script.sh
@@ -2,6 +2,7 @@
echo "travis-install-script.sh"
-sudo -H pip --quiet install -r test/pip-requires.txt
+pip --quiet install -r test/pip-requires.txt
-sudo fab -f test/lib/base.py make_gobgp_ctn:tag=$DOCKER_IMAGE,from_image=$FROM_IMAGE
+go get -v ./gobgp/
+go get -v ./gobgpd/