summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2008-12-08 08:15:18 +1100
committerMartin Schwenke <martin@meltin.net>2008-12-08 08:15:18 +1100
commitc9ca8ccc2312757f8c8a59c79997976796120417 (patch)
tree427ade75a587b1f956488c51e5dcecf1b01d9373 /ctdb
parent805c5bf1f33d250fa1f9f6fac0e46ff9358c8dee (diff)
downloadsamba-c9ca8ccc2312757f8c8a59c79997976796120417.tar.gz
samba-c9ca8ccc2312757f8c8a59c79997976796120417.tar.xz
samba-c9ca8ccc2312757f8c8a59c79997976796120417.zip
When running with local daemons, provided there is more than 2 of
them, randomly pick a single node that will not have any public IPs assigned. This will make life a bit more interesting and will simulate what happens on real clusters with a management node. Some tests were disabling a node to implicitly trigger a ctdb restart - now use an explicit restart of ctdb when it is required. 17_ctdb_config_delete_ip.sh now randomly chooses a public IP on any node to disable - this works around a problem where the hardcoded node might not have any public addresses. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 3d59783c0e9478f4766c380945d6200fc654f5d9)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/tests/scripts/ctdb_test_functions.bash13
-rwxr-xr-xctdb/tests/simple/16_ctdb_config_add_ip.sh6
-rwxr-xr-xctdb/tests/simple/17_ctdb_config_delete_ip.sh35
-rwxr-xr-xctdb/tests/simple/20_ctdb_getmonmode.sh4
4 files changed, 29 insertions, 29 deletions
diff --git a/ctdb/tests/scripts/ctdb_test_functions.bash b/ctdb/tests/scripts/ctdb_test_functions.bash
index 96a0f9f56e5..08f0274f8f3 100644
--- a/ctdb/tests/scripts/ctdb_test_functions.bash
+++ b/ctdb/tests/scripts/ctdb_test_functions.bash
@@ -397,6 +397,11 @@ start_daemons ()
local public_addresses=$var_dir/public_addresses.txt
rm -f $nodes $public_addresses
+ # If there are (strictly) greater than 2 nodes then we'll randomly
+ # choose a node to have no public addresses.
+ local no_public_ips=-1
+ [ $num_nodes -gt 2 ] && no_public_ips=$(($RANDOM % $num_nodes + 1))
+
local i
for i in $(seq 1 $num_nodes) ; do
if [ "${CTDB_USE_IPV6}x" != "x" ]; then
@@ -404,9 +409,11 @@ start_daemons ()
ip addr add ::$i/128 dev lo
else
echo 127.0.0.$i >> $nodes
- # 2 public addresses per node, just to make things interesting.
- echo "192.0.2.$i/24 lo" >> $public_addresses
- echo "192.0.2.$(($i + $num_nodes))/24 lo" >> $public_addresses
+ # 2 public addresses on most nodes, just to make things interesting.
+ if [ $i -ne $no_public_ips ] ; then
+ echo "192.0.2.$i/24 lo" >> $public_addresses
+ echo "192.0.2.$(($i + $num_nodes))/24 lo" >> $public_addresses
+ fi
fi
done
diff --git a/ctdb/tests/simple/16_ctdb_config_add_ip.sh b/ctdb/tests/simple/16_ctdb_config_add_ip.sh
index e6b8ea75c9d..584640b15e0 100755
--- a/ctdb/tests/simple/16_ctdb_config_add_ip.sh
+++ b/ctdb/tests/simple/16_ctdb_config_add_ip.sh
@@ -104,11 +104,13 @@ if [ -n "$add_ip" ] ; then
echo "Waiting for IP to be added..."
wait_until 60 ips_are_on_nodeglob $test_node $test_node_ips ${add_ip%/*}
- echo "That worked! Disabling node $test_node to force a restart..."
- try_command_on_node $test_node ctdb disable
+ echo "That worked!"
else
echo "BAD: Unable to find IP address to add."
testfailures=1
fi
+echo "Restarting cluster to restore configuration..."
+restart_ctdb
+
ctdb_test_exit
diff --git a/ctdb/tests/simple/17_ctdb_config_delete_ip.sh b/ctdb/tests/simple/17_ctdb_config_delete_ip.sh
index fce137ea51e..ac47f631893 100755
--- a/ctdb/tests/simple/17_ctdb_config_delete_ip.sh
+++ b/ctdb/tests/simple/17_ctdb_config_delete_ip.sh
@@ -38,28 +38,19 @@ set -e
onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
-test_node=1
-
-echo "Getting list of public IPs on node ${test_node}..."
-try_command_on_node $test_node 'ctdb ip -n all | sed -e "1d"'
-
-test_node_ips=""
-num_ips=0
-while read ip pnn ; do
- if [ "$pnn" = "$test_node" ] ; then
- test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
- num_ips=$(($num_ips + 1))
- fi
-done <<<"$out" # bashism to avoid problem setting variable in pipeline.
-
-echo "Node ${test_node} has IPs: $test_node_ips"
+echo "Getting list of public IPs..."
+try_command_on_node -v 0 'ctdb ip -n all | sed -e "1d"'
+# Select an IP/node to remove.
+num_ips=$(echo "$out" | wc -l)
num_to_remove=$(($RANDOM % $num_ips))
-ips=$test_node_ips
-for i in $(seq 1 $num_to_remove) ; do
- ips="${ips#* }"
-done
-ip_to_remove="${ips%% *}"
+
+# Find the details in the list.
+i=0
+while [ $i -lt $num_to_remove ] ; do
+ read ip_to_remove test_node
+ i=$(($i + 1))
+done <<<"$out"
echo "Attempting to remove ${ip_to_remove} from node ${test_node}."
try_command_on_node $test_node ctdb delip $ip_to_remove
@@ -74,8 +65,8 @@ while read ip pnn ; do
done <<<"$out" # bashism to avoid problem setting variable in pipeline.
if [ "${test_node_ips/${ip_to_remove}}" = "$test_node_ips" ] ; then
- echo "That worked! Disabling node $test_node to force a restart..."
- try_command_on_node $test_node ctdb disable
+ echo "That worked! Restarting cluster to restore configuration..."
+ restart_ctdb
else
echo "BAD: The remove IP address is still there!"
testfailures=1
diff --git a/ctdb/tests/simple/20_ctdb_getmonmode.sh b/ctdb/tests/simple/20_ctdb_getmonmode.sh
index 97bcf21bc7e..215f0cfb54a 100755
--- a/ctdb/tests/simple/20_ctdb_getmonmode.sh
+++ b/ctdb/tests/simple/20_ctdb_getmonmode.sh
@@ -62,8 +62,8 @@ try_command_on_node -v 0 ctdb disablemonitor -n $test_node
onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node monoff
-echo "That worked! Disabling node $test_node to force a restart..."
+echo "That worked! Restarting cluster to restore configuration..."
-try_command_on_node $test_node ctdb disable
+restart_ctdb
ctdb_test_exit