refactor: extract rm_containers helper

cherry-picked from #898
This commit is contained in:
Matthias Radestock committed 2015-06-15 21:41:43 +01:00
1 parent cba1827d2c
commit ee61f07d9b
3 files changed
+9 -4

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ DOPTS="--name=c2 -h $NAME"
check() {
assert_dns_record $HOST1 c1 $NAME $C2
docker_on $HOST1 rm -f c2 >/dev/null
rm_containers $HOST1 c2
assert_no_dns_record $HOST1 c1 $NAME
}
+1 -1
View File
@@ -17,7 +17,7 @@ assert_expected_fqdn() {
shift
start_container_with_dns $HOST1 "$@"
assert "docker_inspect_fqdn $HOST1 $NAME" $EXPECTED_FQDN
docker_on $HOST1 rm -f $NAME >/dev/null
rm_containers $HOST1 $NAME
}
start_suite "Use container name as hostname"
+7 -2
View File
@@ -111,6 +111,12 @@ start_container_with_dns() {
weave_on $host run --with-dns "$@" -t $DNS_IMAGE /bin/sh
}
rm_containers() {
host=$1
shift
[ $# -eq 0 ] || docker_on $host rm -f "$@" >/dev/null
}
container_ip() {
weave_on $1 ps $2 | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
}
@@ -155,8 +161,7 @@ assert_dns_ptr_record() {
start_suite() {
for host in $HOST1 $HOST2; do
[ -z "$DEBUG" ] || echo "Cleaning up on $host: removing all containers and resetting weave"
containers=$(docker_on $host ps -aq 2>/dev/null)
[ -n "$containers" ] && docker_on $host rm -f $containers >/dev/null 2>&1
rm_containers $host $(docker_on $host ps -aq 2>/dev/null)
weave_on $host reset 2>/dev/null
done
whitely echo "$@"