ctdb-tests: Generalise SM_NOTIFY output format in statd-callout tests
authorMartin Schwenke <martin@meltin.net>
Thu, 2 Mar 2017 10:55:54 +0000 (21:55 +1100)
committerMartin Schwenke <martins@samba.org>
Thu, 1 Mar 2018 18:39:15 +0000 (19:39 +0100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/scripts/local.sh
ctdb/tests/eventscripts/stubs/smnotify

index b5eeb92f56f756a77f4c68d57ac137533ea6b5e6..4af1522e542afa182b6a217b4fdef731fd88ce50 100644 (file)
@@ -706,10 +706,10 @@ check_statd_callout_smnotify ()
     while read _x _sip _x ; do
        for _cip ; do
            cat <<EOF
---client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_even}
---client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_even}
---client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_odd}
---client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_odd}
+SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${_sip}, STATE=${_state_even}
+SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${NFS_HOSTNAME}, STATE=${_state_even}
+SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${_sip}, STATE=${_state_odd}
+SM_NOTIFY: ${_sip} -> ${_cip}, MON_NAME=${NFS_HOSTNAME}, STATE=${_state_odd}
 EOF
        done
     done | {
index 414fa99a89701f4e9d1102ff4ae3b764b9649d88..2bace779df06389ab2a588ebbdb3a1dfe0fb6c79 100755 (executable)
@@ -1,3 +1,39 @@
 #!/bin/sh
-# echo args
-echo "$*"
+
+usage()
+{
+       _prog="${0##*/}" # basename
+       cat <<EOF
+Usage: ${_prog} --client=CLIENT --ip=IP --server=SERVER --stateval=STATEVAL
+EOF
+       exit 1
+}
+
+temp=$(getopt -n "smnotify" -o "h" -l client:,ip:,server:,stateval: -- "$@")
+if [ $? != 0 ] ; then
+       usage
+fi
+
+eval set -- "$temp"
+
+cip=""
+sip=""
+mon_name=""
+state=""
+
+while : ; do
+       case "$1" in
+       --client) cip="$2" ; shift 2 ;;
+       --ip) sip="$2" ; shift 2 ;;
+       --server)  mon_name="$2" ; shift 2 ;;
+       --stateval) state="$2" ; shift 2 ;;
+       --) shift ; break ;;
+       *) usage ;;
+       esac
+done
+
+if [ -z "$cip" -o -z "$sip" -o -z "$mon_name" -o -z "$state" ] ; then
+       usage
+fi
+
+echo "SM_NOTIFY: ${sip} -> ${cip}, MON_NAME=${mon_name}, STATE=${state}"