diff options
author | Martin Schwenke <martin@meltin.net> | 2019-04-30 12:09:26 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-05-07 05:45:34 +0000 |
commit | 7c3819d1ac264acf998f426e0cef7f6211e0ddee (patch) | |
tree | a8c80c6406b7891c5200a1d50af25a509912c013 /ctdb | |
parent | b80967f5dcc6b58db0c38ec3e5cf0cbe46dbeb4b (diff) | |
download | samba-7c3819d1ac264acf998f426e0cef7f6211e0ddee.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>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/tests/scripts/integration.bash | 5 | ||||
-rwxr-xr-x | ctdb/tests/simple/02_ctdb_tunables.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 6ba531a4a76..7aef0c7ee39 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -108,11 +108,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})" @@ -121,7 +120,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_tunables.sh b/ctdb/tests/simple/02_ctdb_tunables.sh index 74163d9b2e6..e205da217e6 100755 --- a/ctdb/tests/simple/02_ctdb_tunables.sh +++ b/ctdb/tests/simple/02_ctdb_tunables.sh @@ -19,8 +19,7 @@ try_command_on_node -v 0 "$CTDB listvars" sanity_check_output \ 5 \ - '^[[:alpha:]][[:alnum:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' \ - "$out" + '^[[:alpha:]][[:alnum:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' echo "Verifying all variable values using \"ctdb getvar\"..." diff --git a/ctdb/tests/simple/05_ctdb_listnodes.sh b/ctdb/tests/simple/05_ctdb_listnodes.sh index 7e992c3ae5a..0adb291f758 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 28552b94bfe..b911b896f99 100755 --- a/ctdb/tests/simple/09_ctdb_ping.sh +++ b/ctdb/tests/simple/09_ctdb_ping.sh @@ -39,8 +39,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" @@ -50,5 +49,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 1189c1c710d..979392f9a1d 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 70245ee7e9f..cda6e5f478e 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 d8a3c604048..612fec1b49b 100755 --- a/ctdb/tests/simple/24_ctdb_getdbmap.sh +++ b/ctdb/tests/simple/24_ctdb_getdbmap.sh @@ -42,7 +42,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') @@ -51,7 +51,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 4f998bf8f3b..3d976c17d0f 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 8aa8e47fa80..f6f064e43bf 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 b12b2aa32f0..bdd8186c49e 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 2c5091d3b9b..990039abfcb 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 |