tests/eventscripts: New tests for 20.multipathd
authorMartin Schwenke <martin@meltin.net>
Tue, 15 Oct 2013 05:44:45 +0000 (16:44 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 22 Oct 2013 03:34:04 +0000 (14:34 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/eventscripts/20.multipathd.monitor.001.sh [new file with mode: 0755]
tests/eventscripts/20.multipathd.monitor.002.sh [new file with mode: 0755]
tests/eventscripts/20.multipathd.monitor.003.sh [new file with mode: 0755]
tests/eventscripts/20.multipathd.monitor.004.sh [new file with mode: 0755]
tests/eventscripts/scripts/local.sh
tests/eventscripts/stubs/multipath [new file with mode: 0755]

diff --git a/tests/eventscripts/20.multipathd.monitor.001.sh b/tests/eventscripts/20.multipathd.monitor.001.sh
new file mode 100755 (executable)
index 0000000..4eafefc
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "No multipath devices configure to check"
+
+setup_multipathd
+
+ok_null
+
+simple_test
diff --git a/tests/eventscripts/20.multipathd.monitor.002.sh b/tests/eventscripts/20.multipathd.monitor.002.sh
new file mode 100755 (executable)
index 0000000..fbfe952
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 multipath devices configure to check, all up"
+
+setup_multipathd "mpatha"  "mpathb"  "mpathc"
+
+ok_null
+
+simple_test
diff --git a/tests/eventscripts/20.multipathd.monitor.003.sh b/tests/eventscripts/20.multipathd.monitor.003.sh
new file mode 100755 (executable)
index 0000000..d9a2125
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 multipath devices configure to check, one down"
+
+setup_multipathd "mpatha"  "!mpathb"  "mpathc"
+
+required_result 1 <<EOF
+ERROR: multipath device "mpathb" has no active paths
+multipath monitoring failed
+EOF
+
+simple_test
diff --git a/tests/eventscripts/20.multipathd.monitor.004.sh b/tests/eventscripts/20.multipathd.monitor.004.sh
new file mode 100755 (executable)
index 0000000..5f45c73
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 multipath devices configure to check, multipath hangs"
+
+setup_multipathd "mpatha"  "!mpathb"  "mpathc"
+export FAKE_MULTIPATH_HANG="yes"
+
+required_result 1 <<EOF
+ERROR: callout to multipath checks hung
+multipath monitoring failed
+EOF
+
+simple_test
index 450396a491df1b850e3103f2fc8d3ce382825361..0527eca78a8fe0ecd190f64f0b8d9001b6a953a1 100644 (file)
@@ -837,6 +837,29 @@ setup_httpd ()
 
 ######################################################################
 
+# multipathd fakery
+
+setup_multipathd ()
+{
+    for i ; do
+       case "$i" in
+           \!*)
+               _t="${i#!}"
+               echo "Marking ${_t} as having no active paths"
+               FAKE_MULTIPATH_FAILURES="${FAKE_MULTIPATH_FAILURES}${FAKE_MULTIPATH+FAILURES:+ }${_t}"
+               ;;
+           *)
+               _t="$i"         
+       esac
+       CTDB_MONITOR_MPDEVICES="${CTDB_MONITOR_MPDEVICES}${CTDB_MONITOR_MPDEVICES:+ }${_t}"
+    done
+
+    export CTDB_MONITOR_MPDEVICES FAKE_MULTIPATH_FAILURES
+    export FAKE_SLEEP_FORCE=0.1
+}
+
+######################################################################
+
 # Result and test functions
 
 # Set some globals and print the summary.
diff --git a/tests/eventscripts/stubs/multipath b/tests/eventscripts/stubs/multipath
new file mode 100755 (executable)
index 0000000..64f95e7
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+usage ()
+{
+    die "usage: ${0} -ll device"
+}
+    
+[ "$1" = "-ll" ] || usage
+shift
+[ $# -eq 1 ] || usage
+
+device="$1"
+
+if [ -n "$FAKE_MULTIPATH_HANG" ] ; then
+    FAKE_SLEEP_REALLY="yes" sleep 999
+fi
+
+path1_state="active"
+path2_state="enabled"
+
+for i in $FAKE_MULTIPATH_FAILURES ; do
+    if [ "$device" = "$i" ] ; then
+       path1_state="inactive"
+       path2_state="inactive"
+       break
+    fi
+done
+
+       cat <<EOF
+${device} (AUTO-01234567) dm-0 ,
+size=10G features='0' hwhandler='0' wp=rw
+|-+- policy='round-robin 0' prio=1 status=${path1_state}
+| \`- #:#:#:# vda 252:0  active ready running
+\`-+- policy='round-robin 0' prio=1 status=${path2_state}
+  \`- #:#:#:# vdb 252:16 active ready running
+EOF