summaryrefslogtreecommitdiffstats
path: root/ctdb/tests/eventscripts/scripts
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-03-14 16:29:01 +1100
committerAmitay Isaacs <amitay@samba.org>2014-03-26 04:21:41 +0100
commit7fdd6b7861a4767cd3e2dfa76a7d7e7790efd840 (patch)
tree10a8bafc0f96e89d3df24e796cd7ec2f62ade3c7 /ctdb/tests/eventscripts/scripts
parentfeeb9843bf46d00beb10f3e959ba0f73f5e33e8c (diff)
ctdb-tests: Add some tests for 11.natgw eventscript
This includes adding support for: * Configuring fake NATGW state in the eventscript unit tests * "natgwlist" and "setnatgwstate" in ctdb command stub * ip command stub to default to "main table" when no table specified, allow routes to be added without "dev" option (just add a default dev), support "metric" option Signed-off-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/tests/eventscripts/scripts')
-rw-r--r--ctdb/tests/eventscripts/scripts/local.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh
index 85894a41b8..898405ce2a 100644
--- a/ctdb/tests/eventscripts/scripts/local.sh
+++ b/ctdb/tests/eventscripts/scripts/local.sh
@@ -505,6 +505,64 @@ EOF
######################################################################
+setup_ctdb_natgw ()
+{
+ debug "Setting up NAT gateway"
+
+ natgw_config_dir="${TEST_VAR_DIR}/natgw_config"
+ mkdir -p "$natgw_config_dir"
+
+ # These will accumulate, 1 per test... but will be cleaned up at
+ # the end.
+ export CTDB_NATGW_NODES=$(mktemp --tmpdir="$natgw_config_dir")
+
+ # Read from stdin
+ while read _ip _master _dev ; do
+ echo "$_ip"
+ if [ "$_master" = "master" ] ; then
+ export FAKE_CTDB_NATGW_MASTER="$_ip"
+ fi
+ done >"$CTDB_NATGW_NODES"
+
+ # Assume all of the nodes are on a /24 network and have IPv4
+ # addresses:
+ read _ip <"$CTDB_NATGW_NODES"
+ export CTDB_NATGW_PRIVATE_NETWORK="${_ip%.*}.0/24"
+
+ # These are fixed. Probably don't use the same network for the
+ # private node IPs. To unset the default gateway just set it to
+ # "". :-)
+ export CTDB_NATGW_PUBLIC_IP="10.1.1.121/24"
+ export CTDB_NATGW_PUBLIC_IFACE="eth1"
+ export CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
+}
+
+ok_natgw_master_ip_addr_show ()
+{
+ _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
+
+ # This is based on CTDB_NATGW_PUBLIC_IP
+ _brd="10.1.1.255"
+
+ok <<EOF
+1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
+ link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
+ inet ${CTDB_NATGW_PUBLIC_IP} brd ${_brd} scope global ${CTDB_NATGW_PUBLIC_IFACE}
+ valid_lft forever preferred_lft forever
+EOF
+}
+
+ok_natgw_slave_ip_addr_show ()
+{
+ _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
+ok <<EOF
+1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
+ link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
+EOF
+}
+
+######################################################################
+
# Samba/winbind fakery
setup_samba ()