From 645f1e216c4c68130cf20ca9ba3d783bc8241628 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 20 Nov 2014 15:03:25 +1100 Subject: [PATCH] ctdb-tests: Update integration tests to use ctdb -X Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 2c4de75d8754616891e97222cfb2ec58fdd8eac2) --- ctdb/tests/complex/18_ctdb_reloadips.sh | 4 +-- ctdb/tests/complex/34_nfs_tickle_restart.sh | 4 +-- ctdb/tests/events.d/00.test | 4 +-- ctdb/tests/scripts/integration.bash | 34 +++++++++++++------------- ctdb/tests/simple/11_ctdb_ip.sh | 8 +++--- ctdb/tests/simple/12_ctdb_getdebug.sh | 12 ++++----- ctdb/tests/simple/20_delip_iface_gc.sh | 18 +++++++------- ctdb/tests/simple/27_ctdb_detach.sh | 2 +- ctdb/tests/simple/75_readonly_records_basic.sh | 4 +-- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/ctdb/tests/complex/18_ctdb_reloadips.sh b/ctdb/tests/complex/18_ctdb_reloadips.sh index 042683c4180..13f7c213af0 100755 --- a/ctdb/tests/complex/18_ctdb_reloadips.sh +++ b/ctdb/tests/complex/18_ctdb_reloadips.sh @@ -50,8 +50,8 @@ select_test_node_and_ips # the provided prefix. Note that this is an IPv4-specific test. echo "Getting public IP information from CTDB..." -try_command_on_node any "$CTDB ip -Y -v -n all" -ctdb_ip_info=$(echo "$out" | awk -F: 'NR > 1 { print $2, $3, $5 }') +try_command_on_node any "$CTDB ip -X -v -n all" +ctdb_ip_info=$(echo "$out" | awk -F'|' 'NR > 1 { print $2, $3, $5 }') echo "Getting IP information from interfaces..." try_command_on_node all "ip addr show" diff --git a/ctdb/tests/complex/34_nfs_tickle_restart.sh b/ctdb/tests/complex/34_nfs_tickle_restart.sh index b7eea4ca21c..365a0176fc9 100755 --- a/ctdb/tests/complex/34_nfs_tickle_restart.sh +++ b/ctdb/tests/complex/34_nfs_tickle_restart.sh @@ -45,7 +45,7 @@ monitor_interval="${out#*= }" #echo "Monitor interval on node $test_node is $monitor_interval seconds." select_test_node_and_ips -try_command_on_node $test_node "$CTDB listnodes -Y" +try_command_on_node $test_node "$CTDB listnodes -X" listnodes_output="$out" numnodes=$(wc -l <<<"$listnodes_output") @@ -67,7 +67,7 @@ echo "Wait until NFS connection is tracked by CTDB on test node ..." wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket echo "Select a node to restart ctdbd" -rn=$(awk -F: -v test_node=$test_node \ +rn=$(awk -F'|' -v test_node=$test_node \ '$2 != test_node { print $2 ; exit }' <<<"$listnodes_output") echo "Restarting CTDB on node ${rn}" diff --git a/ctdb/tests/events.d/00.test b/ctdb/tests/events.d/00.test index e3e15eb7301..0ae09879d43 100755 --- a/ctdb/tests/events.d/00.test +++ b/ctdb/tests/events.d/00.test @@ -26,9 +26,9 @@ case $cmd in ;; startup) echo "ctdb startup event" - IFACES=`ctdb ifaces -Y | grep -v '^:Name:LinkStatus:References:'` + IFACES=`ctdb ifaces -X | grep -v '^|Name|LinkStatus|References|'` for I in $IFACES; do - IFACE=`echo -n "$I" | cut -d ':' -f2` + IFACE=`echo -n "$I" | cut -d '|' -f2` ctdb setifacelink $IFACE up done exit 0; diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index 1835949a4f6..b75e8f95feb 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -163,13 +163,13 @@ all_ips_on_node() { local node="$1" try_command_on_node $node \ - "$CTDB ip -Y | awk -F: 'NR > 1 { print \$2, \$3 }'" + "$CTDB ip -X | awk -F'|' 'NR > 1 { print \$2, \$3 }'" } _select_test_node_and_ips () { try_command_on_node any \ - "$CTDB ip -Y -n all | awk -F: 'NR > 1 { print \$2, \$3 }'" + "$CTDB ip -X -n all | awk -F'|' 'NR > 1 { print \$2, \$3 }'" test_node="" # this matches no PNN test_node_ips="" @@ -209,7 +209,7 @@ select_test_node_and_ips () get_test_ip_mask_and_iface () { # Find the interface - try_command_on_node $test_node "$CTDB ip -v -Y | awk -F: -v ip=$test_ip '\$2 == ip { print \$4 }'" + try_command_on_node $test_node "$CTDB ip -v -X | awk -F'|' -v ip=$test_ip '\$2 == ip { print \$4 }'" iface="$out" if [ -z "$TEST_LOCAL_DAEMONS" ] ; then @@ -334,16 +334,16 @@ node_has_status () local bits fpat mpat rpat case "$status" in - (unhealthy) bits="?:?:?:1:*" ;; - (healthy) bits="?:?:?:0:*" ;; - (disconnected) bits="1:*" ;; - (connected) bits="0:*" ;; - (banned) bits="?:1:*" ;; - (unbanned) bits="?:0:*" ;; - (disabled) bits="?:?:1:*" ;; - (enabled) bits="?:?:0:*" ;; - (stopped) bits="?:?:?:?:1:*" ;; - (notstopped) bits="?:?:?:?:0:*" ;; + (unhealthy) bits="?|?|?|1|*" ;; + (healthy) bits="?|?|?|0|*" ;; + (disconnected) bits="1|*" ;; + (connected) bits="0|*" ;; + (banned) bits="?|1|*" ;; + (unbanned) bits="?|0|*" ;; + (disabled) bits="?|?|1|*" ;; + (enabled) bits="?|?|0|*" ;; + (stopped) bits="?|?|?|?|1|*" ;; + (notstopped) bits="?|?|?|?|0|*" ;; (frozen) fpat='^[[:space:]]+frozen[[:space:]]+1$' ;; (unfrozen) fpat='^[[:space:]]+frozen[[:space:]]+0$' ;; (monon) mpat='^Monitoring mode:ACTIVE \(0\)$' ;; @@ -357,13 +357,13 @@ node_has_status () if [ -n "$bits" ] ; then local out x line - out=$($CTDB -Y status 2>&1) || return 1 + out=$($CTDB -X status 2>&1) || return 1 { read x while read line ; do # This needs to be done in 2 steps to avoid false matches. - local line_bits="${line#:${pnn}:*:}" + local line_bits="${line#|${pnn}|*|}" [ "$line_bits" = "$line" ] && continue [ "${line_bits#${bits}}" != "$line_bits" ] && return 0 done @@ -566,7 +566,7 @@ restart_ctdb () # Cluster is still healthy. Good, we're done! if ! onnode 0 $CTDB_TEST_WRAPPER _cluster_is_healthy ; then echo "Cluster became UNHEALTHY again [$(date)]" - onnode -p all ctdb status -Y 2>&1 + onnode -p all ctdb status -X 2>&1 onnode -p all ctdb scriptstatus 2>&1 echo "Restarting..." continue @@ -580,7 +580,7 @@ restart_ctdb () done echo "Cluster UNHEALTHY... too many attempts..." - onnode -p all ctdb status -Y 2>&1 + onnode -p all ctdb status -X 2>&1 onnode -p all ctdb scriptstatus 2>&1 # Try to make the calling test fail diff --git a/ctdb/tests/simple/11_ctdb_ip.sh b/ctdb/tests/simple/11_ctdb_ip.sh index c1aec0e9bd7..0e02b5e8171 100755 --- a/ctdb/tests/simple/11_ctdb_ip.sh +++ b/ctdb/tests/simple/11_ctdb_ip.sh @@ -15,7 +15,7 @@ Steps: 2. Run 'ctdb ip' on one of the nodes and verify the list of IP addresses displayed (cross check the result with the output of 'ip addr show' on the node). -3. Verify that colon-separated output is generated with the -Y option. +3. Verify that pipe-separated output is generated with the -X option. Expected results: @@ -37,14 +37,14 @@ ips=$(echo "$out" | sed \ -e 's@ node\[@ @' \ -e 's@\].*$@@') machineout=$(echo "$out" | sed -r \ - -e 's@^| |$@:@g' \ + -e 's@^| |$@\|@g' \ -e 's@[[:alpha:]]+\[@@g' \ -e 's@\]@@g') if [ -z "$TEST_LOCAL_DAEMONS" ]; then while read ip pnn ; do try_command_on_node $pnn "ip addr show" - if [ "${out/inet ${ip}\/}" != "$out" ] ; then + if [ "${out/inet* ${ip}\/}" != "$out" ] ; then echo "GOOD: node $pnn appears to have $ip assigned" else echo "BAD: node $pnn does not appear to have $ip assigned" @@ -55,7 +55,7 @@ fi [ "$testfailures" != 1 ] && echo "Looks good!" -cmd="$CTDB -Y ip -n all | tail -n +2" +cmd="$CTDB -X ip -n all | tail -n +2" echo "Checking that \"$cmd\" produces expected output..." try_command_on_node 1 "$cmd" diff --git a/ctdb/tests/simple/12_ctdb_getdebug.sh b/ctdb/tests/simple/12_ctdb_getdebug.sh index 4a4926d0c60..cdd9e342e72 100755 --- a/ctdb/tests/simple/12_ctdb_getdebug.sh +++ b/ctdb/tests/simple/12_ctdb_getdebug.sh @@ -13,7 +13,7 @@ Steps: 1. Verify that the status on all of the ctdb nodes is 'OK'. 2. Get the current debug level on a node, using 'ctdb getdebug -n '. -3. Verify that colon-separated output is generated with the -Y option. +3. Verify that pipe-separated output is generated with the -X option. 4. Verify that the '-n all' option shows the debug level on all nodes. Expected results: @@ -61,19 +61,19 @@ else testfailures=1 fi -colons="" +seps="" nl=" " while read line ; do - t=$(echo "$line" | sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \((-?[[:digit:]]+)\)$@:\1:\2:@') - colons="${colons}${colons:+${nl}}:Name:Level:${nl}${t}" + t=$(echo "$line" | sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \((-?[[:digit:]]+)\)$@\|\1\|\2|@') + seps="${seps}${seps:+${nl}}|Name|Level|${nl}${t}" done <<<"$getdebug_onnode" -cmd="$CTDB -Y getdebug -n all" +cmd="$CTDB -X getdebug -n all" echo "Checking that \"$cmd\" produces expected output..." try_command_on_node 1 "$cmd" -if [ "$out" = "$colons" ] ; then +if [ "$out" = "$seps" ] ; then echo "Yep, looks good!" else echo "Nope, it looks like this:" diff --git a/ctdb/tests/simple/20_delip_iface_gc.sh b/ctdb/tests/simple/20_delip_iface_gc.sh index bc43567a57b..83de49595ab 100755 --- a/ctdb/tests/simple/20_delip_iface_gc.sh +++ b/ctdb/tests/simple/20_delip_iface_gc.sh @@ -19,19 +19,19 @@ cluster_is_healthy ctdb_restart_when_done echo "Getting public IPs information..." -try_command_on_node -v any "$CTDB ip -v -n all -Y | tail -n +2" +try_command_on_node -v any "$CTDB ip -v -n all -X | tail -n +2" ip_info="$out" # Select the first node and find out its interfaces -test_node=$(awk -F: 'NR == 1 { print $3}' <<<"$ip_info") -ifaces=$(awk -F: -v tn=$test_node '$3 == tn { print $6 }' <<<"$ip_info" | sed 's@, @ @g' | xargs -n 1 | sort -u) +test_node=$(awk -F'|' 'NR == 1 { print $3}' <<<"$ip_info") +ifaces=$(awk -F'|' -v tn=$test_node '$3 == tn { print $6 }' <<<"$ip_info" | sed 's@, @ @g' | xargs -n 1 | sort -u) echo "Selected test node ${test_node} with interfaces: ${ifaces}" # Delete all IPs on each interface... deleting IPs from one interface # can cause other interfaces to disappear, so we need to be careful... for i in $ifaces ; do - try_command_on_node $test_node "$CTDB ifaces -Y" - info=$(awk -F: -v iface="$i" '$2 == iface { print $0 }' <<<"$out") + try_command_on_node $test_node "$CTDB ifaces -X" + info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out") if [ -z "$info" ] ; then echo "Interface ${i} missing... assuming already deleted!" @@ -41,16 +41,16 @@ for i in $ifaces ; do echo "Deleting IPs on interface ${i}, with this information:" echo " $info" - try_command_on_node $test_node "$CTDB ip -v -Y | tail -n +2" - awk -F: -v i="$i" \ + try_command_on_node $test_node "$CTDB ip -v -X | tail -n +2" + awk -F'|' -v i="$i" \ '$6 == i { print $2 }' <<<"$out" | while read ip ; do echo " $ip" try_command_on_node $test_node "$CTDB delip $ip" done - try_command_on_node $test_node "$CTDB ifaces -Y" - info=$(awk -F: -v iface="$i" '$2 == iface { print $0 }' <<<"$out") + try_command_on_node $test_node "$CTDB ifaces -X" + info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out") if [ -z "$info" ] ; then echo "GOOD: Interface ${i} has been garbage collected" diff --git a/ctdb/tests/simple/27_ctdb_detach.sh b/ctdb/tests/simple/27_ctdb_detach.sh index 108a270bd44..4b7b3b5f22f 100755 --- a/ctdb/tests/simple/27_ctdb_detach.sh +++ b/ctdb/tests/simple/27_ctdb_detach.sh @@ -35,7 +35,7 @@ ctdb_restart_when_done ###################################################################### -try_command_on_node 0 "$CTDB listnodes -Y" +try_command_on_node 0 "$CTDB listnodes -X" listnodes_output="$out" numnodes=$(wc -l <<<"$listnodes_output") diff --git a/ctdb/tests/simple/75_readonly_records_basic.sh b/ctdb/tests/simple/75_readonly_records_basic.sh index 6cd2cce6128..e4d57081609 100755 --- a/ctdb/tests/simple/75_readonly_records_basic.sh +++ b/ctdb/tests/simple/75_readonly_records_basic.sh @@ -113,8 +113,8 @@ check_readonly () ###################################################################### echo "Get list of nodes..." -try_command_on_node any $CTDB -Y listnodes -all_nodes=$(awk -F: '{print $2}' <<<"$out") +try_command_on_node any $CTDB -X listnodes +all_nodes=$(awk -F'|' '{print $2}' <<<"$out") ###################################################################### -- 2.11.4.GIT