summaryrefslogtreecommitdiff
path: root/ctdb/tests
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-02-12 11:42:04 +1100
committerAmitay Isaacs <amitay@samba.org>2018-03-28 02:57:19 +0200
commita63c45608053d1f461f83f21cb2ca3471847d987 (patch)
treeb0dc4d31ba36fde51b2ecf4ec4175358afdd58e6 /ctdb/tests
parent8c81fb9d9a27ac836f24c90b381fcfba586d9fac (diff)
downloadsamba-a63c45608053d1f461f83f21cb2ca3471847d987.tar.gz
ctdb-tests: 11.natgw event script setup modularisation
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.001.sh2
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.002.sh4
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.003.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.004.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.011.sh2
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.012.sh2
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.013.sh2
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.014.sh2
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.015.sh2
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.021.sh4
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.022.sh4
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.023.sh4
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.024.sh4
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.025.sh5
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.031.sh8
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.041.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.042.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.051.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.052.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.053.sh3
-rwxr-xr-xctdb/tests/eventscripts/11.natgw.054.sh3
-rw-r--r--ctdb/tests/eventscripts/scripts/11.natgw.sh33
22 files changed, 60 insertions, 42 deletions
diff --git a/ctdb/tests/eventscripts/11.natgw.001.sh b/ctdb/tests/eventscripts/11.natgw.001.sh
index afcc0972ddf..06b2cd39cee 100755
--- a/ctdb/tests/eventscripts/11.natgw.001.sh
+++ b/ctdb/tests/eventscripts/11.natgw.001.sh
@@ -4,7 +4,7 @@
define_test "not configured"
-setup_ctdb
+setup
ok_null
simple_test_event "ipreallocate"
diff --git a/ctdb/tests/eventscripts/11.natgw.002.sh b/ctdb/tests/eventscripts/11.natgw.002.sh
index c9054068df4..5e3f2d3a224 100755
--- a/ctdb/tests/eventscripts/11.natgw.002.sh
+++ b/ctdb/tests/eventscripts/11.natgw.002.sh
@@ -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
-
diff --git a/ctdb/tests/eventscripts/11.natgw.003.sh b/ctdb/tests/eventscripts/11.natgw.003.sh
index eb821dca48b..2743b4f1df5 100755
--- a/ctdb/tests/eventscripts/11.natgw.003.sh
+++ b/ctdb/tests/eventscripts/11.natgw.003.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.004.sh b/ctdb/tests/eventscripts/11.natgw.004.sh
index 10bf22c711a..5f1f816912e 100755
--- a/ctdb/tests/eventscripts/11.natgw.004.sh
+++ b/ctdb/tests/eventscripts/11.natgw.004.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.011.sh b/ctdb/tests/eventscripts/11.natgw.011.sh
index 4c5a937d553..e8513c9f2e3 100755
--- a/ctdb/tests/eventscripts/11.natgw.011.sh
+++ b/ctdb/tests/eventscripts/11.natgw.011.sh
@@ -4,7 +4,7 @@
define_test "master node, basic configuration"
-setup_ctdb
+setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
diff --git a/ctdb/tests/eventscripts/11.natgw.012.sh b/ctdb/tests/eventscripts/11.natgw.012.sh
index 6ec98a03f58..94cbe9d22b9 100755
--- a/ctdb/tests/eventscripts/11.natgw.012.sh
+++ b/ctdb/tests/eventscripts/11.natgw.012.sh
@@ -4,7 +4,7 @@
define_test "slave node, basic configuration"
-setup_ctdb
+setup
setup_ctdb_natgw <<EOF
192.168.1.21
diff --git a/ctdb/tests/eventscripts/11.natgw.013.sh b/ctdb/tests/eventscripts/11.natgw.013.sh
index 16f06221805..75823c3cc36 100755
--- a/ctdb/tests/eventscripts/11.natgw.013.sh
+++ b/ctdb/tests/eventscripts/11.natgw.013.sh
@@ -4,7 +4,7 @@
define_test "master node, no gateway"
-setup_ctdb
+setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
diff --git a/ctdb/tests/eventscripts/11.natgw.014.sh b/ctdb/tests/eventscripts/11.natgw.014.sh
index 462756c062d..3df2fab8332 100755
--- a/ctdb/tests/eventscripts/11.natgw.014.sh
+++ b/ctdb/tests/eventscripts/11.natgw.014.sh
@@ -4,7 +4,7 @@
define_test "slave node, no gateway"
-setup_ctdb
+setup
setup_ctdb_natgw <<EOF
192.168.1.21
diff --git a/ctdb/tests/eventscripts/11.natgw.015.sh b/ctdb/tests/eventscripts/11.natgw.015.sh
index 691b363ef1b..dbe09d2efd1 100755
--- a/ctdb/tests/eventscripts/11.natgw.015.sh
+++ b/ctdb/tests/eventscripts/11.natgw.015.sh
@@ -4,7 +4,7 @@
define_test "basic configuration, multiple transitions"
-setup_ctdb
+setup
echo "*** Master node..."
diff --git a/ctdb/tests/eventscripts/11.natgw.021.sh b/ctdb/tests/eventscripts/11.natgw.021.sh
index 5786ea7e648..fb9b167b794 100755
--- a/ctdb/tests/eventscripts/11.natgw.021.sh
+++ b/ctdb/tests/eventscripts/11.natgw.021.sh
@@ -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"
diff --git a/ctdb/tests/eventscripts/11.natgw.022.sh b/ctdb/tests/eventscripts/11.natgw.022.sh
index 170ed8caf84..bcdcd6acf63 100755
--- a/ctdb/tests/eventscripts/11.natgw.022.sh
+++ b/ctdb/tests/eventscripts/11.natgw.022.sh
@@ -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"
diff --git a/ctdb/tests/eventscripts/11.natgw.023.sh b/ctdb/tests/eventscripts/11.natgw.023.sh
index cf71c084797..ae341909d17 100755
--- a/ctdb/tests/eventscripts/11.natgw.023.sh
+++ b/ctdb/tests/eventscripts/11.natgw.023.sh
@@ -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"
diff --git a/ctdb/tests/eventscripts/11.natgw.024.sh b/ctdb/tests/eventscripts/11.natgw.024.sh
index 3d2aed5532d..5b1f201c8c3 100755
--- a/ctdb/tests/eventscripts/11.natgw.024.sh
+++ b/ctdb/tests/eventscripts/11.natgw.024.sh
@@ -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"
diff --git a/ctdb/tests/eventscripts/11.natgw.025.sh b/ctdb/tests/eventscripts/11.natgw.025.sh
index 60602d3ead9..05f56b52098 100755
--- a/ctdb/tests/eventscripts/11.natgw.025.sh
+++ b/ctdb/tests/eventscripts/11.natgw.025.sh
@@ -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"
-
diff --git a/ctdb/tests/eventscripts/11.natgw.031.sh b/ctdb/tests/eventscripts/11.natgw.031.sh
index a8575a57937..039930fa4ad 100755
--- a/ctdb/tests/eventscripts/11.natgw.031.sh
+++ b/ctdb/tests/eventscripts/11.natgw.031.sh
@@ -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"
diff --git a/ctdb/tests/eventscripts/11.natgw.041.sh b/ctdb/tests/eventscripts/11.natgw.041.sh
index e8126e1b47c..d5cc44adce6 100755
--- a/ctdb/tests/eventscripts/11.natgw.041.sh
+++ b/ctdb/tests/eventscripts/11.natgw.041.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.042.sh b/ctdb/tests/eventscripts/11.natgw.042.sh
index 001698cbf69..17d98cb9452 100755
--- a/ctdb/tests/eventscripts/11.natgw.042.sh
+++ b/ctdb/tests/eventscripts/11.natgw.042.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.051.sh b/ctdb/tests/eventscripts/11.natgw.051.sh
index 8a385b69839..9bf8569607c 100755
--- a/ctdb/tests/eventscripts/11.natgw.051.sh
+++ b/ctdb/tests/eventscripts/11.natgw.051.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.052.sh b/ctdb/tests/eventscripts/11.natgw.052.sh
index 091b6f6c1ad..2d4a339cb98 100755
--- a/ctdb/tests/eventscripts/11.natgw.052.sh
+++ b/ctdb/tests/eventscripts/11.natgw.052.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.053.sh b/ctdb/tests/eventscripts/11.natgw.053.sh
index 7c51ec11e8a..d9b173e8d22 100755
--- a/ctdb/tests/eventscripts/11.natgw.053.sh
+++ b/ctdb/tests/eventscripts/11.natgw.053.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/11.natgw.054.sh b/ctdb/tests/eventscripts/11.natgw.054.sh
index 08b4b775593..a2173f38fd3 100755
--- a/ctdb/tests/eventscripts/11.natgw.054.sh
+++ b/ctdb/tests/eventscripts/11.natgw.054.sh
@@ -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
diff --git a/ctdb/tests/eventscripts/scripts/11.natgw.sh b/ctdb/tests/eventscripts/scripts/11.natgw.sh
index be255e6948a..a11da431434 100644
--- a/ctdb/tests/eventscripts/scripts/11.natgw.sh
+++ b/ctdb/tests/eventscripts/scripts/11.natgw.sh
@@ -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 ()