Merge branch 'master' of git://git.samba.org/sahlberg/ctdb
authorMartin Schwenke <martin@meltin.net>
Thu, 26 Aug 2010 01:06:57 +0000 (11:06 +1000)
committerMartin Schwenke <martin@meltin.net>
Thu, 26 Aug 2010 01:06:57 +0000 (11:06 +1000)
tests/scripts/ctdb_test_functions.bash
tests/simple/16_ctdb_config_add_ip.sh
tests/simple/20_ctdb_getmonmode.sh

index 42053c0486a740ee80d44f42aaa4ac573618b25d..68f7994da07e29336c4af9655509f4319975de65 100644 (file)
@@ -66,7 +66,7 @@ ctdb_test_exit ()
     # now complete.
     set +e
 
-    echo "*** TEST COMPLETE (RC=$status), CLEANING UP..."
+    echo "*** TEST COMPLETED (RC=$status) AT $(date '+%F %T'), CLEANING UP..."
 
     eval "$ctdb_test_exit_hook" || true
     unset ctdb_test_exit_hook
@@ -80,7 +80,7 @@ ctdb_test_exit ()
        # leave the recovery in restart_ctdb so that future tests that
        # might do a manual restart mid-test will benefit.
        echo "Forcing a recovery..."
-       onnode 0 ctdb recover
+       onnode 0 $CTDB recover
     fi
 
     exit $status
@@ -336,13 +336,15 @@ _cluster_is_healthy ()
 {
     local out x count line
 
-    out=$(ctdb -Y status 2>&1) || return 1
+    out=$($CTDB -Y status 2>/dev/null) || return 1
 
     {
         read x
        count=0
         while read line ; do
-           count=$(($count + 1))
+           # We need to see valid lines if we're going to be healthy.
+           [ "${line#:[0-9]}" != "$line" ] && count=$(($count + 1))
+           # A line indicating a node is unhealthy causes failure.
            [ "${line##:*:*:*1:}" != "$line" ] && return 1
         done
        [ $count -gt 0 ] && return $?
@@ -357,9 +359,9 @@ cluster_is_healthy ()
     else
        echo "Cluster is UNHEALTHY"
        if ! ${ctdb_test_restart_scheduled:-false} ; then
-           echo "DEBUG:"
+           echo "DEBUG AT $(date '+%F %T'):"
            local i
-           for i in "onnode -q 0 ctdb status" "onnode -q 0 onnode all ctdb scriptstatus" ; do
+           for i in "onnode -q 0 $CTDB status" "onnode -q 0 onnode all $CTDB scriptstatus" ; do
                echo "$i"
                $i || true
            done
@@ -407,7 +409,7 @@ node_has_status ()
     if [ -n "$bits" ] ; then
        local out x line
 
-       out=$(ctdb -Y status 2>&1) || return 1
+       out=$($CTDB -Y status 2>&1) || return 1
 
        {
             read x
@@ -420,9 +422,9 @@ node_has_status ()
            return 1
        } <<<"$out" # Yay bash!
     elif [ -n "$fpat" ] ; then
-       ctdb statistics -n "$pnn" | egrep -q "$fpat"
+       $CTDB statistics -n "$pnn" | egrep -q "$fpat"
     elif [ -n "$mpat" ] ; then
-       ctdb getmonmode -n "$pnn" | egrep -q "$mpat"
+       $CTDB getmonmode -n "$pnn" | egrep -q "$mpat"
     else
        echo 'node_has_status: unknown mode, neither $bits nor $fpat is set'
        return 1
@@ -437,8 +439,8 @@ wait_until_node_has_status ()
 
     echo "Waiting until node $pnn has status \"$status\"..."
 
-    if ! onnode any $CTDB_TEST_WRAPPER wait_until $timeout node_has_status "$pnn" "$status" ; then
-       for i in "onnode -q any ctdb status" "onnode -q any onnode all ctdb scriptstatus" ; do
+    if ! wait_until $timeout onnode any $CTDB_TEST_WRAPPER node_has_status "$pnn" "$status" ; then
+       for i in "onnode -q any $CTDB status" "onnode -q any onnode all $CTDB scriptstatus" ; do
            echo "$i"
            $i || true
        done
@@ -579,9 +581,9 @@ tcpdump_wait ()
 
     echo "Waiting for tcpdump to capture some packets..."
     if ! wait_until 30 tcpdump_check ; then
-       echo "DEBUG:"
+       echo "DEBUG AT $(date '+%F %T'):"
        local i
-       for i in "onnode -q 0 ctdb status" "netstat -tanp" "tcpdump -n -e -r $tcpdump_filename" ; do
+       for i in "onnode -q 0 $CTDB status" "netstat -tanp" "tcpdump -n -e -r $tcpdump_filename" ; do
            echo "$i"
            $i || true
        done
@@ -638,7 +640,7 @@ gratarp_sniff_wait_show ()
 daemons_stop ()
 {
     echo "Attempting to politely shutdown daemons..."
-    onnode 1 ctdb shutdown -n all || true
+    onnode 1 $CTDB shutdown -n all || true
 
     echo "Sleeping for a while..."
     sleep_for 1
@@ -794,16 +796,16 @@ _ctdb_start_post ()
     onnode -q 1  $CTDB_TEST_WRAPPER wait_until_healthy || return 1
 
     echo "Setting RerecoveryTimeout to 1"
-    onnode -pq all "ctdb setvar RerecoveryTimeout 1"
+    onnode -pq all "$CTDB setvar RerecoveryTimeout 1"
 
     # In recent versions of CTDB, forcing a recovery like this blocks
     # until the recovery is complete.  Hopefully this will help the
     # cluster to stabilise before a subsequent test.
     echo "Forcing a recovery..."
-    onnode -q 0 ctdb recover
+    onnode -q 0 $CTDB recover
     sleep_for 1
     echo "Forcing a recovery..."
-    onnode -q 0 ctdb recover
+    onnode -q 0 $CTDB recover
 
     echo "ctdb is ready"
 }
@@ -855,16 +857,16 @@ restart_ctdb ()
     onnode -q 1  $CTDB_TEST_WRAPPER wait_until_healthy || return 1
 
     echo "Setting RerecoveryTimeout to 1"
-    onnode -pq all "ctdb setvar RerecoveryTimeout 1"
+    onnode -pq all "$CTDB setvar RerecoveryTimeout 1"
 
     # In recent versions of CTDB, forcing a recovery like this blocks
     # until the recovery is complete.  Hopefully this will help the
     # cluster to stabilise before a subsequent test.
     echo "Forcing a recovery..."
-    onnode -q 0 ctdb recover
+    onnode -q 0 $CTDB recover
     sleep_for 1
     echo "Forcing a recovery..."
-    onnode -q 0 ctdb recover
+    onnode -q 0 $CTDB recover
 
     echo "ctdb is ready"
 }
@@ -984,7 +986,7 @@ ctdb_test_eventscript_install ()
 {
 
     local script='#!/bin/sh
-out=$(ctdb pnn)
+out=$($CTDB pnn)
 pnn="${out#PNN:}"
 
 rm -vf "/tmp/ctdb-test-flag-${1}.${pnn}"
@@ -1036,3 +1038,6 @@ wait_for_monitor_event ()
     wait_until 120 ! ctdb_test_eventscript_flag exists $pnn "monitor"
 
 }
+
+# Make sure that $CTDB is set.
+: ${CTDB:=ctdb}
index 6fee386d084b333dc738ccd17c354e17203f52f3..3207661f16d82eeceb7ca04cb914377d3765703d 100755 (executable)
@@ -115,6 +115,6 @@ if wait_until 60 ips_are_on_nodeglob $test_node ${add_ip%/*} ; then
     echo "That worked!"
 else
     echo "BAD: IP didn't get added."
-    try_command_on_node $test_node ctdb ip -n all
+    try_command_on_node $test_node $CTDB ip -n all
     exit 1
 fi
index eab3dad45a452cfe24b3bd22a2c1930ac1a955a9..56a38d852587e64faad2a7258214070e9b2ff868 100755 (executable)
@@ -18,7 +18,7 @@ Steps:
 
 1. Verify that the status on all of the ctdb nodes is 'OK'.
 2. Use 'ctdb getmodmode -n <node>' to get the current monitoring mode.
-3. Verify that it shows monitoring as 'active'.
+3. Verify that it looks sane.
 4. Verify that the command prints the output in colon-separated format
    when run with the '-Y' option.
 5. Disable monitoring on the node using 'ctdb disablemonitor'.
@@ -47,19 +47,12 @@ try_command_on_node -v 0 $CTDB getmonmode -n $test_node
 
 sanity_check_output \
     1 \
-    '^Monitoring mode:ACTIVE \(0\)$' \
+    '^Monitoring mode:(ACTIVE \(0\)|DISABLED \(1\))$' \
     "$out"
 
-colons=$(printf ':mode:\n:0:')
-
 try_command_on_node -v 0 $CTDB -Y getmonmode -n $test_node
 
-if [ "$out" = "$colons" ] ; then
-    echo "Looks OK"
-else
-    echo "BAD: -Y output isn't what was expected"
-    testfailures=1
-fi
+sanity_check_output 2 '^(:mode:|:0:|:1:)$' "$out"
 
 try_command_on_node -v 0 $CTDB disablemonitor -n $test_node