summaryrefslogtreecommitdiffstats
path: root/ctdb/tests/scripts
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-12-03 12:10:07 +1100
committerMartin Schwenke <martins@samba.org>2014-12-05 23:29:39 +0100
commita07af1bb56a76d1a7ab856547c801499fc17b21b (patch)
tree751f79cb0ded15fd97a169974ab6c91b3abea0ab /ctdb/tests/scripts
parent7f3f3b15d52c4047cbcb1c3e81f65675c8708f5f (diff)
downloadsamba-a07af1bb56a76d1a7ab856547c801499fc17b21b.tar.gz
samba-a07af1bb56a76d1a7ab856547c801499fc17b21b.tar.xz
samba-a07af1bb56a76d1a7ab856547c801499fc17b21b.zip
ctdb-tests: Need to drop public IPs in kill-failover tests
These tests simulate a dead node rather than a CTDB failure, so drop IP addresses when killing a "node" to avoid problems with duplicates. To cope with a CTDB failure a watchdog would be needed to ensure that the public IPs are dropped when CTDB dies. Let's not do that now. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Dec 5 23:29:39 CET 2014 on sn-devel-104
Diffstat (limited to 'ctdb/tests/scripts')
-rw-r--r--ctdb/tests/scripts/integration.bash38
1 files changed, 38 insertions, 0 deletions
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index 6bec78ef98..0d27c93643 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -687,6 +687,44 @@ nfs_test_cleanup ()
#######################################
+# If the given IP is hosted then print 2 items: maskbits and iface
+ip_maskbits_iface ()
+{
+ _addr="$1"
+
+ case "$_addr" in
+ *:*) _family="inet6" ; _bits=128 ;;
+ *) _family="inet" ; _bits=32 ;;
+ esac
+
+ ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
+ awk -v family="${_family}" \
+ 'NR == 1 { iface = gensub(":$", "", 1, $2) } \
+ $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
+}
+
+drop_ip ()
+{
+ _addr="${1%/*}" # Remove optional maskbits
+
+ set -- $(ip_maskbits_iface $_addr)
+ if [ -n "$1" ] ; then
+ _maskbits="$1"
+ _iface="$2"
+ echo "Removing public address $_addr/$_maskbits from device $_iface"
+ ip addr del "$_ip/$_maskbits" dev "$_iface" >/dev/null 2>&1 || true
+ fi
+}
+
+drop_ips ()
+{
+ for _ip ; do
+ drop_ip "$_ip"
+ done
+}
+
+#######################################
+
# $1: pnn, $2: DB name
db_get_path ()
{