summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-07-29 15:31:55 +1000
committerKarolin Seeger <kseeger@samba.org>2019-09-03 12:05:37 +0000
commitfd8a55bb3f4ec61ddd491b4e3722bb6cd4a56a46 (patch)
treeaf50529070fa9c3f03889f053ab8b86ba5322d46
parentb40bef3c5ee38aaf5aa5347c8b49a3e729c0c2b5 (diff)
downloadsamba-fd8a55bb3f4ec61ddd491b4e3722bb6cd4a56a46.tar.gz
ctdb-tests: Reformat node_has_status()
Re-indent and drop non-POSIX left-parenthesis from case labels. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 52227d19735a3305ad633672c70385f443f222f0)
-rw-r--r--ctdb/tests/scripts/integration.bash94
1 files changed, 48 insertions, 46 deletions
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index e0aa312192b..0a400443240 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -315,53 +315,55 @@ wait_until_ready ()
# This function is becoming nicely overloaded. Soon it will collapse! :-)
node_has_status ()
{
- local pnn="$1"
- local status="$2"
-
- 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|*" ;;
- (frozen) fpat='^[[:space:]]+frozen[[:space:]]+1$' ;;
- (unfrozen) fpat='^[[:space:]]+frozen[[:space:]]+0$' ;;
- (recovered) rpat='^Recovery mode:RECOVERY \(1\)$' ;;
- (notlmaster) rpat="^hash:.* lmaster:${pnn}\$" ;;
+ local pnn="$1"
+ local status="$2"
+
+ 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|*" ;;
+ frozen) fpat='^[[:space:]]+frozen[[:space:]]+1$' ;;
+ unfrozen) fpat='^[[:space:]]+frozen[[:space:]]+0$' ;;
+ recovered) rpat='^Recovery mode:RECOVERY \(1\)$' ;;
+ notlmaster) rpat="^hash:.* lmaster:${pnn}\$" ;;
*)
- echo "node_has_status: unknown status \"$status\""
- return 1
- esac
-
- if [ -n "$bits" ] ; then
- local out x line
-
- 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}|*|}"
- [ "$line_bits" = "$line" ] && continue
- [ "${line_bits#${bits}}" != "$line_bits" ] && return 0
- done
- return 1
- } <<<"$out" # Yay bash!
- elif [ -n "$fpat" ] ; then
- $CTDB statistics -n "$pnn" | egrep -q "$fpat"
- elif [ -n "$rpat" ] ; then
- ! $CTDB status -n "$pnn" | egrep -q "$rpat"
- else
- echo 'node_has_status: unknown mode, neither $bits nor $fpat is set'
- return 1
- fi
+ echo "node_has_status: unknown status \"$status\""
+ return 1
+ esac
+
+ if [ -n "$bits" ] ; then
+ local out x line
+
+ 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}|*|}"
+ [ "$line_bits" = "$line" ] && continue
+ [ "${line_bits#${bits}}" != "$line_bits" ] && \
+ return 0
+ done
+ return 1
+ } <<<"$out" # Yay bash!
+ elif [ -n "$fpat" ] ; then
+ $CTDB statistics -n "$pnn" | egrep -q "$fpat"
+ elif [ -n "$rpat" ] ; then
+ ! $CTDB status -n "$pnn" | egrep -q "$rpat"
+ else
+ echo 'node_has_status: unknown mode, neither $bits nor $fpat is set'
+ return 1
+ fi
}
wait_until_node_has_status ()