ctdb-tests: 11.natgw event script setup modularisation
authorMartin Schwenke <martin@meltin.net>
Mon, 12 Feb 2018 00:42:04 +0000 (11:42 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Mar 2018 00:57:19 +0000 (02:57 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 files changed:
ctdb/tests/eventscripts/11.natgw.001.sh
ctdb/tests/eventscripts/11.natgw.002.sh
ctdb/tests/eventscripts/11.natgw.003.sh
ctdb/tests/eventscripts/11.natgw.004.sh
ctdb/tests/eventscripts/11.natgw.011.sh
ctdb/tests/eventscripts/11.natgw.012.sh
ctdb/tests/eventscripts/11.natgw.013.sh
ctdb/tests/eventscripts/11.natgw.014.sh
ctdb/tests/eventscripts/11.natgw.015.sh
ctdb/tests/eventscripts/11.natgw.021.sh
ctdb/tests/eventscripts/11.natgw.022.sh
ctdb/tests/eventscripts/11.natgw.023.sh
ctdb/tests/eventscripts/11.natgw.024.sh
ctdb/tests/eventscripts/11.natgw.025.sh
ctdb/tests/eventscripts/11.natgw.031.sh
ctdb/tests/eventscripts/11.natgw.041.sh
ctdb/tests/eventscripts/11.natgw.042.sh
ctdb/tests/eventscripts/11.natgw.051.sh
ctdb/tests/eventscripts/11.natgw.052.sh
ctdb/tests/eventscripts/11.natgw.053.sh
ctdb/tests/eventscripts/11.natgw.054.sh
ctdb/tests/eventscripts/scripts/11.natgw.sh

index afcc0972ddf6af97cec5a793b42cd3165a4b59ae..06b2cd39cee268c633c1d168360be723f3955fa4 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "not configured"
 
-setup_ctdb
+setup
 
 ok_null
 simple_test_event "ipreallocate"
index c9054068df417db6831276648737714766593a1f..5e3f2d3a224b97fa5d9298e167c5944d668c77e9 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "missing config file"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
 192.168.1.22
@@ -21,4 +22,3 @@ EOF
 for i in "startup" "ipreallocated" ; do
     simple_test_event "$i"
 done
-
index eb821dca48bd07e6f5a230de6edf2756df216cd9..2743b4f1df54a080bc336135e57915fe818fbd6f 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "CTDB_NATGW_PUBLIC_IFACE unset, not slave-only"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
 192.168.1.22
index 10bf22c711ac564d04cdf461ff8fbb4f94bafc61..5f1f816912e7c45661522becf70bb178c07ac99f 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "CTDB_NATGW_PUBLIC_IP unset, not slave-only"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
 192.168.1.22
index 4c5a937d553b50baca6a7d932535ec37a4659007..e8513c9f2e3e8106a4da04b3d36f30932ab6de5a 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "master node, basic configuration"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
index 6ec98a03f58401626b98f41900e701a560a2b47b..94cbe9d22b99dda1777172f0324e1e2467c07da5 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "slave node, basic configuration"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21
index 16f06221805863dfe3bd2b682a43b8d2c561a1ae..75823c3cc365f1379ce415fb98de5231475df739 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "master node, no gateway"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
index 462756c062dc87963e040e33158ee35531f50854..3df2fab8332764c4943146f2218ec043309e843f 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "slave node, no gateway"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21
index 691b363ef1bfc39e49418b74aadf164d353a4ced..dbe09d2efd18eae7c4256b61bc9c83aa96c3f5a4 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "basic configuration, multiple transitions"
 
-setup_ctdb
+setup
 
 echo "*** Master node..."
 
index 5786ea7e6484dd8d5b65ae11f279953b6c6c7487..fb9b167b79487a70636e3f9250b654bf8aa6e2ad 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "master node, static routes"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
@@ -13,7 +13,7 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24"
+CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24"
 
 ok_null
 simple_test_event "ipreallocated"
index 170ed8caf8418bfc8c9f5634d30316937c3374d9..bcdcd6acf6323cdffe63053ce60b68bff49ca6d2 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "slave node, static routes"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21
@@ -13,7 +13,7 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24"
+CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24"
 
 ok_null
 simple_test_event "ipreallocated"
index cf71c084797ee69fab80f13ec9de6ece7d49c7b0..ae341909d175630ba5f17da04fb4e8429f7d4c96 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "master node, static routes, custom gateway"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
@@ -13,7 +13,7 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
+CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
 
 ok_null
 simple_test_event "ipreallocated"
index 3d2aed5532df64d5da869ffaae5f1f93bb018e4e..5b1f201c8c3a7607c5a55ce2babc1a3b7ab1ac10 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "slave node, static routes, custom gateway"
 
-setup_ctdb
+setup
 
 setup_ctdb_natgw <<EOF
 192.168.1.21
@@ -13,7 +13,7 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
+CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
 
 ok_null
 simple_test_event "ipreallocated"
index 60602d3ead99ac1c0be11b237117e5510d880fec..05f56b52098c5846caa9cadcea0150de3c1f87ea 100755 (executable)
@@ -4,9 +4,9 @@
 
 define_test "static routes, custom gateway, multiple transitions"
 
-setup_ctdb
+setup
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
+CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
 
 echo "*** Master node..."
 
@@ -61,4 +61,3 @@ simple_test_command ip route show
 
 ok_natgw_master_ip_addr_show
 simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
-
index a8575a57937f850cfe8cd724abbdcc160a2a9cac..039930fa4ade85a15748b1dec216dc4dc7049c1e 100755 (executable)
@@ -4,9 +4,9 @@
 
 define_test "master node, static routes, custom gateway, config change"
 
-setup_ctdb
+setup
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
+CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
 
 echo "##################################################"
 echo "Static routes..."
@@ -30,7 +30,7 @@ simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
 echo "##################################################"
 echo "Default routes..."
 
-unset CTDB_NATGW_STATIC_ROUTES
+CTDB_NATGW_STATIC_ROUTES=""
 
 ok "NAT gateway configuration has changed"
 simple_test_event "ipreallocated"
@@ -44,7 +44,7 @@ simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
 echo "##################################################"
 echo "Static routes again..."
 
-export CTDB_NATGW_STATIC_ROUTES="10.1.3.0/24 10.1.4.4/32 10.1.2.0/24@10.1.1.252"
+CTDB_NATGW_STATIC_ROUTES="10.1.3.0/24 10.1.4.4/32 10.1.2.0/24@10.1.1.252"
 
 ok "NAT gateway configuration has changed"
 simple_test_event "ipreallocated"
index e8126e1b47cf3cb2fffb3a034f3a152f6035b5c5..d5cc44adce695ceb1a0ef6d25b83fc0e4c9e22cc 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "slave-only, CTDB_NATGW_PUBLIC_IFACE unset"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 slave-only
 192.168.1.22 master
index 001698cbf6978c44f50fe19bc9befedd73314331..17d98cb94527d26ed13d6c954d16cccf2a0f79a0 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "slave-only, CTDB_NATGW_PUBLIC_IP unset"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 slave-only
 192.168.1.22 master
index 8a385b6983909a8e832d5e68788ef834c92cb0ca..9bf8569607cb89d72ff8bff3a824e20d10b55e71 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, slave, up"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21
 192.168.1.22 master
index 091b6f6c1adad159da4d6e08ac0aba4ec3014caa..2d4a339cb9848c459064649f20a8535469c04f56 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, slave, down"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21
 192.168.1.22 master
index 7c51ec11e8a0bdb1c47bb21931f1386d13a35ef9..d9b173e8d22a27adb400ed64d677bfbfe2a1a5d5 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, master, up"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
 192.168.1.22
index 08b4b775593d0eae5b213371c20cbebec7516312..a2173f38fd355d06156ea18407aae08694429b18 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, master, down"
 
-setup_ctdb
+setup
+
 setup_ctdb_natgw <<EOF
 192.168.1.21 master
 192.168.1.22
index be255e6948a53dfa888f01fde743101b504dbe17..a11da431434d4616cab354f19b6d254f3e99ddaa 100644 (file)
@@ -1,12 +1,23 @@
-setup_ctdb_natgw ()
+setup ()
 {
        debug "Setting up NAT gateway"
 
-       natgw_config_dir="${TEST_VAR_DIR}/natgw_config"
-       mkdir -p "$natgw_config_dir"
+       natgw_nodes="${CTDB_BASE}/natgw_nodes"
+
+       ctdb_set_pnn
 
-       export CTDB_NATGW_NODES="${natgw_config_dir}/natgw_nodes"
+       export CTDB_NATGW_NODES=""
+       export CTDB_NATGW_PRIVATE_NETWORK=""
+       export CTDB_NATGW_PUBLIC_IP=""
+       export CTDB_NATGW_PUBLIC_IFACE=""
+       export CTDB_NATGW_DEFAULT_GATEWAY=""
+       export CTDB_NATGW_STATIC_ROUTES=""
+}
 
+# A separate function for this makes sense because it can be done
+# multiple times per test
+setup_ctdb_natgw ()
+{
        # Read from stdin
        while read _ip _opts ; do
                case "$_opts" in
@@ -21,20 +32,20 @@ setup_ctdb_natgw ()
                        echo "$_ip"
                        ;;
                esac
-       done >"$CTDB_NATGW_NODES"
+       done >"$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"
+       read _ip <"$natgw_nodes"
 
+       CTDB_NATGW_NODES="$natgw_nodes"
+       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=""
+       CTDB_NATGW_PUBLIC_IP="10.1.1.121/24"
+       CTDB_NATGW_PUBLIC_IFACE="eth1"
+       CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
 }
 
 ok_natgw_master_ip_addr_show ()