Test suite: strengthen function _cluster_is_healthy().
authorMartin Schwenke <martin@meltin.net>
Fri, 13 Aug 2010 07:01:54 +0000 (17:01 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 13 Aug 2010 07:01:54 +0000 (17:01 +1000)
If there's a chance that "ctdb status -Y" can return 0 but print
garbage then this function might return a false positive.

So, we do 2 things:

* Redirect stderr to >/dev/null rather than looking at it.  This
  minimises the chance that we will see garbage.

* Since we need at least 1 good line to decide the cluster is healthy,
  we sanity check each line to esnure it starts with :[0-9].

Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/scripts/ctdb_test_functions.bash

index 40a9642afb415e691fc64b263d42c99ef95235a6..d2b069c95b3c2ddaf836f10efecc7fa50a84a809 100644 (file)
@@ -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 $?