6 # This file and its contents are supplied under the terms of the
7 # Common Development and Distribution License ("CDDL"), version 1.0.
8 # You may only use this file in accordance with the terms of version
11 # A full copy of the text of the CDDL should have accompanied this
12 # source. A copy of the CDDL is also available via the Internet at
13 # http://www.illumos.org/license/CDDL.
19 # Copyright (c) 2017 by Intel Corporation. All rights reserved.
22 .
$STF_SUITE/include
/libtest.shlib
23 .
$STF_SUITE/tests
/functional
/fault
/fault.cfg
27 # Testing Fault Management Agent ZED Logic - Automated Auto-Spare Test when
28 # drive is faulted due to CHECKSUM ERRORS.
31 # 1. Create a pool with hot spares
32 # 2. Create a filesystem with the primary cache disable to force reads
33 # 3. Write a file to the pool to be read back
34 # 4. Inject CHECKSUM ERRORS on read with a zinject error handler
35 # 5. Verify the ZED kicks in a hot spare and expected pool/device status
37 # 7. Verify the hot spare is available and expected pool/device status
40 verify_runnable
"both"
44 log_must zinject
-c all
45 destroy_pool
$TESTPOOL
46 rm -f $VDEV_FILES $SPARE_FILE
49 log_assert
"Testing automated auto-spare FMA test"
53 # Events not supported on FreeBSD
55 # Clear events from previous runs
59 TESTFILE
="/$TESTPOOL/$TESTFS/testfile"
61 for type in "mirror" "raidz" "raidz2"; do
62 # 1. Create a pool with hot spares
63 log_must truncate
-s $MINVDEVSIZE $VDEV_FILES $SPARE_FILE
64 log_must zpool create
-f $TESTPOOL $type $VDEV_FILES \
67 # 2. Create a filesystem with the primary cache disable to force reads
68 log_must zfs create
-o primarycache
=none
$TESTPOOL/$TESTFS
69 log_must zfs
set recordsize
=16k
$TESTPOOL/$TESTFS
71 # 3. Write a file to the pool to be read back
72 log_must
dd if=/dev
/urandom of
=$TESTFILE bs
=1M count
=64
74 # 4. Inject CHECKSUM ERRORS on read with a zinject error handler
75 log_must zinject
-d $FAULT_FILE -e corrupt
-f 50 -T read $TESTPOOL
76 log_must
dd if=$TESTFILE of
=/dev
/null bs
=1M count
=64
78 # 5. Verify the ZED kicks in a hot spare and expected pool/device status
79 log_note
"Wait for ZED to auto-spare"
80 log_must wait_vdev_state
$TESTPOOL $FAULT_FILE "DEGRADED" 60
81 log_must wait_vdev_state
$TESTPOOL $SPARE_FILE "ONLINE" 60
82 log_must wait_hotspare_state
$TESTPOOL $SPARE_FILE "INUSE"
83 log_must check_state
$TESTPOOL "" "DEGRADED"
86 log_must zinject
-c all
87 log_must zpool
clear $TESTPOOL $FAULT_FILE
89 # 7. Verify the hot spare is available and expected pool/device status
90 log_must wait_vdev_state
$TESTPOOL $FAULT_FILE "ONLINE" 60
91 log_must wait_hotspare_state
$TESTPOOL $SPARE_FILE "AVAIL"
92 log_must check_state
$TESTPOOL "" "ONLINE"
97 log_pass
"Auto-spare test successful"