]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_008_pos.ksh
zfs: merge openzfs/zfs@229b9f4ed
[FreeBSD/FreeBSD.git] / sys / contrib / openzfs / tests / zfs-tests / tests / functional / cli_root / zpool_status / zpool_status_008_pos.ksh
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) 2024 by Lawrence Livermore National Security, LLC.
20 #
21
22 . $STF_SUITE/include/libtest.shlib
23
24 #
25 # DESCRIPTION:
26 # Verify 'zpool status -e' only shows unhealthy devices.
27 #
28 # STRATEGY:
29 # 1. Create zpool
30 # 2. Force DEGRADE, FAULT, or inject slow IOs for vdevs
31 # 3. Verify vdevs are reported correctly with -e and -s
32 # 4. Verify parents are reported as DEGRADED
33 # 5. Verify healthy children are not reported
34 #
35
36 function cleanup
37 {
38         log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO
39         zinject -c all
40         poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2
41         log_must rm -f $all_vdevs
42 }
43
44 log_assert "Verify 'zpool status -e'"
45
46 log_onexit cleanup
47
48 all_vdevs=$(echo $TESTDIR/vdev{1..6})
49 log_must mkdir -p $TESTDIR
50 log_must truncate -s $MINVDEVSIZE $all_vdevs
51
52 OLD_SLOW_IO=$(get_tunable ZIO_SLOW_IO_MS)
53
54 for raid_type in "draid2:3d:6c:1s" "raidz2"; do
55
56         log_must zpool create -f $TESTPOOL2 $raid_type $all_vdevs
57
58         # Check DEGRADED vdevs are shown.
59         log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev4 "ONLINE"
60         log_must zinject -d $TESTDIR/vdev4 -A degrade $TESTPOOL2
61         log_must eval "zpool status -e $TESTPOOL2 | grep $TESTDIR/vdev4 | grep DEGRADED"
62
63         # Check FAULTED vdevs are shown.
64         log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev5 "ONLINE"
65         log_must zinject -d $TESTDIR/vdev5 -A fault $TESTPOOL2
66         log_must eval "zpool status -e $TESTPOOL2 | grep $TESTDIR/vdev5 | grep FAULTED"
67
68         # Check no ONLINE vdevs are shown
69         log_mustnot eval "zpool status -e $TESTPOOL2 | grep ONLINE"
70
71         # Check no ONLINE slow vdevs are show.  Then mark IOs greater than
72         # 10ms slow, delay IOs 20ms to vdev6, check slow IOs.
73         log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev6 "ONLINE"
74         log_mustnot eval "zpool status -es $TESTPOOL2 | grep ONLINE"
75
76         log_must set_tunable64 ZIO_SLOW_IO_MS 10
77         log_must zinject -d $TESTDIR/vdev6 -D20:100 $TESTPOOL2
78         log_must mkfile 1048576 /$TESTPOOL2/testfile
79         sync_pool $TESTPOOL2
80         log_must set_tunable64 ZIO_SLOW_IO_MS $OLD_SLOW_IO
81
82         # Check vdev6 slow IOs are only shown when requested with -s.
83         log_mustnot eval "zpool status -e $TESTPOOL2 | grep $TESTDIR/vdev6 | grep ONLINE"
84         log_must eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev6 | grep ONLINE"
85
86         # Pool level and top-vdev level status must be DEGRADED.
87         log_must eval "zpool status -e $TESTPOOL2 | grep $TESTPOOL2 | grep DEGRADED"
88         log_must eval "zpool status -e $TESTPOOL2 | grep $raid_type | grep DEGRADED"
89
90         # Check that healthy vdevs[1-3] aren't shown with -e.
91         log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev1 "ONLINE"
92         log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev2 "ONLINE"
93         log_must check_vdev_state $TESTPOOL2 $TESTDIR/vdev3 "ONLINE"
94         log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev1 | grep ONLINE"
95         log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev2 | grep ONLINE"
96         log_mustnot eval "zpool status -es $TESTPOOL2 | grep $TESTDIR/vdev3 | grep ONLINE"
97
98         log_must zinject -c all
99         log_must zpool status -es $TESTPOOL2
100
101         zpool destroy $TESTPOOL2
102 done
103
104 log_pass "Verify zpool status -e shows only unhealthy vdevs"