Add auto-online test for ZED/FMA as part of the ZTS

Automated auto-online test to go along with ZED FMA integration (PR 4673)
auto_online_001.pos works with real devices (sd- and mpath) and with non-real
block devices (loop) by adding a scsi_debug device to the pool

Note: In order for test group to run, ZED must not currently be running.
Kernel 3.16.37 or higher needed for scsi_debug to work properly
If timeout occurs on test using a scsi_debug device (error noticed on Ubuntu
system), a reboot might be needed in order for test to pass. (more
investigation into this)

Also suppressed output from is_real_device/is_loop_device/is_mpath_device -
was making the log file very cluttered with useless error messages
"ie /dev/mapper/sdc is not a block device" from previous patch

Reviewed-by: Don Brady <don.brady@intel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: David Quigley <david.quigley@intel.com>
Signed-off-by: Sydney Vanda <sydney.m.vanda@intel.com>
Closes #5774
This commit is contained in:
Sydney Vanda
2016-09-23 13:51:08 -07:00
committed by Brian Behlendorf
parent 4859fe796c
commit ec0e24c232
13 changed files with 524 additions and 21 deletions
@@ -15,6 +15,7 @@ SUBDIRS = \
delegate \
devices \
exec \
fault \
features \
grow_pool \
grow_replicas \
@@ -0,0 +1,6 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/fault
dist_pkgdata_SCRIPTS = \
fault.cfg \
setup.ksh \
cleanup.ksh \
auto_online_001_pos.ksh
@@ -0,0 +1,142 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2016 by Intel Corporation. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/fault/fault.cfg
#
# DESCRIPTION:
# Tesing auto-online FMA ZED logic.
#
# STRATEGY:
# 1. Create a pool
# 2. export a pool
# 3. offline disk
# 4. import pool with missing disk
# 5. online disk
# 6. ZED polls for an event change for online disk to be automatically
# added back to the pool.
# 7. Creates a raidz1 zpool using persistent disk path names
# (ie not /dev/sdc).
# 8. Tests import using pool guid and cache file.
#
# If loop devices are used, then a scsi_debug device is added to the pool.
#
verify_runnable "both"
if ! is_physical_device $DISKS; then
log_unsupported "Unsupported disks for this test."
fi
function cleanup
{
#online last disk before fail
on_off_disk $offline_disk "online"
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_assert "Testing auto-online FMA ZED logic"
log_onexit cleanup
target=$TESTPOOL
if is_loop_device $DISK1; then
SD=$($LSSCSI | $NAWK '/scsi_debug/ {print $6; exit}')
SDDEVICE=$($ECHO $SD | $NAWK -F / '{print $3}')
SDDEVICE_ID=$(get_persistent_disk_name $SDDEVICE)
autoonline_disks="$SDDEVICE"
else
autoonline_disks="$DISK1 $DISK2 $DISK3"
fi
# Clear disk labels
for i in {0..2}
do
log_must $ZPOOL labelclear -f /dev/disk/by-id/"${devs_id[i]}"
done
if is_loop_device $DISK1; then
#create a pool with one scsi_debug device and 3 loop devices
log_must $ZPOOL create -f $TESTPOOL raidz1 $SDDEVICE_ID $DISK1 \
$DISK2 $DISK3
elif ( is_real_device $DISK1 || is_mpath_device $DISK1 ); then
log_must $ZPOOL create -f $TESTPOOL raidz1 ${devs_id[0]} \
${devs_id[1]} ${devs_id[2]}
else
log_fail "Disks are not supported for this test"
fi
#add some data to the pool
log_must $MKFILE $FSIZE /$TESTPOOL/data
#pool guid import
typeset guid=$(get_config $TESTPOOL pool_guid)
if (( RANDOM % 2 == 0 )) ; then
target=$guid
fi
for offline_disk in $autoonline_disks
do
log_must $ZPOOL export -F $TESTPOOL
host=$($LS /sys/block/$offline_disk/device/scsi_device | $NAWK -F : '{ print $1}')
#offline disk
on_off_disk $offline_disk "offline"
#reimport pool with drive missing
log_must $ZPOOL import $target
check_state $TESTPOOL "" "degraded"
if (($? != 0)); then
log_fail "$TESTPOOL is not degraded"
fi
#online disk
on_off_disk $offline_disk "online" $host
log_note "Delay for ZED auto-online"
typeset -i timeout=0
$CAT ${ZEDLET_DIR}/zedlog | \
$EGREP "zfs_iter_vdev: matched devid" > /dev/null
while (($? != 0)); do
if ((timeout == $MAXTIMEOUT)); then
log_fail "Timeout occured"
fi
((timeout++))
$SLEEP 1
$CAT ${ZEDLET_DIR}/zedlog | \
$EGREP "zfs_iter_vdev: matched devid" > /dev/null
done
check_state $TESTPOOL "" "online"
if (($? != 0)); then
log_fail "$TESTPOOL is not back online"
fi
$SLEEP 2
done
log_must $ZPOOL destroy $TESTPOOL
log_pass "Auto-online test successful"
+58
View File
@@ -0,0 +1,58 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2016 by Intel Corporation. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/fault/fault.cfg
verify_runnable "global"
cleanup_devices $DISKS
if [[ -f ${ZEDLET_DIR}/zed.pid ]]; then
zedpid=$($CAT ${ZEDLET_DIR}/zed.pid)
log_must $KILL $zedpid
fi
log_must $RM ${ZEDLET_DIR}/all-syslog.sh
log_must $RM ${ZEDLET_DIR}/zed.pid
log_must $RM ${ZEDLET_DIR}/zedlog
log_must $RM ${ZEDLET_DIR}/state
log_must $RMDIR $ZEDLET_DIR
if is_loop_device $DISK1; then
SD=$($LSSCSI | $NAWK '/scsi_debug/ {print $6; exit}')
SDDEVICE=$($ECHO $SD | $NAWK -F / '{print $3}')
if [[ -z $SDDEVICE ]]; then
log_pass
fi
#offline disk
on_off_disk $SDDEVICE "offline"
block_device_wait
log_must $MODUNLOAD scsi_debug
fi
log_pass
@@ -0,0 +1,50 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2016 by Intel Corporation. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
verify_runnable "global"
export DISK_ARRAY_NUM=$($ECHO ${DISKS} | $NAWK '{print NF}')
export DISKSARRAY=$DISKS
export FSIZE=10M
export MAXTIMEOUT=20
export DISK1=$($ECHO $DISKS | $NAWK '{print $1}')
export DISK2=$($ECHO $DISKS | $NAWK '{print $2}')
export DISK3=$($ECHO $DISKS | $NAWK '{print $3}')
export ZEDLET_DIR=/var/tmp/zed
if is_linux; then
set_slice_prefix
set_device_dir
devs_id[0]=$(get_persistent_disk_name $DISK1)
devs_id[1]=$(get_persistent_disk_name $DISK2)
devs_id[2]=$(get_persistent_disk_name $DISK3)
export devs_id
else
DEV_DSKDIR="/dev"
fi
+85
View File
@@ -0,0 +1,85 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2016 by Intel Corporation. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/fault/fault.cfg
typeset SDSIZE=256
typeset SDHOSTS=1
typeset SDTGTS=1
typeset SDLUNS=1
[[ -z $UDEVADM ]] && log_fail "Missing UDEVADM command"
[[ -z $NAWK ]] && log_fail "Missing NAWK command"
[[ -z $EGREP ]] && log_fail "Missing EGREP command"
[[ -z $LSSCSI ]] && log_fail "Missing LSSCSI command"
[[ -z $MODUNLOAD ]] && log_fail "Missing MODUNLOAD command"
[[ -z $PGREP ]] && log_fail "Missing PGREP command"
verify_runnable "global"
if [[ ! -d /var/tmp/zed ]]; then
log_must $MKDIR /var/tmp/zed
fi
modprobe -n scsi_debug
if (($? != 0)); then
log_unsupported "Platform does not have scsi_debug module"
fi
# Verify the ZED is not already running.
$PGREP -x zed > /dev/null
if (($? == 0)); then
log_fail "ZED already running"
fi
log_must $CP ${ZEDLETDIR}/all-syslog.sh $ZEDLET_DIR
log_note "Starting ZED"
#run ZED in the background and redirect foreground logging output to zedlog
log_must eval "$ZED -vF -d $ZEDLET_DIR -p $ZEDLET_DIR/zed.pid -s" \
"$ZEDLET_DIR/state 2>${ZEDLET_DIR}/zedlog &"
#if using loop devices, create a scsi_debug device to be used with
#auto-online test
if is_loop_device $DISK1; then
$LSMOD | $EGREP scsi_debug > /dev/zero
if (($? == 0)); then
log_fail "SCSI_DEBUG module already installed"
else
log_must $MODLOAD scsi_debug dev_size_mb=$SDSIZE \
add_host=$SDHOSTS num_tgts=$SDTGTS max_luns=$SDLUNS
block_device_wait
$LSSCSI | $EGREP scsi_debug > /dev/null
if (($? == 1)); then
log_fail "scsi_debug failed"
else
SDDEVICE=$($LSSCSI \
| $NAWK '/scsi_debug/ {print $6; exit}')
log_must $FORMAT -s $SDDEVICE mklabel gpt
fi
fi
fi
log_pass