]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Change sanity_check_output() to internally use $out
authorMartin Schwenke <martin@meltin.net>
Tue, 30 Apr 2019 02:09:26 +0000 (12:09 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 7 May 2019 05:45:34 +0000 (05:45 +0000)
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>
ctdb/tests/scripts/integration.bash
ctdb/tests/simple/02_ctdb_tunables.sh
ctdb/tests/simple/05_ctdb_listnodes.sh
ctdb/tests/simple/09_ctdb_ping.sh
ctdb/tests/simple/12_ctdb_getdebug.sh
ctdb/tests/simple/14_ctdb_statistics.sh
ctdb/tests/simple/24_ctdb_getdbmap.sh
ctdb/tests/simple/25_dumpmemory.sh
ctdb/tests/simple/51_message_ring.sh
ctdb/tests/simple/52_fetch_ring.sh
ctdb/tests/simple/81_tunnel_ring.sh

index 6ba531a4a76ceeb05f5a0154a768923a5b9fe03b..7aef0c7ee398b5f6ca4b46a938f6de8b52e10b26 100644 (file)
@@ -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
index 74163d9b2e63af682448f800c46e74925ee17f6e..e205da217e613ceeb17c47dc7f20088f89652fab 100755 (executable)
@@ -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\"..."
 
index 7e992c3ae5a94108c8590b293b09026f673e1363..0adb291f758cf0192e3d36dce12c34025d123d3a 100755 (executable)
@@ -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"
 
index 28552b94bfe5bd2aebce3749d88219fcae45fa47..b911b896f994a71e622aeb3f6c4ba7069032e5d6 100755 (executable)
@@ -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$)"
index 1189c1c710daedabfc98a07f1cb07d719f8fb0b7..979392f9a1d179634d21c626512b9607f3ae791b 100755 (executable)
@@ -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
index 70245ee7e9f4d09b60acc253e4901d01f11eae7d..cda6e5f478ed92828cdacd2d34a8e0fc4ae72d72 100755 (executable)
@@ -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"
index d8a3c604048211c97e76837ef94094225661896b..612fec1b49bfe7a55e5878aa50c1bf8234c4b883 100755 (executable)
@@ -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"
index 4f998bf8f3bbd3c9976a28cb81187f5498a79fd6..3d976c17d0f68ad349fc06df776b8c657ded222e 100755 (executable)
@@ -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"
index 8aa8e47fa80c9d6475a0c25cd6dbb5881e204211..f6f064e43bf83bf181e58d16cc6872474ca13d54 100755 (executable)
@@ -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)
index b12b2aa32f08b3f857ef3e880c48db26084d1c81..bdd8186c49e4eea31707456d52a9625803d81f32 100755 (executable)
@@ -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
index 2c5091d3b9b084a4634c91766cbeb99551ac3ebc..990039abfcb29f11a23599df55c010ba3ada7a5c 100755 (executable)
@@ -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