]>
Commit | Line | Data |
---|---|---|
d9daa7ab DQ |
1 | #!/bin/ksh -p |
2 | ||
3 | # | |
4 | # CDDL HEADER START | |
5 | # | |
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 | |
9 | # 1.0 of the CDDL. | |
10 | # | |
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. | |
14 | # | |
15 | # CDDL HEADER END | |
16 | # | |
17 | ||
18 | # | |
19 | # Copyright (c) 2017 by Intel Corporation. All rights reserved. | |
20 | # | |
21 | ||
22 | . $STF_SUITE/include/libtest.shlib | |
23 | . $STF_SUITE/tests/functional/fault/fault.cfg | |
24 | ||
25 | # | |
26 | # DESCRIPTION: | |
27 | # Testing Fault Management Agent ZED Logic - Automated Auto-Spare Test when | |
28 | # drive is faulted due to IO ERRORS. | |
29 | # | |
30 | # STRATEGY: | |
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 IO ERRORS on read with a zinject error handler | |
35 | # 5. Verify the ZED kicks in a hot spare and expected pool/device status | |
36 | # 6. Clear the fault | |
37 | # 7. Verify the hot spare is available and expected pool/device status | |
38 | # | |
39 | ||
40 | verify_runnable "both" | |
41 | ||
42 | function cleanup | |
43 | { | |
44 | log_must zinject -c all | |
4e9b1569 | 45 | destroy_pool $TESTPOOL |
d9daa7ab DQ |
46 | rm -f $VDEV_FILES $SPARE_FILE |
47 | } | |
48 | ||
49 | log_assert "Testing automated auto-spare FMA test" | |
50 | ||
51 | log_onexit cleanup | |
52 | ||
4e9b1569 | 53 | # Clear events from previous runs |
54 | zed_events_drain | |
55 | ||
d9daa7ab DQ |
56 | TESTFILE="/$TESTPOOL/$TESTFS/testfile" |
57 | ||
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 | |
62 | ||
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 | |
66 | ||
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 | |
69 | ||
70 | # 4. Inject IO ERRORS on read with a zinject error handler | |
71 | log_must zinject -d $FAULT_FILE -e io -T read $TESTPOOL | |
72 | log_must cp $TESTFILE /dev/null | |
73 | ||
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 "FAULTED" 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" | |
80 | ||
81 | # 6. Clear the fault | |
82 | log_must zinject -c all | |
83 | log_must zpool clear $TESTPOOL $FAULT_FILE | |
84 | ||
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 is_pool_resilvered $TESTPOOL | |
89 | log_must check_state $TESTPOOL "" "ONLINE" | |
90 | ||
91 | cleanup | |
92 | done | |
93 | ||
94 | log_pass "Auto-spare test successful" |