aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests
diff options
context:
space:
mode:
authorTony Hutter <[email protected]>2017-05-19 12:30:16 -0700
committerBrian Behlendorf <[email protected]>2017-05-19 12:30:16 -0700
commit4a283c7f77eb5065e9f03b122bf8ead4f4a1e2be (patch)
tree2a4daf72ae62343aa7f24305a592fc2f31bb2eeb /tests/zfs-tests
parenta32df59e187a6187eb96c52b93cf02e8af51f327 (diff)
Force fault a vdev with 'zpool offline -f'
This patch adds a '-f' option to 'zpool offline' to fault a vdev instead of bringing it offline. Unlike the OFFLINE state, the FAULTED state will trigger the FMA code, allowing for things like autoreplace and triggering the slot fault LED. The -f faults persist across imports, unless they were set with the temporary (-t) flag. Both persistent and temporary faults can be cleared with zpool clear. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #6094
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh111
3 files changed, 114 insertions, 3 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am
index 6bb5fbf6a..33fbb18d6 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am
@@ -3,4 +3,5 @@ dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
zpool_offline_001_pos.ksh \
- zpool_offline_002_neg.ksh
+ zpool_offline_002_neg.ksh \
+ zpool_offline_003_pos.ksh
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh
index c0ccf0bb8..6f4c2e318 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh
@@ -39,7 +39,6 @@
# 1. Create an array of correctly formed 'zpool offline' options
# 2. Execute each element of the array.
# 3. Verify use of each option is successful.
-#
verify_runnable "global"
@@ -122,4 +121,4 @@ for disk in $DISKLIST; do
fi
done
-log_pass "'zpool offline' with correct options succeeded"
+log_pass "'zpool offline -f' succeeded"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh
new file mode 100755
index 000000000..7b5d21cba
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh
@@ -0,0 +1,111 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2016 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# Test force faulting a VDEV with 'zpool offline -f'
+#
+# STRATEGY:
+# For both temporary and persistent faults, do the following:
+# 1. Force fault a vdev, and clear the fault.
+# 2. Offline a vdev, force fault it, clear the fault, and online it.
+# 3. Force fault a vdev, export it, then import it.
+
+verify_runnable "global"
+
+DISKLIST=$(get_disklist $TESTPOOL)
+set -A disks $DISKLIST
+typeset -i num=${#disks[*]}
+
+set -A args "" "-t"
+
+function cleanup
+{
+ # Ensure we don't leave disks in the offline state
+ for disk in $DISKLIST; do
+ log_must zpool online $TESTPOOL $disk
+ check_state $TESTPOOL $disk "online"
+ if [[ $? != 0 ]]; then
+ log_fail "Unable to online $disk"
+ fi
+ done
+}
+
+log_assert "Executing 'zpool offline -f' with correct options succeeds"
+
+log_onexit cleanup
+
+if [[ -z $DISKLIST ]]; then
+ log_fail "DISKLIST is empty."
+fi
+
+typeset -i i=0
+typeset -i j=1
+
+# Get name of the first disk in the pool
+disk=${DISKLIST%% *}
+
+# Test temporary and persistent faults
+for arg in f tf ; do
+ # Force fault disk, and clear the fault
+ log_must zpool offline -$arg $TESTPOOL $disk
+ check_state $TESTPOOL $disk "faulted"
+ log_must zpool clear $TESTPOOL $disk
+ check_state $TESTPOOL $disk "online"
+
+ # Offline a disk, force fault it, clear the fault, and online it
+ log_must zpool offline $TESTPOOL $disk
+ check_state $TESTPOOL $disk "offline"
+ log_must zpool offline -$arg $TESTPOOL $disk
+ check_state $TESTPOOL $disk "faulted"
+ log_must zpool clear $TESTPOOL $disk
+ check_state $TESTPOOL $disk "offline"
+ log_must zpool online $TESTPOOL $disk
+ check_state $TESTPOOL $disk "online"
+
+ # Test faults across imports
+ log_must zpool offline -tf $TESTPOOL $disk
+ check_state $TESTPOOL $disk "faulted"
+ log_must zpool export $TESTPOOL
+ log_must zpool import $TESTPOOL
+ log_note "-$arg now imported"
+ if [[ "$arg" = "f" ]] ; then
+ # Persistent fault
+ check_state $TESTPOOL $disk "faulted"
+ log_must zpool clear $TESTPOOL $disk
+ else
+ # Temporary faults get cleared by imports
+ check_state $TESTPOOL $disk "online"
+ fi
+done
+log_pass "'zpool offline -f' with correct options succeeded"