summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorImcom Jin <jinyu.bjut@gmail.com>2017-12-07 12:18:06 +0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-12-16 20:00:38 +0900
commit7b4ebf9be4b719d101593baccdb813d02c90ca02 (patch)
tree1862b50d88bd1105af150754d5f13c41be633a32
parent72740f758364d2eeefa5a7c71d8c2a1556fa2cc8 (diff)
use label for containers and networks in order to avoid colliding with others
-rw-r--r--test/lib/base.py10
-rw-r--r--test/scenario_test/README.md4
2 files changed, 9 insertions, 5 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")
diff --git a/test/scenario_test/README.md b/test/scenario_test/README.md
index 540f6628..a4ab549e 100644
--- a/test/scenario_test/README.md
+++ b/test/scenario_test/README.md
@@ -110,7 +110,7 @@ A lot of containers, networks temporary files are created during the test.
Let's clean up.
```shell
-$ sudo docker rm -f $(sudo docker ps -a -q)
-$ sudo docker network prune -f
+$ sudo docker rm -f $(sudo docker ps -a -q -f "label=gobgp-test")
+$ sudo docker network prune -f --filter "label=gobgp-test"
$ sudo rm -rf /tmp/gobgp
```