ctdb-tests: Avoid bulk output in $out, prefer $outfile
authorMartin Schwenke <martin@meltin.net>
Thu, 11 Apr 2019 10:55:20 +0000 (20:55 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 7 May 2019 05:45:35 +0000 (05:45 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13924

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
38 files changed:
ctdb/tests/complex/11_ctdb_delip_removes_ip.sh
ctdb/tests/complex/18_ctdb_reloadips.sh
ctdb/tests/complex/32_cifs_tickle.sh
ctdb/tests/complex/36_smb_reset_server.sh
ctdb/tests/complex/37_nfs_reset_server.sh
ctdb/tests/complex/60_rogueip_releaseip.sh
ctdb/tests/complex/scripts/local.bash
ctdb/tests/scripts/integration.bash
ctdb/tests/simple/02_ctdb_tunables.sh
ctdb/tests/simple/05_ctdb_listnodes.sh
ctdb/tests/simple/08_ctdb_isnotrecmaster.sh
ctdb/tests/simple/11_ctdb_ip.sh
ctdb/tests/simple/15_ctdb_statisticsreset.sh
ctdb/tests/simple/19_ip_takeover_noop.sh
ctdb/tests/simple/20_delip_iface_gc.sh
ctdb/tests/simple/21_ctdb_attach.sh
ctdb/tests/simple/23_ctdb_moveip.sh
ctdb/tests/simple/24_ctdb_getdbmap.sh
ctdb/tests/simple/26_ctdb_config_check_error_on_unreachable_ctdb.sh
ctdb/tests/simple/27_ctdb_detach.sh
ctdb/tests/simple/35_ctdb_getreclock.sh
ctdb/tests/simple/51_message_ring.sh
ctdb/tests/simple/52_fetch_ring.sh
ctdb/tests/simple/53_transaction_loop.sh
ctdb/tests/simple/54_transaction_loop_recovery.sh
ctdb/tests/simple/55_ctdb_ptrans.sh
ctdb/tests/simple/56_replicated_transaction_recovery.sh
ctdb/tests/simple/58_ctdb_restoredb.sh
ctdb/tests/simple/69_recovery_resurrect_deleted.sh
ctdb/tests/simple/70_recoverpdbbyseqnum.sh
ctdb/tests/simple/71_ctdb_wipedb.sh
ctdb/tests/simple/72_update_record_persistent.sh
ctdb/tests/simple/75_readonly_records_basic.sh
ctdb/tests/simple/77_ctdb_db_recovery.sh
ctdb/tests/simple/79_volatile_db_traverse.sh
ctdb/tests/simple/80_ctdb_traverse.sh
ctdb/tests/simple/81_tunnel_ring.sh
ctdb/tests/simple/90_debug_hung_script.sh

index b5c8866d67a1d9f1f009ce60f01f06353eb59e15..543472c0f222bcc2682e218ff59df10c2939de14 100755 (executable)
@@ -22,8 +22,8 @@ cluster_is_healthy
 select_test_node_and_ips
 get_test_ip_mask_and_iface
 
-echo "Checking that node ${test_node} hosts ${test_ip} on interface ${iface}..."
-try_command_on_node $test_node "ip addr show dev $iface | grep -E 'inet6?[[:space:]]*${test_ip}/'"
+echo "Checking that node ${test_node} hosts ${test_ip}..."
+try_command_on_node $test_node "ip addr show to ${test_ip} | grep -q ."
 
 echo "Attempting to remove ${test_ip} from node ${test_node}."
 try_command_on_node $test_node $CTDB delip $test_ip
@@ -33,10 +33,10 @@ wait_until_ips_are_on_node '!' $test_node $test_ip
 timeout=60
 increment=5
 count=0
-echo "Waiting for ${test_ip} to disappear from ${iface}..."
+echo "Waiting for ${test_ip} to disappear from node ${test_node}..."
 while : ; do
-    try_command_on_node -v $test_node "ip addr show dev $iface"
-    if echo "$out" | grep -E 'inet6?[[:space:]]*${test_ip}/'; then
+    try_command_on_node -v $test_node "ip addr show to ${test_node}"
+    if -n "$out" ; then
        echo "Still there..."
        if [ $(($count * $increment)) -ge $timeout ] ; then
            echo "BAD: Timed out waiting..."
index 2beff7718746cebd9a5099806f77d8ebdd5321f8..4ba1b26a8e89ddb52e3d15681e2d5d13b0c0d406 100755 (executable)
@@ -48,12 +48,12 @@ select_test_node_and_ips
 
 echo "Getting public IP information from CTDB..."
 try_command_on_node any "$CTDB ip -X -v all"
-ctdb_ip_info=$(echo "$out" | awk -F'|' 'NR > 1 { print $2, $3, $5 }')
+ctdb_ip_info=$(awk -F'|' 'NR > 1 { print $2, $3, $5 }' "$outfile")
 
 echo "Getting IP information from interfaces..."
 try_command_on_node all "ip addr show"
-ip_addr_info=$(echo "$out" | \
-    awk '$1 == "inet" { ip = $2; sub(/\/.*/, "", ip); print ip }')
+ip_addr_info=$(awk '$1 == "inet" { ip = $2; sub(/\/.*/, "", ip); print ip }' \
+                  "$outfile")
 
 prefix=""
 for b in $(seq 0 255) ; do
@@ -168,7 +168,7 @@ check_ips ()
 
     try_command_on_node $test_node "ip addr show dev ${iface}"
     local ip_addrs_file=$(mktemp)
-    echo "$out" | \
+    cat "$outfile" | \
        sed -n -e "s@.*inet * \(${prefix//./\.}\.[0-9]*\)/.*@\1@p" | \
        sort >"$ip_addrs_file"
 
index 4f2cdadbdfc359a6a049b398098efebc7ecee033..bfe3df4e82f511ae83d865a9c66f111a87d862f6 100755 (executable)
@@ -61,13 +61,6 @@ echo "Source socket is $src_socket"
 # we sometimes beat the registration.
 echo "Checking if CIFS connection is tracked by CTDB on test node..."
 wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
-echo "$out"
-
-if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
-    echo "GOOD: CIFS connection tracked OK by CTDB."
-else
-    die "BAD: Socket not tracked by CTDB."
-fi
 
 # This is almost immediate.  However, it is sent between nodes
 # asynchonously, so it is worth checking...
index 0de77722fc38b2fe45f15a1588db6c3e60bd7019..870b80661aa9545cbbb9c3921ad16040dd21a886 100755 (executable)
@@ -59,16 +59,8 @@ echo "Source socket is $src_socket"
 
 # This should happen as soon as connection is up... but unless we wait
 # we sometimes beat the registration.
-echo "Checking if CIFS connection is tracked by CTDB on test node..."
+echo "Waiting until SMB connection is tracked by CTDB on test node..."
 wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
-echo "$out"
-
-if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
-    echo "GOOD: CIFS connection tracked OK by CTDB."
-else
-    echo "BAD: Socket not tracked by CTDB."
-    exit 1
-fi
 
 # It would be nice if ss consistently used local/peer instead of src/dst
 ss_filter="src ${test_ip}:${test_port} dst ${src_socket}"
@@ -80,7 +72,7 @@ if [ -z "$out" ] ; then
        exit 1
 fi
 echo "GOOD: ss lists the socket:"
-echo "$out"
+cat "$outfile"
 
 echo "Disabling node $test_node"
 try_command_on_node 1 $CTDB disable -n $test_node
index 7190af0f552ba14354a5b7685dd611aad8eb8834..32ff9295cc6711141f3d3752d28a44ff26943048 100755 (executable)
@@ -60,7 +60,7 @@ echo "Source socket is $src_socket"
 echo "Wait until NFS connection is tracked by CTDB on test node ..."
 wait_until $((monitor_interval * 2)) \
           check_tickles $test_node $test_ip $test_port $src_socket
-echo "$out"
+cat "$outfile"
 
 # It would be nice if ss consistently used local/peer instead of src/dst
 ss_filter="src ${test_ip}:${test_port} dst ${src_socket}"
@@ -72,7 +72,7 @@ if [ -z "$out" ] ; then
        exit 1
 fi
 echo "GOOD: ss lists the socket:"
-echo "$out"
+cat "$outfile"
 
 echo "Disabling node $test_node"
 try_command_on_node 1 $CTDB disable -n $test_node
index 2fddc06f8674bca18fcde04a421abf235b5cbd04..88e4e554c34abcba1b2284c608cf0b5af1306c41 100755 (executable)
@@ -31,7 +31,7 @@ for i in $all_pnns ; do
                continue
        fi
        try_command_on_node $i "$CTDB ip"
-       n=$(awk -v ip="$test_ip" '$1 == ip { print }' <<<"$out")
+       n=$(awk -v ip="$test_ip" '$1 == ip { print }' "$outfile")
        if [ -n "$n" ] ; then
                other_node="$i"
                break
index 7787de8f111dc4b1551ae3d4fbcaa7e931e3dbda..787f597edcc419cc600e771e449879763a3c28e8 100644 (file)
@@ -67,7 +67,7 @@ check_tickles ()
     local src_socket="$4"
     try_command_on_node $node ctdb gettickles $test_ip $test_port
     # SRC: 10.0.2.45:49091   DST: 10.0.2.143:445
-    [ "${out/SRC: ${src_socket} /}" != "$out" ]
+    grep -Fq "SRC: ${src_socket} " "$outfile"
 }
 
 check_tickles_all ()
@@ -79,8 +79,7 @@ check_tickles_all ()
 
     try_command_on_node all ctdb gettickles $test_ip $test_port
     # SRC: 10.0.2.45:49091   DST: 10.0.2.143:445
-    local t="${src_socket//./\\.}"
-    local count=$(grep -E -c "SRC: ${t} " <<<"$out" || true)
+    local count=$(grep -Fc "SRC: ${src_socket} " "$outfile" || true)
     [ $count -eq $numnodes ]
 }
 
index d9afe898ad29849271f2f655f1bd758c119283a5..ce5bd576b246a1d45dcd6d13cebb413aeea2ec92 100644 (file)
@@ -148,30 +148,7 @@ sanity_check_output ()
     return $ret
 }
 
-sanity_check_ips ()
-{
-    local ips="$1" # list of "ip node" lines
-
-    echo "Sanity checking IPs..."
-
-    local x ipp prev
-    prev=""
-    while read x ipp ; do
-       [ "$ipp" = "-1" ] && break
-       if [ -n "$prev" -a "$ipp" != "$prev" ] ; then
-           echo "OK"
-           return 0
-       fi
-       prev="$ipp"
-    done <<<"$ips"
-
-    echo "BAD: a node was -1 or IPs are only assigned to one node:"
-    echo "$ips"
-    echo "Are you running an old version of CTDB?"
-    return 1
-}
-
-# This returns a list of "ip node" lines in $out
+# This returns a list of "ip node" lines in $outfile
 all_ips_on_node()
 {
     local node="$1"
@@ -192,9 +169,9 @@ _select_test_node_and_ips ()
            test_node="$pnn"
        fi
        if [ "$pnn" = "$test_node" ] ; then
-            test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
+           test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
        fi
-    done <<<"$out" # bashism to avoid problem setting variable in pipeline.
+    done <"$outfile"
 
     echo "Selected node ${test_node} with IPs: ${test_node_ips}."
     test_ip="${test_node_ips%% *}"
@@ -264,7 +241,7 @@ delete_ip_from_all_nodes ()
            if [ "$_ip" = "$_i" ] ; then
                _nodes="${_nodes}${_nodes:+,}${_pnn}"
            fi
-       done <<<"$out" # bashism
+       done <"$outfile"
     done
 
     try_command_on_node -pq "$_nodes" "$CTDB delip $_ip"
@@ -435,7 +412,7 @@ ips_are_on_node ()
            if $negating ; then
                ips="${ips/${check}}"
            fi
-       done <<<"$out" # bashism to avoid problem setting variable in pipeline.
+       done <"$outfile"
     done
 
     ips="${ips// }" # Remove any spaces.
@@ -477,7 +454,7 @@ node_has_some_ips ()
        if [ "$node" = "$pnn" ] ; then
            return 0
        fi
-    done <<<"$out" # bashism to avoid problem setting variable in pipeline.
+    done <"$outfile"
 
     return 1
 }
@@ -614,7 +591,8 @@ wait_for_monitor_event ()
        return 1
     }
 
-    local ctdb_scriptstatus_original="$out"
+    mv "$outfile" "${outfile}.orig"
+
     wait_until 120 _ctdb_scriptstatus_changed
 }
 
@@ -625,7 +603,7 @@ _ctdb_scriptstatus_changed ()
        return 1
     }
 
-    [ "$out" != "$ctdb_scriptstatus_original" ]
+    ! diff "$outfile" "${outfile}.orig" >/dev/null
 }
 
 #######################################
index e205da217e613ceeb17c47dc7f20088f89652fab..2e7a08b6f6fe6680c738663e0f8dd7811b7051de 100755 (executable)
@@ -23,7 +23,6 @@ sanity_check_output \
 
 echo "Verifying all variable values using \"ctdb getvar\"..."
 
-echo "$out" |
 while read var x val ; do
     try_command_on_node 0 "$CTDB getvar $var"
 
@@ -33,7 +32,7 @@ while read var x val ; do
        echo "MISMATCH on $var: $val != $val2"
        exit 1
     fi
-done
+done <"$outfile"
 
 echo "GOOD: all tunables match"
 
index 0adb291f758cf0192e3d36dce12c34025d123d3a..722c9d2a0354f70c07cbbbd85eaee80acd2d1d7b 100755 (executable)
@@ -32,7 +32,7 @@ cluster_is_healthy
 
 try_command_on_node -v 0 "$CTDB listnodes"
 
-num_nodes=$(echo "$out" | wc -l)
+num_nodes=$(wc -l <"$outfile")
 
 # Each line should look like an IP address.
 ipv4_pat='[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'
index 12c8164b223f88c29cdc27719d30032407d8d1d3..68e22879ba3e5318cc283f5f161c21bdec72b036 100755 (executable)
@@ -33,13 +33,11 @@ set -e
 cluster_is_healthy
 
 cmd="$CTDB isnotrecmaster || true"
-try_command_on_node all "$cmd"
-echo "Output of \"$cmd\":"
-echo "$out"
+try_command_on_node -v all "$cmd"
 
-num_all_lines=$(echo "$out" |  wc -l)
-num_rm_lines=$(echo "$out" | fgrep -c 'this node is the recmaster') || true
-num_not_rm_lines=$(echo "$out" | fgrep -c 'this node is not the recmaster') || true
+num_all_lines=$(wc -l <"$outfile")
+num_rm_lines=$(grep -Fc 'this node is the recmaster' "$outfile") || true
+num_not_rm_lines=$(grep -Fc 'this node is not the recmaster' "$outfile") || true
 
 if [ $num_rm_lines -eq 1 ] ; then
     echo "OK, there is only 1 recmaster"
index 4b11729a1e1eab6d0023a53e54dfcb73c8be7595..d9fdd28f77543e26078fbf9d6df7b6f3660b1bf3 100755 (executable)
@@ -33,18 +33,20 @@ cluster_is_healthy
 
 echo "Getting list of public IPs..."
 try_command_on_node -v 1 "$CTDB ip all | tail -n +2"
-ips=$(echo "$out" | sed \
+ips=$(sed \
        -e 's@ node\[@ @' \
-       -e 's@\].*$@@')
-machineout=$(echo "$out" | sed -r \
+       -e 's@\].*$@@' \
+       "$outfile")
+machineout=$(sed -r \
        -e 's@^| |$@\|@g' \
        -e 's@[[:alpha:]]+\[@@g' \
-       -e 's@\]@@g')
+       -e 's@\]@@g' \
+       "$outfile")
 
 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
+               try_command_on_node $pnn "ip addr show to ${ip}"
+               if [ -n "$out" ] ; then
                        echo "GOOD: node $pnn appears to have $ip assigned"
                else
                        die "BAD: node $pnn does not appear to have $ip assigned"
index 8843a4dd9f7537f3319c015b349e56b10ff2ada1..1dce7b39965500a514c83c55b151eba487735671 100755 (executable)
@@ -37,10 +37,11 @@ num_nodes="$out"
 
 get_stat ()
 {
-    local label="$1"
-    local out="$2"
+       local label="$1"
 
-    echo "$out" | sed -rn -e "s@^[[:space:]]+${label}[[:space:]]+([[:digit:]])@\1@p" | head -1
+       cat "$outfile" |
+       sed -rn -e "s@^[[:space:]]+${label}[[:space:]]+([[:digit:]])@\1@p" |
+       head -1
 }
 
 check_reduced ()
@@ -59,20 +60,20 @@ check_reduced ()
 n=0
 while [ $n -lt $num_nodes ] ; do
     echo "Getting initial statistics for node ${n}..."
-    
+
     try_command_on_node -v $n $CTDB statistics
 
-    before_req_control=$(get_stat "req_control" "$out")
-    before_reply_control=$(get_stat "reply_control" "$out")
-    before_node_packets_recv=$(get_stat "node_packets_recv" "$out")
+    before_req_control=$(get_stat "req_control")
+    before_reply_control=$(get_stat "reply_control")
+    before_node_packets_recv=$(get_stat "node_packets_recv")
 
     try_command_on_node $n $CTDB statisticsreset
 
     try_command_on_node -v $n $CTDB statistics
 
-    after_req_control=$(get_stat "req_control" "$out")
-    after_reply_control=$(get_stat "reply_control" "$out")
-    after_node_packets_recv=$(get_stat "node_packets_recv" "$out")
+    after_req_control=$(get_stat "req_control")
+    after_reply_control=$(get_stat "reply_control")
+    after_node_packets_recv=$(get_stat "node_packets_recv")
 
     check_reduced "req_control" "$before_req_control" "$after_req_control"
     check_reduced "reply_control" "$before_reply_control" "$after_reply_control"
index 8aedb339d94bf22ef9b4da466ae15638e4b7c9fd..93caf668c0bc80ea46c91483b2ac7a65457e7bfc 100755 (executable)
@@ -34,9 +34,7 @@ while read ip pnn ; do
        if [ "$pnn" != "-1" ] ; then
                die "BAD: IP address ${ip} is assigned to node ${pnn}"
        fi
-done <<EOF
-$out
-EOF
+done <"$outfile"
 
 echo "GOOD: All IP addresses are unassigned"
 
index 6cc39580c5eb43edd2703d34744990a7bc90fa35..2756f64ceb1c195ad56d41ff44cf3066c78c20bd 100755 (executable)
@@ -19,14 +19,14 @@ select_test_node_and_ips
 
 # Find interfaces on test node
 try_command_on_node $test_node "$CTDB ifaces -X"
-ifaces=$(awk -F'|' 'NR > 1 { print $2 }' <<<"$out")
+ifaces=$(awk -F'|' 'NR > 1 { print $2 }' "$outfile")
 echo "Node ${test_node} has 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 -X"
-    info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out")
+    info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' "$outfile")
 
     if [ -z "$info" ] ; then
        echo "Interface ${i} missing... assuming already deleted!"
@@ -38,7 +38,7 @@ for i in $ifaces ; do
 
     try_command_on_node $test_node "$CTDB ip -v -X | tail -n +2"
     awk -F'|' -v i="$i" \
-       '$6 == i { print $2 }' <<<"$out" |
+       '$6 == i { print $2 }' "$outfile" |
     while read ip ; do
        echo "  $ip"
        try_command_on_node $test_node "$CTDB delip $ip"
@@ -46,8 +46,8 @@ for i in $ifaces ; do
     try_command_on_node $test_node "$CTDB ipreallocate"
 
     try_command_on_node $test_node "$CTDB ifaces -X"
-    info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' <<<"$out")
-    
+    info=$(awk -F'|' -v iface="$i" '$2 == iface { print $0 }' "$outfile")
+
     if [ -z "$info" ] ; then
        echo "GOOD: Interface ${i} has been garbage collected"
     else
index 88f91e69acdde76c2d9c55e1a4ee47cc6ff5ddf3..7965ced6052375114d897adee35d38b32018696c 100755 (executable)
@@ -36,9 +36,8 @@ cluster_is_healthy
 
 ######################################################################
 
-try_command_on_node 0 "$CTDB listnodes -X"
-listnodes_output="$out"
-numnodes=$(wc -l <<<"$listnodes_output")
+try_command_on_node 0 "$CTDB listnodes -X | wc -l"
+numnodes="$out"
 lastnode=$(( numnodes - 1 ))
 
 ######################################################################
@@ -55,7 +54,7 @@ check_db ()
        echo "$out"
        exit 1
     else
-       local flags=$(awk '{print $4}' <<<"$out") || true
+       local flags=$(awk '{print $4}' "$outfile") || true
        if [ "$flags" = "$flag" ]; then
            echo "GOOD: database $db is attached on node $node with flag $flag"
        else
index 4220d1268e48e3e67df563c24861562e20dbacb1..699ccc3d2ee9a5de0f756663dec4d3e0b5abcf9d 100755 (executable)
@@ -23,7 +23,28 @@ cluster_is_healthy
 
 select_test_node_and_ips
 
-sanity_check_ips "$out"
+sanity_check_ips ()
+{
+    echo "Sanity checking IPs..."
+
+    local x ipp prev
+    prev=""
+    while read x ipp ; do
+       [ "$ipp" = "-1" ] && break
+       if [ -n "$prev" -a "$ipp" != "$prev" ] ; then
+           echo "OK"
+           return 0
+       fi
+       prev="$ipp"
+    done <"$outfile"
+
+    echo "BAD: a node was -1 or IPs are only assigned to one node:"
+    cat "$outfile"
+    echo "Are you running an old version of CTDB?"
+    return 1
+}
+
+sanity_check_ips
 
 # Find a target node - it must be willing to host $test_ip
 try_command_on_node any "$CTDB listnodes | wc -l"
@@ -37,7 +58,7 @@ for i in $(seq 0 $(($num_nodes - 1)) ) ; do
            to_node="$i"
            break 2
        fi
-    done <<<"$out"
+    done <"$outfile"
 done
 
 if [ -z "$to_node" ] ; then
index 612fec1b49bfe7a55e5878aa50c1bf8234c4b883..32d6d26a4fff6fc61c0e28272064cc205f7889dd 100755 (executable)
@@ -44,7 +44,7 @@ db_map_pattern='^(Number of databases:[[:digit:]]+|dbid:0x[[:xdigit:]]+ name:[^[
 
 sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern"
 
-num_db_init=$(echo "$out" | sed -n -e '1s/.*://p')
+num_db_init=$(sed -n -e '1s/.*://p' "$outfile")
 
 for i in $(seq 1 5) ; do
     f=$(make_temp_db_filename)
@@ -52,14 +52,14 @@ for i in $(seq 1 5) ; do
     try_command_on_node 0 $CTDB attach "$f"
     try_command_on_node 0 $CTDB getdbmap
     sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern"
-    num=$(echo "$out" | sed -n -e '1s/^.*://p')
+    num=$(sed -n -e '1s/^.*://p' "$outfile")
     if [ $num = $(($num_db_init + $i)) ] ; then
        echo "OK: correct number of additional databases"
     else
        echo "BAD: no additional database"
        exit 1
     fi
-    if [ "${out/name:${f} /}" != "$out" ] ; then
+    if awk '{print $2}' "$outfile" | grep -Fqx "name:$f" ; then
        echo "OK: getdbmap knows about \"$f\""
     else
        echo "BAD: getdbmap does not know about \"$f\""
index f356c820260aa0d91e408240a7741751049f923f..d7c0c0f9100bd51cf15dcca22b4fe8dad2077682 100755 (executable)
@@ -42,8 +42,8 @@ cluster_is_healthy
 
 test_node=1
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 echo "There are $num_nodes nodes."
 
 echo "Shutting down node ${test_node}..."
@@ -58,7 +58,7 @@ pat="ctdb_control error: 'ctdb_control to disconnected node'|ctdb_control error:
 for i in ip disable enable "ban 0" unban listvars ; do
     try_command_on_node -v 0 ! $CTDB $i -n $test_node
 
-    if egrep -q "$pat" <<<"$out" ; then
+    if egrep -q "$pat" "$outfile" ; then
        echo "OK: \"ctdb ${i}\" fails with expected \"disconnected node\" message"
     else
        echo "BAD: \"ctdb ${i}\" does not fail with expected \"disconnected node\" message"
index e8ca2382e886ff11bd17669f3f171cff8033eeed..f7f7a7e8c4072ff171ba4892ec9c750095e895f1 100755 (executable)
@@ -32,9 +32,8 @@ cluster_is_healthy
 
 ######################################################################
 
-try_command_on_node 0 "$CTDB listnodes -X"
-listnodes_output="$out"
-numnodes=$(wc -l <<<"$listnodes_output")
+try_command_on_node 0 "$CTDB listnodes -X | wc -l"
+numnodes="$out"
 
 ######################################################################
 
@@ -43,12 +42,12 @@ check_db ()
 {
     db="$1"
     try_command_on_node all $CTDB getdbmap
-    local num_db=$(grep -cF "$db" <<<"$out") || true
+    local num_db=$(grep -cF "$db" "$outfile") || true
     if [ $num_db -eq $numnodes ]; then
        echo "GOOD: database $db is attached on all nodes"
     else
        echo "BAD: database $db is not attached on all nodes"
-       echo "$out"
+       cat "$outfile"
        exit 1
     fi
 }
@@ -58,12 +57,12 @@ check_no_db ()
 {
     db="$1"
     try_command_on_node all $CTDB getdbmap
-    local num_db=$(grep -cF "$db" <<<"$out") || true
+    local num_db=$(grep -cF "$db" "$outfile") || true
     if [ $num_db -eq 0 ]; then
        echo "GOOD: database $db is not attached any more"
     else
        echo "BAD: database $db is still attached"
-       echo "$out"
+       cat "$outfile"
        exit 1
     fi
 }
@@ -134,12 +133,12 @@ echo
 echo "Write a key to database"
 try_command_on_node 0 $CTDB writekey $testdb1 foo bar
 try_command_on_node 0 $CTDB catdb $testdb1
-num_keys=$(echo "$out" | sed -n -e 's/Dumped \([0-9]*\) records/\1/p') || true
+num_keys=$(sed -n -e 's/Dumped \([0-9]*\) records/\1/p' "$outfile") || true
 if [ -n "$num_keys" -a $num_keys -eq 1 ]; then
     echo "GOOD: Key added to database"
 else
     echo "BAD: Key did not get added to database"
-    echo "$out"
+    cat "$outfile"
     exit 1
 fi
 
@@ -158,11 +157,11 @@ check_db "$testdb1"
 echo
 echo "Check if the database is empty"
 try_command_on_node 0 $CTDB catdb $testdb1
-num_keys=$(echo "$out" | sed -n -e 's/Dumped \([0-9]*\) records/\1/p') || true
+num_keys=$(sed -n -e 's/Dumped \([0-9]*\) records/\1/p' "$outfile") || true
 if [ -n "$num_keys" -a $num_keys -eq 0 ]; then
     echo "GOOD: Database $testdb1 is empty"
 else
     echo "BAD: Database $testdb1 is not empty"
-    echo "$out"
+    cat "$outfile"
     exit 1
 fi
index 0a2f3d5b92e72912566bd33debc5269bdb2db4ca..8cedd34045b37f85e86dcf113d1c1e45146bf1aa 100755 (executable)
@@ -25,7 +25,7 @@ if [ -z "$out" ] ; then
     exit 0
 fi
 
-n=$(echo "$out" | sort -u | wc -l)
+n=$(sort -u "$outfile" | wc -l)
 if [ "$n" = 1 ] ; then
        echo "GOOD: All nodes have the same recovery lock setting"
 else
index f6f064e43bf83bf181e58d16cc6872474ca13d54..6f90c8fd5bb908ab0689dc2cc23c979d95205924 100755 (executable)
@@ -19,23 +19,21 @@ set -e
 
 cluster_is_healthy
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 echo "Running message_ring on all $num_nodes nodes."
 try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND message_ring -n $num_nodes
 
 # Get the last line of output.
-while read line ; do
-    prev=$line
-done <<<"$out"
+last=$(tail -n 1 "$outfile")
 
 pat='^(Waiting for cluster|Ring\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec \(\+ve=[[:digit:]]+ -ve=[[:digit:]]+\))$'
 sanity_check_output 1 "$pat"
 
-# $prev should look like this:
+# $last should look like this:
 #    Ring[1]: 10670.93 msgs/sec (+ve=53391 -ve=53373)
-stuff="${prev##Ring\[*\]: }"
+stuff="${last##Ring\[*\]: }"
 mps="${stuff% msgs/sec*}"
 
 if [ ${mps%.*} -ge 10 ] ; then
index bdd8186c49e4eea31707456d52a9625803d81f32..05632024cb50404567004876bfa5a2a63a506b61 100755 (executable)
@@ -19,8 +19,8 @@ set -e
 
 cluster_is_healthy
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 echo "Running fetch_ring on all $num_nodes nodes."
 try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND fetch_ring -n $num_nodes
@@ -29,13 +29,11 @@ pat='^(Waiting for cluster|Fetch\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)?
 sanity_check_output 1 "$pat"
 
 # Get the last line of output.
-while read line ; do
-    prev=$line
-done <<<"$out"
+last=$(tail -n 1 "$outfile")
 
-# $prev should look like this:
+# $last should look like this:
 #    Fetch[1]: 10670.93 msgs/sec
-stuff="${prev##*Fetch\[*\]: }"
+stuff="${last##*Fetch\[*\]: }"
 mps="${stuff% msgs/sec*}"
 
 if [ ${mps%.*} -ge 10 ] ; then
index 2102e401384af052a688fef464f1433ceeadb3e3..d47761216cead9501b454321f157b3cab741d15c 100755 (executable)
@@ -24,8 +24,8 @@ TESTDB="persistent_trans.tdb"
 try_command_on_node 0 "$CTDB attach $TESTDB persistent"
 try_command_on_node 0 "$CTDB wipedb $TESTDB"
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 if [ -z "$CTDB_TEST_TIMELIMIT" ] ; then
     CTDB_TEST_TIMELIMIT=30
index 61ac29ca1784606047c9c5a7b37a873f33552fcc..7beacb9c913a5eba6d78507c14f1686e6a28b183 100755 (executable)
@@ -43,8 +43,8 @@ TESTDB="persistent_trans.tdb"
 try_command_on_node 0 "$CTDB attach $TESTDB persistent"
 try_command_on_node 0 "$CTDB wipedb $TESTDB"
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 if [ -z "$CTDB_TEST_TIMELIMIT" ] ; then
     CTDB_TEST_TIMELIMIT=30
index e7db3aea45688fd4044530d7bb2fe9bf76b7c59b..72b183483980631d9137c597f9b10e3193dccf54 100755 (executable)
@@ -51,11 +51,11 @@ echo "$items" | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
 
 try_command_on_node 0 $CTDB catdb "$TESTDB"
 
-n=$(echo "$out" | grep -c '^key.*= "key.*"' || true)
+n=$(grep -c '^key.*= "key.*"' "$outfile" || true)
 
 if [ $n -ne 3 ] ; then
     echo "BAD: expected 3 keys in..."
-    echo "$out"
+    cat "$outfile"
     exit 1
 else
     echo "GOOD: 3 records were inserted"
@@ -75,11 +75,11 @@ echo "$items" | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
 
 try_command_on_node 0 $CTDB catdb "$TESTDB"
 
-n=$(echo "$out" | grep -c '^key.*= "key.*"' || true)
+n=$(grep -c '^key.*= "key.*"' "$outfile" || true)
 
 if [ $n -ne 3 ] ; then
     echo "BAD: expected 3 keys in..."
-    echo "$out"
+    cat "$outfile"
     exit 1
 else
     echo "GOOD: 3 records found"
@@ -116,11 +116,11 @@ echo "$items" | try_command_on_node -i 0 $CTDB ptrans "$TESTDB"
 
 try_command_on_node 0 $CTDB catdb "$TESTDB"
 
-n=$(echo "$out" | grep -c '^key.*= "key.*"' || true)
+n=$(grep -c '^key.*= "key.*"' "$outfile" || true)
 
 if [ $n -ne 0 ] ; then
     echo "BAD: expected 0 keys in..."
-    echo "$out"
+    cat "$outfile"
     exit 1
 else
     echo "GOOD: 0 records found"
index f09ed550c82e85dd052f45a973494e56f450429e..4d5c1297fa940a0f327de42d7a67a03e62622d11 100755 (executable)
@@ -44,8 +44,8 @@ TESTDB="replicated_trans.tdb"
 try_command_on_node 0 "$CTDB attach $TESTDB replicated"
 try_command_on_node 0 "$CTDB wipedb $TESTDB"
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 if [ -z "$CTDB_TEST_TIMELIMIT" ] ; then
     CTDB_TEST_TIMELIMIT=30
index eacbdfc5465d0335e124c3fe28ad54bcafe2536e..579233e0e8023446c29595ce75bad73effc124d8 100755 (executable)
@@ -36,10 +36,10 @@ set -e
 cluster_is_healthy
 
 try_command_on_node 0 $CTDB status
-generation=$(echo "$out" | sed -n -e 's/^Generation:\([0-9]*\)/\1/p')
+generation=$(sed -n -e 's/^Generation:\([0-9]*\)/\1/p' "$outfile")
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 # 2.
 test_db="restoredb_test.tdb"
@@ -105,7 +105,7 @@ fi
 wait_until_ready
 
 try_command_on_node 0 $CTDB status
-new_generation=$(echo "$out" | sed -n -e 's/^Generation:\([0-9]*\)/\1/p')
+new_generation=$(sed -n -e 's/^Generation:\([0-9]*\)/\1/p' "$outfile")
 
 echo "Old generation = $generation"
 echo "New generation = $new_generation"
index 2c8fc12edef7f11b58ec1c8a449069e5037daeeb..8126c49b83c0afc364c46b7f6290df3edcfa8164 100755 (executable)
@@ -20,9 +20,9 @@ testdb="rec_test.tdb"
 echo "Getting list of nodes..."
 try_command_on_node -v any "onnode -pq all ctdb pnn | grep '^[0-9][0-9]*$'"
 
-first=$(echo "$out" | sed -n -e '1p')
-second=$(echo "$out" | sed -n -e '2p')
-notfirst=$(echo "$out" | tail -n +2)
+first=$(sed -n -e '1p' "$outfile")
+second=$(sed -n -e '2p' "$outfile")
+notfirst=$(tail -n +2 "$outfile")
 
 echo "Create/wipe test database ${testdb}"
 try_command_on_node $first $CTDB attach "$testdb"
@@ -46,7 +46,7 @@ database_has_zero_records ()
        local n
        for n in $notfirst ; do
                try_command_on_node $n $CTDB cattdb "$testdb"
-               if echo "$out" | grep -q '^key(' ; then
+               if grep -q '^key(' "$outfile" ; then
                        return 1
                fi
        done
@@ -74,7 +74,7 @@ wait_until_node_has_status $first notstopped
 echo "Get database contents"
 try_command_on_node -v $first $CTDB catdb "$testdb"
 
-if echo "$out" | grep -q '^key(' ; then
+if grep -q '^key(' "$outfile" ; then
        echo "BAD: Deleted record has been resurrected"
        exit 1
 fi
index 1722288b5629ac0749db3c5cfc7d101146580891..84e0ec15c43c78ed22acacccbddcb1621cd7205c 100755 (executable)
@@ -35,8 +35,8 @@ set -e
 
 cluster_is_healthy
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 add_record_per_node ()
 {
index 6fae93b0a43a47a1f87a79756ac8793a7d172b08..9305339d1e3fb68c6369d0300e100842ee637829 100755 (executable)
@@ -32,8 +32,8 @@ set -e
 
 cluster_is_healthy
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 # 2.
 test_db="persistent_test.tdb"
index 4ab69d81b61ce048c789dea445351d09c7333a30..90b5ee0615143dd1437c41fa5b6ff363d80e6018 100755 (executable)
@@ -34,8 +34,8 @@ set -e
 
 cluster_is_healthy
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 test_db="persistent_test.tdb"
 
index c5662f571c6468f0e93f7a5d5f7054a471b2927c..a83b4d315300a17245cd78362fa4d8b048df5c22 100755 (executable)
@@ -49,12 +49,12 @@ check_no_readonly ()
 {
     try_command_on_node all $CTDB cattdb $testdb
     local ro_flags="RO_HAVE_READONLY|RO_HAVE_DELEGATIONS"
-    local numreadonly=$(grep -c -E "$ro_flags" <<<"$out") || true
+    local numreadonly=$(grep -c -E "$ro_flags" "$outfile") || true
     if [ $numreadonly -eq 0 ] ; then
        echo "GOOD: no read-only delegations"
     else
        echo "BAD: there are read-only delegations"
-       echo "$out"
+       cat "$outfile"
        exit 1
     fi
 }
@@ -72,36 +72,36 @@ check_readonly ()
     local count
 
     try_command_on_node $dmaster $CTDB cattdb $testdb
-    count=$(grep -c -E "RO_HAVE_DELEGATIONS" <<<"$out") || true
+    count=$(grep -c -E "RO_HAVE_DELEGATIONS" "$outfile") || true
     if [ $count -eq 1 ] ; then
        echo "GOOD: dmaster ${dmaster} has read-only delegations"
     else
        echo "BAD: dmaster ${dmaster} has no read-only delegations"
-       echo "$out"
+       cat "$outfile"
        exit 1
     fi
-    count=$(grep -c -E "RO_HAVE_READONLY" <<<"$out") || true
+    count=$(grep -c -E "RO_HAVE_READONLY" "$outfile") || true
     if [ $count -ne 0 ] ; then
        echo "BAD: dmaster ${dmaster} has a read-only copy"
-       echo "$out"
+       cat "$outfile"
        exit 1
     fi
 
     local o
     for o in $others ; do
        try_command_on_node $o $CTDB cattdb $testdb
-       count=$(grep -c -E "RO_HAVE_READONLY" <<<"$out") || true
+       count=$(grep -c -E "RO_HAVE_READONLY" "$outfile") || true
        if [ $count -eq 1 ] ; then
            echo "GOOD: node ${o} has a read-only copy"
        else
            echo "BAD: node ${o} has no read-only copy"
-           echo "$out"
+           cat "$outfile"
            exit 1
        fi
-       count=$(grep -c -E "RO_HAVE_DELEGATIONS" <<<"$out") || true
+       count=$(grep -c -E "RO_HAVE_DELEGATIONS" "$outfile") || true
        if [ $count -ne 0 ] ; then
            echo "BAD: other node ${o} has read-only delegations"
-           echo "$out"
+           cat "$outfile"
            exit 1
        fi
     done
@@ -111,7 +111,7 @@ check_readonly ()
 
 echo "Get list of nodes..."
 try_command_on_node any $CTDB -X listnodes
-all_nodes=$(awk -F'|' '{print $2}' <<<"$out")
+all_nodes=$(awk -F'|' '{print $2}' "$outfile")
 
 ######################################################################
 
@@ -138,7 +138,7 @@ try_command_on_node all $CTDB setdbreadonly $testdb
 
 # Database should be tagged as READONLY
 try_command_on_node 0 $CTDB getdbmap
-db_details=$(awk -v db="$testdb" '$2 == foo="name:" db { print }' <<<"$out")
+db_details=$(awk -v db="$testdb" '$2 == foo="name:" db { print }' "$outfile")
 if grep -q "READONLY" <<<"$db_details" ; then
     echo "GOOD: read-only record support is enabled"
 else
index b2703eedbc44ccd1542031d24a1303baa0b8dfc5..a8bc2d95ef6f5414d2c0a075896bd395e86236f9 100755 (executable)
@@ -93,7 +93,7 @@ try_command_on_node $recmaster $CTDB writekey $TESTDB test1 value1
 # Fetch a record   key=test1
 echo "read key(test1)"
 try_command_on_node $recmaster $CTDB readkey $TESTDB test1
-echo "$out"
+cat "$outfile"
 
 # Do a recovery
 echo "force recovery"
@@ -108,7 +108,7 @@ try_command_on_node $recmaster $CTDB writekey $TESTDB test1 value2
 # Fetch a record   key=test1
 echo "read key(test1)"
 try_command_on_node $recmaster $CTDB readkey $TESTDB test1
-echo "$out"
+cat "$outfile"
 
 # Do a recovery
 echo "force recovery"
@@ -119,7 +119,7 @@ wait_until_node_has_status $recmaster recovered
 # Verify record   key=test1
 echo "read key(test1)"
 try_command_on_node $recmaster $CTDB readkey $TESTDB test1
-echo "$out"
+cat "$outfile"
 if [ "$out" = "Data: size:6 ptr:[value2]" ]; then
        echo "GOOD: Recovery did not corrupt database"
 else
index b98be4d23f9b6c057d4da653334fbe3cdf11ce68..af7e962f579ec43bfb64ff1d3444ead70e16fba8 100755 (executable)
@@ -75,7 +75,7 @@ try_command_on_node 1 $CTDB writekey "$TESTDB" "foo" "bar1"
 echo "do traverse on node 0"
 try_command_on_node -v 0 $CTDB catdb "$TESTDB"
 
-num=$(echo "$out" | sed -n -e 's|^Dumped \(.*\) records$|\1|p')
+num=$(sed -n -e 's|^Dumped \(.*\) records$|\1|p' "$outfile")
 if [ "$num" = 1 ] ; then
        echo "OK: There was 1 record"
 else
@@ -83,7 +83,7 @@ else
        exit 1
 fi
 
-if echo "$out" | grep -q "^data(4) = \"bar1\"\$" ; then
+if grep -q "^data(4) = \"bar1\"\$" "$outfile" ; then
        echo "OK: Data from node 1 was returned"
 else
        echo "BAD: Data from node 1 was not returned"
index 544d8932cd966fd1250b33f1f55961a13f748471..d28f9c2814e1ad9be38d9a6b459c49a24237452d 100755 (executable)
@@ -58,7 +58,7 @@ done
 echo "Start a traverse and collect records"
 try_command_on_node 0 $CTDB catdb $TESTDB
 
-num_read=$(echo "$out" | tail -n 1 | cut -d\  -f2)
+num_read=$(tail -n 1 "$outfile" | cut -d\  -f2)
 if [ $num_read -eq $num_records ]; then
        echo "GOOD: All $num_records records retrieved"
        status=0
index 990039abfcb29f11a23599df55c010ba3ada7a5c..c78c4209ea6474f444a8bb85eecf01eefb231edc 100755 (executable)
@@ -19,24 +19,22 @@ set -e
 
 cluster_is_healthy
 
-try_command_on_node 0 "$CTDB listnodes"
-num_nodes=$(echo "$out" | wc -l)
+try_command_on_node 0 "$CTDB listnodes | wc -l"
+num_nodes="$out"
 
 echo "Running tunnel_test on all $num_nodes nodes."
 try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND \
        tunnel_test -t 30 -n $num_nodes
 
 # Get the last line of output.
-while read line ; do
-    prev=$line
-done <<<"$out"
+last=$(tail -n 1 "$outfile")
 
 pat='^(Waiting for cluster|pnn\[[[:digit:]]+\] [[:digit:]]+(\.[[:digit:]]+)? msgs/sec)$'
 sanity_check_output 1 "$pat"
 
-# $prev should look like this:
+# $last should look like this:
 #    pnn[2] count=85400
-stuff="${prev##pnn\[*\] }"
+stuff="${last##pnn\[*\] }"
 mps="${stuff% msgs/sec}"
 
 if [ ${mps%.*} -ge 10 ] ; then
index 9e2072c98b62839c96560aa982099741cfa28e07..e8cdefec73494231d39bce7be20fe9c5e7650cb8 100755 (executable)
@@ -54,11 +54,9 @@ wait_for_monitor_event $test_node
 
 echo "Waiting for debugging output to appear..."
 # Use test -s because the file is created above using mktemp
-wait_until 60 onnode $test_node test -s "$debug_output"
+wait_until 60 test -s "$debug_output"
 
 echo "Checking output of hung script debugging..."
-try_command_on_node -v $test_node cat "$debug_output"
-hung_script_output="$out"
 
 # Can we actually read kernel stacks
 if try_command_on_node $test_node "cat /proc/$$/stack >/dev/null 2>&1" ; then
@@ -72,7 +70,7 @@ fi
 
 while IFS="" read pattern ; do
     [ -n "$pattern" ] || continue
-    if grep -- "^${pattern}\$" <<<"$hung_script_output" >/dev/null ; then
+    if grep -q -- "^${pattern}\$" "$debug_output" ; then
        printf 'GOOD: output contains "%s"\n' "$pattern"
     else
        printf 'BAD: output does not contain "%s"\n' "$pattern"