Test suite: Make "ctdb ip" test backward compatible with older ctdb versions.
[vlendec/samba-autobuild/.git] / ctdb / tests / simple / 11_ctdb_ip.sh
index 941a8ef9e06e7ba7eb2558059b303e1fcc3f3fb4..e85884541a92905299781fd0d5e0cc3c7074858e 100755 (executable)
@@ -29,12 +29,17 @@ ctdb_test_init "$@"
 
 set -e
 
-onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
+cluster_is_healthy
 
 echo "Getting list of public IPs..."
-try_command_on_node -v 1 ctdb ip -n all
-ips=$(echo "$out" | sed -e '1d')
-colons=$(echo "$ips" | sed -e 's@^@:@' -e 's@$@:@' -e 's@ @:@')
+try_command_on_node -v 1 "$CTDB ip -n all | tail -n +2"
+ips=$(echo "$out" | sed \
+       -e 's@ node\[@ @' \
+       -e 's@\].*$@@')
+machineout=$(echo "$out" | sed -r \
+       -e 's@^| |$@:@g' \
+       -e 's@[[:alpha:]]+\[@@g' \
+       -e 's@\]@@g')
 
 while read ip pnn ; do
     try_command_on_node $pnn "ip addr show"
@@ -48,16 +53,16 @@ done <<<"$ips" # bashism to avoid problem setting variable in pipeline.
 
 [ "$testfailures" != 1 ] && echo "Looks good!"
 
-cmd="ctdb -Y ip -n all | sed -e '1d'"
+cmd="$CTDB -Y ip -n all | tail -n +2"
 echo "Checking that \"$cmd\" produces expected output..."
 
 try_command_on_node 1 "$cmd"
-if [ "$out" = "$colons" ] ; then
+if [ "$out" = "$machineout" ] ; then
     echo "Yep, looks good!"
 else
     echo "Nope, it looks like this:"
     echo "$out"
+    echo "Should be like this:"
+    echo "$machineout"
     testfailures=1
 fi
-
-ctdb_test_exit