5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2016, 2017 by Intel Corporation. All rights reserved.
26 . $STF_SUITE/include/libtest.shlib
27 . $STF_SUITE/tests/functional/fault/fault.cfg
31 # Testing Fault Management Agent ZED Logic - Automated Auto-Online Test.
37 # 4. Import pool with missing disk
39 # 6. ZED polls for an event change for online disk to be automatically
40 # added back to the pool.
42 # Creates a raidz1 zpool using persistent disk path names
45 # If loop devices are used, then a scsi_debug device is added to the pool.
46 # otherwise just an sd device is used as the auto-online device.
47 # Auto-online matches by devid.
49 verify_runnable "both"
51 if ! is_physical_device $DISKS; then
52 log_unsupported "Unsupported disks for this test."
57 #online last disk before fail
58 insert_disk $offline_disk $host
59 poolexists $TESTPOOL && destroy_pool $TESTPOOL
62 log_assert "Testing automated auto-online FMA test"
66 # If using the default loop devices, need a scsi_debug device for auto-online
67 if is_loop_device $DISK1; then
68 SD=$(lsscsi | nawk '/scsi_debug/ {print $6; exit}')
69 SDDEVICE=$(echo $SD | nawk -F / '{print $3}')
70 SDDEVICE_ID=$(get_persistent_disk_name $SDDEVICE)
71 autoonline_disks="$SDDEVICE"
73 autoonline_disks="$DISK1 $DISK2 $DISK3"
79 zpool labelclear -f /dev/disk/by-id/"${devs_id[i]}"
82 if is_loop_device $DISK1; then
83 # create a pool with one scsi_debug device and 3 loop devices
84 log_must zpool create -f $TESTPOOL raidz1 $SDDEVICE_ID $DISK1 \
86 elif ( is_real_device $DISK1 || is_mpath_device $DISK1 ); then
87 # else use the persistent names for sd devices
88 log_must zpool create -f $TESTPOOL raidz1 ${devs_id[0]} \
89 ${devs_id[1]} ${devs_id[2]}
91 log_fail "Disks are not supported for this test"
94 # Add some data to the pool
95 log_must mkfile $FSIZE /$TESTPOOL/data
97 for offline_disk in $autoonline_disks
99 log_must zpool export -F $TESTPOOL
101 host=$(get_scsi_host $offline_disk)
104 remove_disk $offline_disk
106 # Reimport pool with drive missing
107 log_must zpool import $TESTPOOL
108 check_state $TESTPOOL "" "degraded"
110 log_fail "$TESTPOOL is not degraded"
114 log_must zpool events -c
117 insert_disk $offline_disk $host
119 log_note "Delay for ZED auto-online"
122 if ((timeout == $MAXTIMEOUT)); then
123 log_fail "Timeout occured"
128 zpool events $TESTPOOL \
129 | egrep sysevent.fs.zfs.resilver_finish > /dev/null
131 log_note "Auto-online of $offline_disk is complete"
137 # Validate auto-online was successful
138 check_state $TESTPOOL "" "online"
140 log_fail "$TESTPOOL is not back online"
144 log_must zpool destroy $TESTPOOL
146 log_pass "Auto-online test successful"