diff options
-rw-r--r-- | .travis.yml | 7 | ||||
-rw-r--r-- | test/lib/base.py | 23 | ||||
-rw-r--r-- | test/lib/gobgp.py | 8 | ||||
-rw-r--r-- | test/scenario_test/README.md | 3 | ||||
-rw-r--r-- | test/scenario_test/ci-scripts/jenkins-build-script.sh | 7 | ||||
-rwxr-xr-x | test/scenario_test/ci-scripts/travis-build-script.sh | 2 | ||||
-rwxr-xr-x | test/scenario_test/ci-scripts/travis-install-script.sh | 5 |
7 files changed, 36 insertions, 19 deletions
diff --git a/.travis.yml b/.travis.yml index 44082883..2373248e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,8 @@ script: test/scenario_test/ci-scripts/travis-build-script.sh env: global: - - DOCKER_IMAGE=osrg/quagga + - DOCKER_IMAGE=gobgp + - FROM_IMAGE=osrg/quagga matrix: allow_failures: @@ -72,7 +73,7 @@ matrix: services: - docker - env: - - TEST=bgp_zebra_nht_test.py DOCKER_IMAGE=osrg/quagga:v1.0 + - TEST=bgp_zebra_nht_test.py FROM_IMAGE=osrg/quagga:v1.0 sudo: required services: - docker @@ -147,7 +148,7 @@ matrix: services: - docker - env: - - TEST=zapi_v3_test.py DOCKER_IMAGE=osrg/quagga:v1.0 + - TEST=zapi_v3_test.py FROM_IMAGE=osrg/quagga:v1.0 sudo: required services: - docker diff --git a/test/lib/base.py b/test/lib/base.py index 2618d720..4b4ff4ef 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -97,6 +97,29 @@ 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 0251a807..14fbfe1f 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -47,8 +47,7 @@ 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' @@ -57,11 +56,6 @@ 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 df76a2e5..540f6628 100644 --- a/test/scenario_test/README.md +++ b/test/scenario_test/README.md @@ -77,8 +77,7 @@ You also need this operation at every modification to the source code. ```shell $ cd $GOPATH/src/github.com/osrg/gobgp -$ go install ./gobgp/ -$ go install ./gobgpd/ +$ sudo fab -f ./test/lib/base.py make_gobgp_ctn --set tag=gobgp ``` ## <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 64b14c63..6baf2193 100644 --- a/test/scenario_test/ci-scripts/jenkins-build-script.sh +++ b/test/scenario_test/ci-scripts/jenkins-build-script.sh @@ -33,10 +33,11 @@ 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 -$GOROOT/bin/go get -v ./gobgp/ -$GOROOT/bin/go get -v ./gobgpd/ +cd $GOBGP/gobgpd +$GOROOT/bin/go get -v 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 1ed4e05e..4fd654db 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" -PYTHONPATH=test python test/scenario_test/$TEST --gobgp-image $DOCKER_IMAGE -x -s +sudo 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 72bdc79d..5270ac21 100755 --- a/test/scenario_test/ci-scripts/travis-install-script.sh +++ b/test/scenario_test/ci-scripts/travis-install-script.sh @@ -2,7 +2,6 @@ echo "travis-install-script.sh" -pip --quiet install -r test/pip-requires.txt +sudo -H pip --quiet install -r test/pip-requires.txt -go get -v ./gobgp/ -go get -v ./gobgpd/ +sudo fab -f test/lib/base.py make_gobgp_ctn:tag=$DOCKER_IMAGE,from_image=$FROM_IMAGE |