diff options
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/base.py | 23 | ||||
-rw-r--r-- | test/lib/gobgp.py | 8 |
2 files changed, 24 insertions, 7 deletions
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 |