diff options
author | Imcom Jin <jinyu.bjut@gmail.com> | 2017-12-07 12:18:06 +0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-16 20:00:38 +0900 |
commit | 7b4ebf9be4b719d101593baccdb813d02c90ca02 (patch) | |
tree | 1862b50d88bd1105af150754d5f13c41be633a32 /test/lib | |
parent | 72740f758364d2eeefa5a7c71d8c2a1556fa2cc8 (diff) |
use label for containers and networks in order to avoid colliding with others
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/base.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/lib/base.py b/test/lib/base.py index b0f66ec4..da3cf611 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -48,6 +48,10 @@ BGP_ATTR_TYPE_CLUSTER_LIST = 10 BGP_ATTR_TYPE_MP_REACH_NLRI = 14 BGP_ATTR_TYPE_EXTENDED_COMMUNITIES = 16 +# with this label, we can do filtering in `docker ps` and `docker network prune` +TEST_CONTAINER_LABEL = 'gobgp-test' +TEST_NETWORK_LABEL = TEST_CONTAINER_LABEL + env.abort_exception = RuntimeError output.stderr = False @@ -156,7 +160,7 @@ class Bridge(object): v6 = '' if self.subnet.version == 6: v6 = '--ipv6' - self.id = local('docker network create --driver bridge {0} --subnet {1} {2}'.format(v6, subnet, self.name), capture=True) + self.id = local('docker network create --driver bridge {0} --subnet {1} --label {2} {3}'.format(v6, subnet, TEST_NETWORK_LABEL, self.name), capture=True) try_several_times(f) self.self_ip = self_ip @@ -200,7 +204,7 @@ class Container(object): def docker_name(self): if TEST_PREFIX == DEFAULT_TEST_PREFIX: - return self.name + return '{0}'.format(self.name) return '{0}_{1}'.format(TEST_PREFIX, self.name) def next_if_name(self): @@ -213,7 +217,7 @@ class Container(object): c << "docker run --privileged=true" for sv in self.shared_volumes: c << "-v {0}:{1}".format(sv[0], sv[1]) - c << "--name {0} -id {1}".format(self.docker_name(), self.image) + c << "--name {0} -l {1} -id {2}".format(self.docker_name(), TEST_CONTAINER_LABEL, self.image) self.id = try_several_times(lambda: local(str(c), capture=True)) self.is_running = True self.local("ip li set up dev lo") |