ctdb-tools: Update onnode and ctdb-diagnostics to use ctdb -X
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Nov 2014 03:39:59 +0000 (14:39 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 5 Dec 2014 20:02:40 +0000 (21:02 +0100)
Also update onnode unit tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/onnode/0070.sh
ctdb/tests/onnode/0071.sh
ctdb/tests/onnode/0072.sh
ctdb/tests/onnode/0075.sh
ctdb/tests/onnode/stubs/onnode-buggy-001
ctdb/tools/ctdb_diagnostics
ctdb/tools/onnode

index b071e80a800f1b73a344d00acb385cf374bdb9cc..d649f82f217f93c17d2cb5609f70c6908931394e 100755 (executable)
@@ -7,11 +7,11 @@ cmd="$ONNODE ok hostname"
 define_test "$cmd" "all nodes OK"
 
 ctdb_set_output <<EOF
-:Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped:Inactive:PartiallyOnline:ThisNode:
-:0:192.168.1.101:0:0:0:0:0:0:0:Y:
-:1:192.168.1.102:0:0:0:0:0:0:0:N:
-:2:192.168.1.103:0:0:0:0:0:0:0:N:
-:3:192.168.1.104:0:0:0:0:0:0:0:N:
+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
+|0|192.168.1.101|0|0|0|0|0|0|0|Y|
+|1|192.168.1.102|0|0|0|0|0|0|0|N|
+|2|192.168.1.103|0|0|0|0|0|0|0|N|
+|3|192.168.1.104|0|0|0|0|0|0|0|N|
 EOF
 
 required_result <<EOF
index d594323e3fd2f4c128a3f4132325b53c7caaaf80..4f945acce3b40d270ad17fb57afa9cc765c4c86b 100755 (executable)
@@ -7,11 +7,11 @@ cmd="$ONNODE ok hostname"
 define_test "$cmd" "2nd node disconnected"
 
 ctdb_set_output <<EOF 
-:Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped:Inactive:PartiallyOnline:ThisNode:
-:0:192.168.1.101:0:0:0:0:0:0:0:Y:
-:1:192.168.1.102:1:0:0:0:0:0:0:N:
-:2:192.168.1.103:0:0:0:0:0:0:0:N:
-:3:192.168.1.104:0:0:0:0:0:0:0:N:
+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
+|0|192.168.1.101|0|0|0|0|0|0|0|Y|
+|1|192.168.1.102|1|0|0|0|0|0|0|N|
+|2|192.168.1.103|0|0|0|0|0|0|0|N|
+|3|192.168.1.104|0|0|0|0|0|0|0|N|
 EOF
 
 required_result <<EOF
index cb29e3b9a2c29baa8ad01d3ed2bb524c85e52be6..51a4c46f975fbf753dd8f7553b597114369406dd 100755 (executable)
@@ -7,11 +7,11 @@ cmd="$ONNODE ok hostname"
 define_test "$cmd" "2nd node disconnected, extra status columns"
 
 ctdb_set_output <<EOF
-:Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped:Inactive:X1:X2:X3:X4:
-:0:192.168.1.101:0:0:0:0:0:0:0:0:0:0:
-:1:192.168.1.102:1:0:0:0:0:0:0:0:0:0:
-:2:192.168.1.103:0:0:0:0:0:0:0:0:0:0:
-:3:192.168.1.104:0:0:0:0:0:0:0:0:0:0:
+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|X1|X2|X3|X4|
+|0|192.168.1.101|0|0|0|0|0|0|0|0|0|0|
+|1|192.168.1.102|1|0|0|0|0|0|0|0|0|0|
+|2|192.168.1.103|0|0|0|0|0|0|0|0|0|0|
+|3|192.168.1.104|0|0|0|0|0|0|0|0|0|0|
 EOF
 
 required_result <<EOF
index 4276e9c12c873581125955ef9d1d45d332279e68..92fe22053c6d4ac9e3015fe45e85838c9a8d3da5 100755 (executable)
@@ -7,11 +7,11 @@ cmd="$ONNODE con hostname"
 define_test "$cmd" "1st node disconnected"
 
 ctdb_set_output <<EOF
-:Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped:Inactive:PartiallyOnline:ThisNode:
-:0:192.168.1.101:1:0:0:0:0:0:0:N:
-:1:192.168.1.102:0:0:0:0:0:0:0:Y:
-:2:192.168.1.103:0:0:0:0:0:0:0:N:
-:3:192.168.1.104:0:0:0:0:0:0:0:N:
+|Node|IP|Disconnected|Banned|Disabled|Unhealthy|Stopped|Inactive|PartiallyOnline|ThisNode|
+|0|192.168.1.101|1|0|0|0|0|0|0|N|
+|1|192.168.1.102|0|0|0|0|0|0|0|Y|
+|2|192.168.1.103|0|0|0|0|0|0|0|N|
+|3|192.168.1.104|0|0|0|0|0|0|0|N|
 EOF
 
 required_result <<EOF
index 77a1207d6c23433f300a66f1caad3d42eaeb18d8..e044ee33a187aa006367ab98dfa1ce465009dfa8 100755 (executable)
@@ -141,10 +141,10 @@ get_nodes_with_status ()
     local bits
     case "$status" in
        healthy)
-           bits="0:0:0:0:0:0"
+           bits="0|0|0|0|0|0"
            ;;
        connected)
-           bits="0:[0-1]:[0-1]:[0-1]:[0-1]:[0-1]"
+           bits="0|[0-1]|[0-1]|[0-1]|[0-1]|[0-1]"
            ;;
        *)
            invalid_nodespec
@@ -152,7 +152,7 @@ get_nodes_with_status ()
 
     if [ -z "$ctdb_status_output" ] ; then
        # FIXME: need to do something if $CTDB_NODES_SOCKETS is set.
-       ctdb_status_output=$(ctdb -Y status 2>/dev/null)
+       ctdb_status_output=$(ctdb -X status 2>/dev/null)
        if [ $? -ne 0 ] ; then
            echo "${prog}: unable to get status of CTDB nodes" >&2
            exit 1
@@ -164,14 +164,14 @@ get_nodes_with_status ()
     local i
     for i in $ctdb_status_output ; do
        # Try removing bits from end.
-       local t="${i%:${bits}:}"
+       local t="${i%|${bits}|}"
        if [ "$t" != "$i" ] ; then
            # Succeeded.  Get address.  NOTE: this is an optimisation.
            # It might be better to get the node number and then get
            # the nth node to get the address.  This would make things
            # more consistent if $ctdb_base/nodes actually contained
            # hostnames.
-           nodes="${nodes} ${t#:*:}"
+           nodes="${nodes} ${t#|*|}"
        fi
     done
 
@@ -186,7 +186,7 @@ get_node_with_property ()
 
     local prop_node=""
     if [ "${ctdb_props##:${prop}:}" = "$ctdb_props" ] ; then
-       prop_node=$(ctdb "$prop" -Y 2>/dev/null)
+       prop_node=$(ctdb "$prop" -X 2>/dev/null)
        # We only want the first line.
        local nl="
 "
index 2a51e1bac25205d0f1427ada12bfbcbb3c636543..3f2fa630f7845e29004fd862622ae7e702999558 100755 (executable)
@@ -17,7 +17,7 @@ EOF
 
 }
 
-nodes=$(ctdb listnodes -Y | cut -d: -f2)
+nodes=$(ctdb listnodes -X | cut -d'|' -f2)
 bad_nodes=""
 diff_opts=
 no_ads=false
index 33d0e20779d96682e0d947db48a617c65d05c169..96d569a26442a9d49fae848eb88e14b1dd274f9d 100755 (executable)
@@ -145,7 +145,7 @@ get_nodes_with_status ()
     local status="$2"
 
     if [ -z "$ctdb_status_output" ] ; then
-       ctdb_status_output=$(ctdb -Y status 2>&1)
+       ctdb_status_output=$(ctdb -X status 2>&1)
        if [ $? -ne 0 ] ; then
            echo "${prog}: unable to get status of CTDB nodes" >&2
            echo "$ctdb_status_output" >&2
@@ -158,7 +158,7 @@ get_nodes_with_status ()
 
     (
        local i
-       IFS="${IFS}:"
+       IFS="${IFS}|"
        while IFS="" read i ; do
 
            set -- $i # split line on colons
@@ -196,7 +196,7 @@ get_node_with_property ()
     local prop_node=""
     if [ "${ctdb_props##:${prop}:}" = "$ctdb_props" ] ; then
        # Not in cache.
-       prop_node=$(ctdb "$prop" -Y 2>/dev/null)
+       prop_node=$(ctdb "$prop" -X 2>/dev/null)
        if [ $? -eq 0 ] ; then
            if [ "$prop" = "natgwlist" ] ; then
                prop_node="${prop_node%% *}" # 1st word