diff options
author | Martin Schwenke <martin@meltin.net> | 2019-04-30 12:09:26 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-05-17 07:18:29 +0000 |
commit | 7c97bc83284e09ac028a0a7ce04b039b97eae0c7 (patch) | |
tree | 43c0c5482e556ca5e38f166043eedd9e4544284e /ctdb | |
parent | 30b5d837d5dc863275cc685e1f4f80d866be7bdf (diff) | |
download | samba-7c97bc83284e09ac028a0a7ce04b039b97eae0c7.tar.gz |
ctdb-tests: Change sanity_check_output() to internally use $out
All callers are currently passed $out. Global variable $out is used
in many other places so use it here to simplify the interface and make
future changes simpler.
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>
(cherry picked from commit 7c3819d1ac264acf998f426e0cef7f6211e0ddee)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/tests/scripts/integration.bash | 5 | ||||
-rwxr-xr-x | ctdb/tests/simple/02_ctdb_listvars.sh | 3 | ||||
-rwxr-xr-x | ctdb/tests/simple/05_ctdb_listnodes.sh | 3 | ||||
-rwxr-xr-x | ctdb/tests/simple/09_ctdb_ping.sh | 6 | ||||
-rwxr-xr-x | ctdb/tests/simple/12_ctdb_getdebug.sh | 3 | ||||
-rwxr-xr-x | ctdb/tests/simple/14_ctdb_statistics.sh | 2 | ||||
-rwxr-xr-x | ctdb/tests/simple/24_ctdb_getdbmap.sh | 4 | ||||
-rwxr-xr-x | ctdb/tests/simple/25_dumpmemory.sh | 4 | ||||
-rwxr-xr-x | ctdb/tests/simple/51_message_ring.sh | 2 | ||||
-rwxr-xr-x | ctdb/tests/simple/52_fetch_ring.sh | 2 | ||||
-rwxr-xr-x | ctdb/tests/simple/81_tunnel_ring.sh | 2 |
11 files changed, 15 insertions, 21 deletions
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index 3750c442eba..bc4d2b429ff 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -113,11 +113,10 @@ sanity_check_output () { local min_lines="$1" local regexp="$2" # Should be anchored as necessary. - local output="$3" local ret=0 - local num_lines=$(echo "$output" | wc -l) + local num_lines=$(echo "$out" | wc -l) echo "There are $num_lines lines of output" if [ $num_lines -lt $min_lines ] ; then echo "BAD: that's less than the required number (${min_lines})" @@ -126,7 +125,7 @@ sanity_check_output () local status=0 local unexpected # local doesn't pass through status of command on RHS. - unexpected=$(echo "$output" | egrep -v "$regexp") || status=$? + unexpected=$(echo "$out" | egrep -v "$regexp") || status=$? # Note that this is reversed. if [ $status -eq 0 ] ; then diff --git a/ctdb/tests/simple/02_ctdb_listvars.sh b/ctdb/tests/simple/02_ctdb_listvars.sh index 2f709a8cc0d..9041b6cd216 100755 --- a/ctdb/tests/simple/02_ctdb_listvars.sh +++ b/ctdb/tests/simple/02_ctdb_listvars.sh @@ -37,5 +37,4 @@ try_command_on_node -v 0 "$CTDB listvars" sanity_check_output \ 5 \ - '^[[:alpha:]][[:alnum:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' \ - "$out" + '^[[:alpha:]][[:alnum:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' diff --git a/ctdb/tests/simple/05_ctdb_listnodes.sh b/ctdb/tests/simple/05_ctdb_listnodes.sh index 9e48a68e3c0..87aa776d038 100755 --- a/ctdb/tests/simple/05_ctdb_listnodes.sh +++ b/ctdb/tests/simple/05_ctdb_listnodes.sh @@ -39,8 +39,7 @@ ipv4_pat='[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' ipv6_pat='[[:xdigit:]]+:[[:xdigit:]:]+[[:xdigit:]]+' sanity_check_output \ 2 \ - "^${ipv4_pat}|${ipv6_pat}\$" \ - "$out" + "^${ipv4_pat}|${ipv6_pat}\$" out_0="$out" diff --git a/ctdb/tests/simple/09_ctdb_ping.sh b/ctdb/tests/simple/09_ctdb_ping.sh index ab6ba146df6..40006a221d0 100755 --- a/ctdb/tests/simple/09_ctdb_ping.sh +++ b/ctdb/tests/simple/09_ctdb_ping.sh @@ -42,8 +42,7 @@ try_command_on_node -v 0 "$CTDB ping -n 1" sanity_check_output \ 1 \ - '^response from 1 time=-?[.0-9]+ sec[[:space:]]+\([[:digit:]]+ clients\)$' \ - "$out" + '^response from 1 time=-?[.0-9]+ sec[[:space:]]+\([[:digit:]]+ clients\)$' try_command_on_node -v 0 "$CTDB shutdown -n 1" @@ -53,5 +52,4 @@ try_command_on_node -v 0 "! $CTDB ping -n 1" sanity_check_output \ 1 \ - "(: ctdb_control error: ('ctdb_control to disconnected node'|'node is disconnected')|Unable to get ping response from node 1|Node 1 is DISCONNECTED|ctdb_control for getpnn failed|: Can not access node. Node is not operational\.|Node 1 has status DISCONNECTED\|UNHEALTHY\|INACTIVE$)" \ - "$out" + "(: ctdb_control error: ('ctdb_control to disconnected node'|'node is disconnected')|Unable to get ping response from node 1|Node 1 is DISCONNECTED|ctdb_control for getpnn failed|: Can not access node. Node is not operational\.|Node 1 has status DISCONNECTED\|UNHEALTHY\|INACTIVE$)" diff --git a/ctdb/tests/simple/12_ctdb_getdebug.sh b/ctdb/tests/simple/12_ctdb_getdebug.sh index 226184813c0..7e6177a3ad4 100755 --- a/ctdb/tests/simple/12_ctdb_getdebug.sh +++ b/ctdb/tests/simple/12_ctdb_getdebug.sh @@ -36,8 +36,7 @@ getdebug_onnode="$out" sanity_check_output \ $num_nodes \ - '^(ERROR|WARNING|NOTICE|INFO|DEBUG)$' \ - "$out" + '^(ERROR|WARNING|NOTICE|INFO|DEBUG)$' cmd="" n=0 diff --git a/ctdb/tests/simple/14_ctdb_statistics.sh b/ctdb/tests/simple/14_ctdb_statistics.sh index 5ff22d7f64c..eda2dc54749 100755 --- a/ctdb/tests/simple/14_ctdb_statistics.sh +++ b/ctdb/tests/simple/14_ctdb_statistics.sh @@ -35,4 +35,4 @@ pattern='^(CTDB version 1|Current time of statistics[[:space:]]*:.*|Statistics c try_command_on_node -v 1 "$CTDB statistics" -sanity_check_output 40 "$pattern" "$out" +sanity_check_output 40 "$pattern" diff --git a/ctdb/tests/simple/24_ctdb_getdbmap.sh b/ctdb/tests/simple/24_ctdb_getdbmap.sh index 9bed5903914..60458c2c8a7 100755 --- a/ctdb/tests/simple/24_ctdb_getdbmap.sh +++ b/ctdb/tests/simple/24_ctdb_getdbmap.sh @@ -45,7 +45,7 @@ try_command_on_node -v 0 "$CTDB getdbmap" db_map_pattern='^(Number of databases:[[:digit:]]+|dbid:0x[[:xdigit:]]+ name:[^[:space:]]+ path:[^[:space:]]+)$' -sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" "$out" +sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" num_db_init=$(echo "$out" | sed -n -e '1s/.*://p') @@ -54,7 +54,7 @@ for i in $(seq 1 5) ; do echo "Creating test database: $f" try_command_on_node 0 $CTDB attach "$f" try_command_on_node 0 $CTDB getdbmap - sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" "$out" + sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern" num=$(echo "$out" | sed -n -e '1s/^.*://p') if [ $num = $(($num_db_init + $i)) ] ; then echo "OK: correct number of additional databases" diff --git a/ctdb/tests/simple/25_dumpmemory.sh b/ctdb/tests/simple/25_dumpmemory.sh index 36fecfed016..6aa9300383f 100755 --- a/ctdb/tests/simple/25_dumpmemory.sh +++ b/ctdb/tests/simple/25_dumpmemory.sh @@ -31,8 +31,8 @@ cluster_is_healthy pat='^([[:space:]].+[[:space:]]+contains[[:space:]]+[[:digit:]]+ bytes in[[:space:]]+[[:digit:]]+ blocks \(ref [[:digit:]]+\)[[:space:]]+0x[[:xdigit:]]+|[[:space:]]+reference to: .+|full talloc report on .+ \(total[[:space:]]+[[:digit:]]+ bytes in [[:digit:]]+ blocks\))$' try_command_on_node -v 0 "$CTDB dumpmemory" -sanity_check_output 10 "$pat" "$out" +sanity_check_output 10 "$pat" echo try_command_on_node -v 0 "$CTDB rddumpmemory" -sanity_check_output 10 "$pat" "$out" +sanity_check_output 10 "$pat" diff --git a/ctdb/tests/simple/51_message_ring.sh b/ctdb/tests/simple/51_message_ring.sh index e1bdab383c7..cecea6c81bb 100755 --- a/ctdb/tests/simple/51_message_ring.sh +++ b/ctdb/tests/simple/51_message_ring.sh @@ -31,7 +31,7 @@ while read line ; do done <<<"$out" pat='^(Waiting for cluster|Ring\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec \(\+ve=[[:digit:]]+ -ve=[[:digit:]]+\))$' -sanity_check_output 1 "$pat" "$out" +sanity_check_output 1 "$pat" # $prev should look like this: # Ring[1]: 10670.93 msgs/sec (+ve=53391 -ve=53373) diff --git a/ctdb/tests/simple/52_fetch_ring.sh b/ctdb/tests/simple/52_fetch_ring.sh index 81e6a7a6bb0..078adcbe30f 100755 --- a/ctdb/tests/simple/52_fetch_ring.sh +++ b/ctdb/tests/simple/52_fetch_ring.sh @@ -26,7 +26,7 @@ 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 pat='^(Waiting for cluster|Fetch\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec)$' -sanity_check_output 1 "$pat" "$out" +sanity_check_output 1 "$pat" # Get the last line of output. while read line ; do diff --git a/ctdb/tests/simple/81_tunnel_ring.sh b/ctdb/tests/simple/81_tunnel_ring.sh index c98b139e9cc..31ede40bafd 100755 --- a/ctdb/tests/simple/81_tunnel_ring.sh +++ b/ctdb/tests/simple/81_tunnel_ring.sh @@ -32,7 +32,7 @@ while read line ; do done <<<"$out" pat='^(Waiting for cluster|pnn\[[[:digit:]]+\] [[:digit:]]+(\.[[:digit:]]+)? msgs/sec)$' -sanity_check_output 1 "$pat" "$out" +sanity_check_output 1 "$pat" # $prev should look like this: # pnn[2] count=85400 |