summaryrefslogtreecommitdiff
path: root/ctdb/tests
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2015-06-17 17:05:44 +1000
committerAmitay Isaacs <amitay@samba.org>2015-07-14 09:57:17 +0200
commite7954298022b94a48ac18fef8c7f7b40281846cb (patch)
treeac749e0f0f4e0c564714545c30edc0ce0b2a41ed /ctdb/tests
parentc72c5b754f590ecc26cfff077b20d04e684c2ea9 (diff)
downloadsamba-e7954298022b94a48ac18fef8c7f7b40281846cb.tar.gz
ctdb-tests: New function nfs_iterate_test()
Much clearer than using iterate_test() for this purpose. This also does failover counting by calling rpcinfo in each iteration. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rw-r--r--ctdb/tests/eventscripts/scripts/local.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh
index 290c8f494e5..8db8fcbe804 100644
--- a/ctdb/tests/eventscripts/scripts/local.sh
+++ b/ctdb/tests/eventscripts/scripts/local.sh
@@ -1259,3 +1259,58 @@ EOF
result_footer "$_result"
}
+
+# Run an NFS eventscript iteratively.
+#
+# - 1st argument is the number of iterations.
+#
+# - 2nd argument is the NFS/RPC service being tested
+#
+# rpcinfo is used on each iteration to test the availability of the
+# service
+#
+# - Subsequent arguments come in pairs: an iteration number and
+# something to eval before that iteration. Each time an iteration
+# number is matched the associated argument is given to eval after
+# the default setup is done. The iteration numbers need to be given
+# in ascending order.
+#
+# These arguments can allow a service to be started or stopped
+# before a particular iteration.
+#
+nfs_iterate_test ()
+{
+ _repeats="$1"
+ _rpc_service="$2"
+ shift 2
+
+ echo "Running $_repeats iterations of \"$script $event\" $args"
+
+ _iterate_failcount=0
+ for _iteration in $(seq 1 $_repeats) ; do
+ # This is not a numerical comparison because $1 will often not
+ # be set.
+ if [ "$_iteration" = "$1" ] ; then
+ debug "##################################################"
+ eval "$2"
+ debug "##################################################"
+ shift 2
+ fi
+ if rpcinfo -T tcp localhost "$_rpc_service" >/dev/null 2>&1 ; then
+ _iterate_failcount=0
+ else
+ _iterate_failcount=$(($_iterate_failcount + 1))
+ fi
+ rpc_set_service_failure_response "$_rpc_service" $_iterate_failcount
+ _out=$(simple_test 2>&1)
+ _ret=$?
+ if "$TEST_VERBOSE" || [ $_ret -ne 0 ] ; then
+ echo "##################################################"
+ echo "Iteration ${_iteration}:"
+ echo "$_out"
+ fi
+ if [ $_ret -ne 0 ] ; then
+ exit $_ret
+ fi
+ done
+}