From 42d2a860ebee3da7189378d06c8838778da27ef0 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 18 Jun 2015 17:48:21 +0100 Subject: [PATCH] test more things, more obviously --- test/500_weave_multi_cidr_test.sh | 39 ++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/test/500_weave_multi_cidr_test.sh b/test/500_weave_multi_cidr_test.sh index ef06c3ad..d40474dc 100755 --- a/test/500_weave_multi_cidr_test.sh +++ b/test/500_weave_multi_cidr_test.sh @@ -11,7 +11,11 @@ assert_container_cidrs() { CIDRS="$@" # Assert container has attached CIDRs - assert_raises "weave_on $HOST ps $CID | grep -E '^$CID [0-9a-f:]{17} $CIDRS$'" + if [ -z "$CIDRS" ] ; then + assert "weave_on $HOST ps $CID" "" + else + assert_raises "weave_on $HOST ps $CID | grep -E '^$CID [0-9a-f:]{17} $CIDRS$'" + fi } # assert_zone_records [ ...] @@ -40,7 +44,9 @@ assert_bridge_cidrs() { assert "echo $BRIDGE_CIDRS" "$CIDRS" } -start_suite "Weave run/start/attach/detach with multiple cidr arguments" +start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr arguments" + +# also check that these commands understand all address flavours # NOTE: in these tests, net: arguments are checked against a # specific address, i.e. we are assuming that IPAM always returns the @@ -54,22 +60,34 @@ CID=$(start_container $HOST1 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3. assert_container_cidrs $HOST1 $CID 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24 assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 10.2.2.1 10.2.3.1 +# Stop the container +docker_on $HOST1 stop $CID +assert_container_cidrs $HOST1 $CID +assert_zone_records $HOST1 $CID $NAME. + +# Restart with three IPs +weave_on $HOST1 start 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID +assert_container_cidrs $HOST1 $CID 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24 +assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 10.2.2.1 10.2.3.1 + # Remove two of them weave_on $HOST1 detach ip:10.2.2.1/24 net:10.2.3.0/24 $CID assert_container_cidrs $HOST1 $CID 10.2.1.1/24 assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 +# ...and the remaining one +weave_on $HOST1 detach 10.2.1.1/24 $CID +assert_container_cidrs $HOST1 $CID +assert_zone_records $HOST1 $CID $NAME. -# Put them both back +# Put one back +weave_on $HOST1 attach 10.2.1.1/24 $CID +assert_container_cidrs $HOST1 $CID 10.2.1.1/24 +assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 +# ...and the remaining two weave_on $HOST1 attach ip:10.2.2.1/24 net:10.2.3.0/24 $CID assert_container_cidrs $HOST1 $CID 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24 assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 10.2.2.1 10.2.3.1 -# Stop the container, restart with three IPs -docker_on $HOST1 stop $CID -weave_on $HOST1 start 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID -assert_container_cidrs $HOST1 $CID 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24 -assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 10.2.2.1 10.2.3.1 - # Expose three cidrs weave_on $HOST1 expose 10.2.1.2/24 ip:10.2.2.2/24 net:10.2.3.0/24 assert_bridge_cidrs $HOST1 weave 10.2.1.2/24 10.2.2.2/24 10.2.3.2/24 @@ -77,6 +95,9 @@ assert_bridge_cidrs $HOST1 weave 10.2.1.2/24 10.2.2.2/24 10.2.3. # Hide two of them weave_on $HOST1 hide ip:10.2.2.2/24 net:10.2.3.0/24 assert_bridge_cidrs $HOST1 weave 10.2.1.2/24 +# ...and the remaining one +weave_on $HOST1 hide 10.2.1.2/24 +assert_bridge_cidrs $HOST1 weave # Now detach and run another container to check we have released IPs in IPAM weave_on $HOST1 detach $CID