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 # Clear events from previous runs
56 TESTFILE
="/$TESTPOOL/$TESTFS/testfile"
58 for type in "mirror" "raidz" "raidz2"; do
59 # 1. Create a pool with hot spares
60 truncate
-s $SPA_MINDEVSIZE $VDEV_FILES $SPARE_FILE
61 log_must zpool create
-f $TESTPOOL $type $VDEV_FILES spare
$SPARE_FILE
63 # 2. Create a filesystem with the primary cache disable to force reads
64 log_must zfs create
-o primarycache
=none
$TESTPOOL/$TESTFS
65 log_must zfs
set recordsize
=16k
$TESTPOOL/$TESTFS
67 # 3. Write a file to the pool to be read back
68 log_must
dd if=/dev
/urandom of
=$TESTFILE bs
=1M count
=16
70 # 4. Inject CHECKSUM ERRORS on read with a zinject error handler
71 log_must zinject
-d $FAULT_FILE -e corrupt
-f 50 -T read $TESTPOOL
72 log_must
cp $TESTFILE /dev
/null
74 # 5. Verify the ZED kicks in a hot spare and expected pool/device status
75 log_note
"Wait for ZED to auto-spare"
76 log_must wait_vdev_state
$TESTPOOL $FAULT_FILE "DEGRADED" 60
77 log_must wait_vdev_state
$TESTPOOL $SPARE_FILE "ONLINE" 60
78 log_must wait_hotspare_state
$TESTPOOL $SPARE_FILE "INUSE"
79 log_must check_state
$TESTPOOL "" "DEGRADED"
82 log_must zinject
-c all
83 log_must zpool
clear $TESTPOOL $FAULT_FILE
85 # 7. Verify the hot spare is available and expected pool/device status
86 log_must wait_vdev_state
$TESTPOOL $FAULT_FILE "ONLINE" 60
87 log_must wait_hotspare_state
$TESTPOOL $SPARE_FILE "AVAIL"
88 log_must check_state
$TESTPOOL "" "ONLINE"
93 log_pass
"Auto-spare test successful"