From a7c9fd272c6328651658e46aeed232ef22ba4c57 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 22 Apr 2015 09:25:42 +0100 Subject: [PATCH] add exec_on helper so we don't repeat the remote docker invocation command (complete with hard-coded port) over and over again. --- test/100_cross_hosts_test.sh | 2 +- test/110_encryption_test.sh | 2 +- test/200_dns_test.sh | 4 ++-- test/210_dns_multicast_test.sh | 6 +++--- test/220_dns_custom_test.sh | 4 ++-- test/300_fallback_dns_test.sh | 4 ++-- test/400_weave_local_test.sh | 2 +- test/config.sh | 7 +++++++ 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/test/100_cross_hosts_test.sh b/test/100_cross_hosts_test.sh index ec1b1bd9..13789bbd 100755 --- a/test/100_cross_hosts_test.sh +++ b/test/100_cross_hosts_test.sh @@ -18,7 +18,7 @@ weave_on $HOST2 launch $HOST1 weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "ping -q -c 4 $C2 >&2 && echo ok") +ok=$(exec_on $HOST1 c1 ping -q -c 4 $C2 >&2 && echo ok) assert "echo $ok" "ok" end_suite diff --git a/test/110_encryption_test.sh b/test/110_encryption_test.sh index a70d4f37..79831acf 100755 --- a/test/110_encryption_test.sh +++ b/test/110_encryption_test.sh @@ -18,7 +18,7 @@ weave_on $HOST2 launch -password notverysecure $HOST1 weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "ping -q -c 4 $C2 >&2 && echo ok") +ok=$(exec_on $HOST1 c1 ping -q -c 4 $C2 >&2 && echo ok) assert "echo $ok" "ok" end_suite diff --git a/test/200_dns_test.sh b/test/200_dns_test.sh index d38dba84..045cdacc 100755 --- a/test/200_dns_test.sh +++ b/test/200_dns_test.sh @@ -16,10 +16,10 @@ docker_on $HOST1 rm -f c1 c2 || true weave_on $HOST1 run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "dig +short seetwo.weave.local") +ok=$(exec_on $HOST1 c1 dig +short seetwo.weave.local) assert "echo $ok" "$C2" -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "dig +short -x $C2") +ok=$(exec_on $HOST1 c1 dig +short -x $C2) assert "echo $ok" "seetwo.weave.local." end_suite diff --git a/test/210_dns_multicast_test.sh b/test/210_dns_multicast_test.sh index a296f276..2e72e262 100755 --- a/test/210_dns_multicast_test.sh +++ b/test/210_dns_multicast_test.sh @@ -22,13 +22,13 @@ weave_on $HOST2 launch-dns 10.2.254.2/24 -debug weave_on $HOST2 run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu weave_on $HOST1 run --with-dns $C1/24 --name=c1 -t aanand/docker-dnsutils /bin/sh -ok=$(docker -H tcp://$HOST1:2375 exec c1 dig +short seetwo.weave.local) +ok=$(exec_on $HOST1 c1 dig +short seetwo.weave.local) assert "echo $ok" "$C2" -ok=$(docker -H tcp://$HOST1:2375 exec c1 dig +short -x $C2) +ok=$(exec_on $HOST1 c1 dig +short -x $C2) assert "echo $ok" "seetwo.weave.local." -ok=$(docker -H tcp://$HOST1:2375 exec c1 dig +short -x 8.8.8.8) +ok=$(exec_on $HOST1 c1 dig +short -x 8.8.8.8) assert "test -n \"$ok\" && echo pass" "pass" end_suite diff --git a/test/220_dns_custom_test.sh b/test/220_dns_custom_test.sh index 9556584d..6ed56f04 100755 --- a/test/220_dns_custom_test.sh +++ b/test/220_dns_custom_test.sh @@ -16,10 +16,10 @@ docker_on $HOST1 rm -f c1 c2 || true weave_on $HOST1 run $C2/24 -t --name=c2 -h seetwo.foo.bar ubuntu weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "dig +short seetwo.foo.bar.") +ok=$(exec_on $HOST1 c1 dig +short seetwo.foo.bar.) assert "echo $ok" "$C2" -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "dig +short -x $C2") +ok=$(exec_on $HOST1 c1 dig +short -x $C2) assert "echo $ok" "seetwo.foo.bar." end_suite diff --git a/test/300_fallback_dns_test.sh b/test/300_fallback_dns_test.sh index 94e3a5b0..19e8cabd 100755 --- a/test/300_fallback_dns_test.sh +++ b/test/300_fallback_dns_test.sh @@ -10,10 +10,10 @@ docker_on $HOST1 rm -f c1 || true weave_on $HOST1 run --with-dns 10.2.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh -ok=$(docker -H tcp://$HOST1:2375 exec c1 dig +short -t MX weave.works) +ok=$(exec_on $HOST1 c1 dig +short -t MX weave.works) assert "test -n \"$ok\" && echo pass" "pass" -ok=$(docker -H tcp://$HOST1:2375 exec c1 dig +short -x 8.8.8.8) +ok=$(exec_on $HOST1 c1 dig +short -x 8.8.8.8) assert "test -n \"$ok\" && echo pass" "pass" end_suite diff --git a/test/400_weave_local_test.sh b/test/400_weave_local_test.sh index f8ce663e..2658a160 100755 --- a/test/400_weave_local_test.sh +++ b/test/400_weave_local_test.sh @@ -11,7 +11,7 @@ assert_raises "docker_on $HOST1 ps | grep weave" 0 docker_on $HOST1 rm -f c1 || true run_on $HOST1 sudo ./weave --local run 10.2.6.5/24 -ti --name=c1 ubuntu -ok=$(docker -H tcp://$HOST1:2375 exec c1 sh -c "ifconfig | grep ethwe") +ok=$(exec_on $HOST1 c1 ifconfig | grep ethwe) assert "test -n \"$ok\" && echo pass" "pass" docker_on $HOST1 rm -f c1 || true diff --git a/test/config.sh b/test/config.sh index 59743095..c20f55a6 100644 --- a/test/config.sh +++ b/test/config.sh @@ -57,6 +57,13 @@ weave_on() { DOCKER_HOST=tcp://$host:2375 $WEAVE $@ } +exec_on() { + host=$1 + container=$2 + shift 2 + docker -H tcp://$host:2375 exec $container "$@" +} + start_suite() { whitely echo $@ }