ctdb-tests: NAT gateway slave-only changes
authorMartin Schwenke <martin@meltin.net>
Fri, 22 Jan 2016 00:04:22 +0000 (11:04 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Jan 2016 06:18:25 +0000 (07:18 +0100)
Handle the "slave-only" option in the unit test setup.  Reindent
function while touching it.

Also drop a test that no longer makes sense.  Specifying both "master"
and "slave-only' is now much more obvious, since they need to be on
the same line, and is now punishable by undefined behaviour.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/11.natgw.005.sh [deleted file]
ctdb/tests/eventscripts/scripts/local.sh

diff --git a/ctdb/tests/eventscripts/11.natgw.005.sh b/ctdb/tests/eventscripts/11.natgw.005.sh
deleted file mode 100755 (executable)
index 074fcda..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "Inconsistent test setup: slave-only but current node is master"
-
-setup_ctdb
-setup_ctdb_natgw <<EOF
-192.168.1.21 master
-192.168.1.22
-192.168.1.23
-192.168.1.24
-EOF
-
-CTDB_NATGW_SLAVE_ONLY="yes"
-
-required_result 1 <<EOF
-Inconsistent test configuration - master node is slave-only
-There is no NATGW master node
-EOF
-
-for i in "ipreallocated" ; do
-    simple_test_event "$i"
-done
index 1dc64d633c5266fa2d5708352f3b3c30756aedf8..82ebc098d6f306881e6c28ce7529f13077d1ce90 100644 (file)
@@ -601,35 +601,43 @@ 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"
-    export CTDB_NATGW_SLAVE_ONLY=""
+       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 _opts ; do
+               case "$_opts" in
+               master)
+                       export FAKE_CTDB_NATGW_MASTER="$_ip"
+                       echo "$_ip"
+                       ;;
+               slave-only)
+                       printf "%s\tslave-only\n" "$_ip"
+                       ;;
+               *)
+                       echo "$_ip"
+                       ;;
+               esac
+       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"
+       export CTDB_NATGW_SLAVE_ONLY=""
 }
 
 ok_natgw_master_ip_addr_show ()