Index: projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile (revision 328572) @@ -1,32 +1,33 @@ # $FreeBSD$ .include PACKAGE= tests TESTSDIR=${TESTSBASE}/sys/cddl/zfs/include STFSUITEDIR=${TESTSBASE}/sys/cddl/zfs MAN= FILESDIR= ${TESTSBASE}/sys/cddl/zfs/include ${PACKAGE}FILES+= constants.cfg ${PACKAGE}FILES+= libremote.kshlib ${PACKAGE}FILES+= libsas.kshlib +${PACKAGE}FILES+= libgnop.kshlib ${PACKAGE}FILES+= logapi.kshlib ${PACKAGE}FILES+= libtest.kshlib ${PACKAGE}FILES+= stf.shlib ${PACKAGE}FILES+= testenv.kshlib ${PACKAGE}FILES+= commands.cfg CLEANFILES+= commands.cfg commands.cfg: translatecommands.awk commands.txt awk -v stfsuitedir=${STFSUITEDIR} -f ${.ALLSRC} > ${.TARGET} ${PACKAGE}FILES+= default.cfg CLEANFILES+= default.cfg default.cfg: default.cfg.in sed "s:%%STFSUITEDIR%%:${STFSUITEDIR}:" ${.ALLSRC} > ${.TARGET} ATF_TESTS_KSH93+= libtest_test .include Index: projects/zfsd/head/tests/sys/cddl/zfs/include/libgnop.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/libgnop.kshlib (nonexistent) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/libgnop.kshlib (revision 328572) @@ -0,0 +1,89 @@ +# +# Copyright (c) 2017 Spectra Logic Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions, and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# substantially similar to the "NO WARRANTY" disclaimer below +# ("Disclaimer") and any redistribution must be conditioned upon +# including a substantially similar Disclaimer requirement for further +# binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. +# +# $FreeBSD$ +# + +# +# Routines that use gnop(8) to simulate devices that can disappear at any time +# + +# Create a gnop device on top of a real device. Don't use the full extent; use +# a portion in the middle so that any ZFS label present on the real device +# won't be present on the gnop device and vice versa. +function create_gnop +{ + typeset disk=$1 + # size of disk in bytes + typeset -li disk_size + # disk size, rounded down to multiple of 16384 + typeset -li disk_size_rounded + # size of the nop device in bytes + typeset -li nop_size + # offset of the beginning of the nop device in bytes + typeset -li nop_offset + + disk_size=`diskinfo da0 | cut -f 3` + # Round it down so the nop device will be 4k-aligned + disk_size_rounded=$(( ${disk_size} / 16384 * 16384 )) + nop_size=$(( ${disk_size_rounded} / 4 )) + nop_offset=${nop_size} + + gnop create -s ${nop_size} -o ${nop_offset} ${disk} +} + +# Create multiple gnop devices +function create_gnops +{ + typeset disk + for disk in $@; do + create_gnop "$disk" || return 1 + done + return 0 +} + +# Destroy a gnop device. +function destroy_gnop +{ + # Name of the underlying (non-gnop) device + typeset disk=$1 + + # Use "-f" so we can destroy a gnop with a consumer (like ZFS) + gnop destroy -f ${disk}.nop +} + +# Destroy multiple gnop devices. Attempt to destroy them all, ignoring errors +function destroy_gnops +{ + typeset disk + for disk in $@; do + destroy_gnop "$disk" + done + return 0 +} Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/cleanup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/cleanup.ksh (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/cleanup.ksh (revision 328572) @@ -1,50 +1,33 @@ #!/usr/local/bin/ksh93 -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 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)cleanup.ksh 1.3 08/11/03 SMI" # . $STF_SUITE/tests/hotplug/hotplug.kshlib -if ! $LOFIADM -f > /dev/null 2>&1; then - log_unsupported -fi - -verify_runnable "global" - cleanup_testenv $TESTPOOL -log_must destroy_lofi_device $ALL_FILES - -# -# record repair to resource(s) to cleanup fma faulty -# -log_must repair_faulty - -if [[ -d $VDEV_DIR ]]; then - log_must $RM -rf $VDEV_DIR -fi - -log_pass +destroy_gnops $ALL_DISKS Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug.cfg =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug.cfg (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug.cfg (revision 328572) @@ -1,41 +1,33 @@ # # 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 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotplug.cfg 1.3 08/08/15 SMI" # -export STF_TIMEOUT=1800 +export DEV_DISKS="$DISK0 $DISK1 $DISK2" +export SPARE_DISKS="$DISK3" +export ALL_DISKS="$DEV_DISKS $SPARE_DISKS" -export BG_PID='' - -export VDEV_DIR=/disk.${TESTCASE_ID} -export FILE_EVENT_ID=$VDEV_DIR/fma-event-id - -export NEWFILE=$VDEV_DIR/e -export SMALLFILE=$VDEV_DIR/smalldisk - -export DEV_FILES="$VDEV_DIR/a $VDEV_DIR/b $VDEV_DIR/c" -export SPARE_FILES="$VDEV_DIR/d" -export ALL_FILES="$DEV_FILES $SPARE_FILES $NEWFILE $SMALLFILE" +set_disks Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug.kshlib (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug.kshlib (revision 328572) @@ -1,515 +1,460 @@ # # 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 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotplug.kshlib 1.4 08/11/03 SMI" # . $STF_SUITE/include/libtest.kshlib +. $STF_SUITE/include/libgnop.kshlib +. $STF_SUITE/tests/hotplug/hotplug.cfg # # create lofi devices # # $1-n files # function create_lofi_device { typeset lofi_files="$@" typeset file for file in $lofi_files ; do if ! $LOFIADM $file > /dev/null 2>&1 ; then insert_device $file if (($? != 0)); then return 1 fi fi shift done return 0 } # # Check and destroy lofi devices # # $1-n lofi files or deviece # function destroy_lofi_device { typeset -i ret=0 typeset dev_file="$@" typeset file for file in $dev_file ; do if $LOFIADM $file > /dev/null 2>&1; then $LOFIADM -d $file -f if (($? != 0)); then ((ret += 1)) fi fi done return $ret } # -# Setup test environment using FILE[1-4] +# Setup test environment using DISKS[1-4] # -# $1 pool name -# $2 pool type +# $1 pool type # function setup_testenv { - typeset pool=$1 - typeset type=$2 + typeset type=$1 - if [[ -z $pool || -z $type ]]; then - log_fail "Usage: setup_testenv " + if [[ -z $type ]]; then + log_fail "Usage: setup_testenv " fi - log_must repair_faulty - - log_must create_lofi_device $DEV_FILES $SPARE_FILES - - typeset devlist=$(convert_lofi $DEV_FILES) - typeset sparelist=$(convert_lofi $SPARE_FILES) - typeset spare=$(random_get_with_non "spare") log_must $ZPOOL create -f \ - $pool $type $devlist $spare $sparelist - log_must start_bg_write $pool - - # Provide 10 seconds for background process to write - $SLEEP 10 + $TESTPOOL $type ${DISK0}.nop ${DISK1}.nop ${DISK2}.nop ${DISK3}.nop } # # Cleanup test envirnment according to pool name # # $1 pool # function cleanup_testenv { - typeset pool=$1 - - if [[ -z $pool ]]; then - log_fail "Usage: cleanup_testenv " - fi - - log_must repair_faulty - - kill_bg_write - log_must $SYNC - $SLEEP 10 - - typeset -i i=0 - if datasetexists $pool; then - typeset mntpnt=$(get_prop mountpoint $pool) - # Try three times in order to ensure successful pool destruction - while ((i < 3)); do - $ZPOOL destroy -f $pool - if (($? == 0)); then - break - fi - $SLEEP 5 - ((i += 1)) - done - fi - - if ((i == 3)); then - log_fail "Unable to destroy $pool, even after 3 attempts." - fi + destroy_pool $TESTPOOL } # # Start a background process to write file on given pool. # # $1 pool # function start_bg_write { typeset pool=$1 if datasetnonexists $pool; then return 1 fi typeset mntpnt=$(get_prop mountpoint $pool) while true; do $DD if=/dev/random of=$mntpnt/foo count=10 $SYNC $SLEEP 1 done & BG_PID=$! return 0 } # # Kill the background write process. # function kill_bg_write { typeset -i ret=0 if [[ -n $BG_PID ]]; then kill -9 $BG_PID ret=$? if ((ret == 0)); then BG_PID='' fi fi $SLEEP 10 return $ret } # # Insert a given file into a given device slot # # $1 file # $2 device # function insert_device { typeset file=$1 typeset device=$2 if [[ -z $file ]]; then return 1 fi # # Make sure insert device succeed within 60 seconds # typeset -i i=0 while ((i < 6)); do $SLEEP 10 $LOFIADM -a $file $device -f > /dev/null 2>&1 if (($? == 0)); then return 0 fi ((i += 1)) done return 1 } # # Remove the given lofi device # # $1 device or file # function remove_device { typeset devfile=$1 if [[ -z $devfile ]]; then return 1 fi # # Make sure remove device succeed within 60 seconds # typeset -i i=0 while ((i < 6)); do $SLEEP 10 $LOFIADM -d $devfile -f if (($? == 0)); then return 0 fi ((i += 1)) done return 1 } # # Verify the given devices have expected status in pool # # $1 pool # $2 device # $3 expected status # function verify_device_status { typeset pool=$1 typeset device=$2 typeset expect_stat=$3 if [[ -z $pool || -z $expect_stat || -z $device ]]; then log_note "Usage: verify_device_status " return 1 fi # # 1.5 minute disk status checking, make sure zpool sync disk status. # typeset -i i=0 while ((i < 9)); do $SLEEP 10 typeset str=$($ZPOOL status $pool | $GREP "lofi" | \ $AWK '{print $1 " " $2}') typeset real_stat=${str##*$device } real_stat=$($ECHO $real_stat | $AWK '{print $1}') if [[ "$expect_stat" == "$real_stat" ]]; then return 0 fi ((i += 1)) done log_note "Expected status($expect_stat), " \ "see status($real_stat) for $device" $ZPOOL status -v $pool return 1 } # # Output fma event id to given file, the default output file is $FILE_EVENT_ID # function getfmri { eval typeset output_file=${1:-$FILE_EVENT_ID} # # fmadm faulty output include several sections below # # --------------- ------------------------------------ -------------- --------- # TIME EVENT-ID MSG-ID SEVERITY # --------------- ------------------------------------ -------------- --------- # Aug 31 22:34:19 ec648a9e-0c9f-c495-e176-e38ba212e278 ZFS-8000-D3 Major # Aug 31 19:44:59 d69cdd12-b0cf-62ea-d0a3-8d2e9ebfeb50 ZFS-8000-D3 # Aug 31 19:35:16 7213f0d5-00d4-ea32-ddfc-98cdd683c27e ZFS-8000-D3 # Aug 31 19:29:11 33424bef-a973-4dae-94ef-cb97f2cb0759 ZFS-8000-D3 # Aug 31 17:07:26 74219b66-ead4-6d2b-bbad-bc40547ca02e ZFS-8000-GH # # Fault class : fault.fs.zfs.device # # Description : A ZFS device failed. Refer to http://sun.com/msg/ZFS-8000-D3 for # more information. # # Response : No automated response will occur. # # Impact : Fault tolerance of the pool may be compromised. # # Action : Run 'zpool status -x' and replace the bad device. # $FMADM faulty | $NAWK ' BEGIN { start = 0 } /^---/ && /---$/ { if (start == 0) { start = 1 } } /^TIME/ && /SEVERITY$/ { if (start == 1) { start = 2 } } /^---/ && /---$/ { if (start == 2) { start = 3 continue } } /^$/ { start = 0 } (start == 3) {print $4}' > $output_file -} - -# -# Repair all the fma error in current system -# -function repair_faulty -{ - getfmri $FILE_EVENT_ID - while read item; do - $FMADM repair $item > /dev/null 2>&1 - if (($? != 0)); then - return 1 - fi - done < $FILE_EVENT_ID - - return 0 } # # Verify if ZFS FMA faulty error message are generated. # # $1 TRUE or FALSE # function fma_faulty { # # 1.5 minute for FMA faulty checking, make sure FMA sync with ZFS status # typeset expect=${1:-TRUE} typeset -i fsize typeset -i i=0 while ((i < 9)); do $SLEEP 10 # # try to get fma faulty # getfmri $FILE_EVENT_ID fsize=$($LS -ld $FILE_EVENT_ID | $AWK '{print $5}') case $expect in TRUE) if (( fsize != 0 )); then return 0 fi ;; FALSE) if (( fsize == 0 )); then return 0 fi ;; *) return 1 esac ((i += 1)) done return 1 } # # Create fresh file # # $1 file size # $2 file name # function create_file { typeset size=$1 typeset file=$2 if [[ -z $size || -z $file ]]; then log_note "Usage: create_file " return 1 fi if [[ -f $file ]]; then $RM -f $file fi $MKFILE $size $file return $? } # # Unmount all filesystem, and disable syseventd and fmd piror to # unloading ZFS module # function unload_zfs { # destroy /dev/zvol link log_must $ZFS volfini log_must $ZFS unmount -f -a log_must $SVCADM disable -t sysevent fmd $SLEEP 10 # # 1 minute for ZFS module unload checking # # For example: # # 192 fffffffff7c92000 99858 182 1 zfs (ZFS storage pool version 6) # typeset -i i=0 while ((i < 10)); do typeset id=$($MODINFO | $GREP "ZFS storage" | $AWK '{print $1}') if [[ -n $id ]]; then $MODUNLOAD -i $id if (($? == 0)) ; then return 0 fi else return 0 fi $SLEEP 6 ((i += 1)) done return 1 } # # Load ZFS module and remount all filesystem # function load_zfs { typeset -i ret=0 $SVCADM enable sysevent fmd ((ret |= $?)) $SLEEP 10 $ZFS mount -a ((ret |= $?)) # create /dev/zvol link $ZFS volinit ((ret |= $?)) return $ret } # # Convert file name to device name or reverse. # # $1-n lofi files or devices # function convert_lofi { typeset n list for n in "$@"; do typeset item=$($LOFIADM $n) list="$list $item" shift done $ECHO $list } Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_001_pos.ksh (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_001_pos.ksh (revision 328572) @@ -1,86 +1,74 @@ #!/usr/local/bin/ksh93 -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 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotplug_001_pos.ksh 1.2 08/02/27 SMI" # . $STF_SUITE/tests/hotplug/hotplug.kshlib ################################################################################# # # __stc_assertion_start # # ID: hotplug_001_pos # # DESCRIPTION: # When removing a device from a redundant pool, the device's state will -# be indicated as 'REMOVED'. No FMA faulty message. +# be indicated as 'REMOVED'. # # STRATEGY: # 1. Create mirror/raidz/raidz2 pool. # 2. Synchronise with device in the background. # 3. Remove one of device of pool. # 4. Detect removed devices status is 'REMOVED'. # 5. Detect no FMA faulty message. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2007-06-01) # # __stc_assertion_end # ################################################################################ -verify_runnable "global" - -function cleanup -{ - cleanup_testenv $TESTPOOL -} - log_assert "When removing a device from a redundant pool, the device's " \ - "state will be indicated as 'REMOVED'. No FMA faulty message." -log_onexit cleanup + "state will be indicated as 'REMOVED'." for type in "mirror" "raidz" "raidz2"; do log_note "Start $type testing ..." - setup_testenv $TESTPOOL $type + setup_testenv $type - typeset file=$(random_get $DEV_FILES) - typeset device=$(convert_lofi $file) - log_must remove_device $device - log_must $ZPOOL clear $TESTPOOL + log_must destroy_gnop $DISK0 + log_must check_state $TESTPOOL ${DISK0}.nop 'REMOVED' - log_must verify_device_status $TESTPOOL $device 'REMOVED' - log_must fma_faulty 'FALSE' - + log_must create_gnop $DISK0 cleanup_testenv $TESTPOOL done log_pass "When removing a device from a redundant pool, the device's " \ - "state will be indicated as 'REMOVED'. No FMA faulty message." + "state will be indicated as 'REMOVED'." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_008_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_008_pos.ksh (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_008_pos.ksh (revision 328572) @@ -1,89 +1,72 @@ #!/usr/local/bin/ksh93 -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 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotplug_008_pos.ksh 1.3 08/02/27 SMI" # . $STF_SUITE/tests/hotplug/hotplug.kshlib ################################################################################# # # __stc_assertion_start # # ID: hotplug_008_pos # # DESCRIPTION: # After hot spare device is revoved, the devices state will be 'REMOVED'. # No FMA faults was generated. # # STRATEGY: # 1. Create mirror/raidz/raidz2 pool with hot spare device. # 2. Synchronise with device in the background. # 3. Remove the hotspare device. # 4. Verify the device's status is 'REMOVED'. # 5. Verify no FMA fault was generated. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2007-06-01) # # __stc_assertion_end # ################################################################################ -log_unsupported "Hotplugging of hotspare devices is not supported." - -verify_runnable "global" - -function cleanup -{ - cleanup_testenv $TESTPOOL -} - log_assert "When removing hotspare device, verify device status is 'REMOVED'." -log_onexit cleanup for type in "mirror" "raidz" "raidz2"; do - log_must create_lofi_device $DEV_FILES $SPARE_FILES - log_must $ZPOOL create -f $TESTPOOL $type $DEV_FILES spare $SPARE_FILES - log_must start_bg_write $TESTPOOL - typeset val=$(random_get "on" "off") - log_must $ZPOOL set autoreplace=$val $TESTPOOL + log_must $ZPOOL create -f $TESTPOOL $type $DISK0.nop $DISK1.nop $DISK2.nop spare $DISK3.nop - typeset file=$(random_get $SPARE_FILES) - typeset device=$(convert_lofi $file) - log_must remove_device $device - log_must $ZPOOL clear $TESTPOOL + log_must destroy_gnop $DISK3 + wait_for 15 1 check_state $TESTPOOL $DISK3.nop 'REMOVED' + log_must check_state $TESTPOOL $DISK3.nop 'REMOVED' - log_must verify_device_status $TESTPOOL $device 'REMOVED' - log_must fma_faulty 'TRUE' - + log_must create_gnop $DISK3 cleanup_testenv $TESTPOOL done log_pass "When removing hotspare device, verify device status is 'REMOVED'." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_011_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_011_pos.ksh (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_011_pos.ksh (revision 328572) @@ -1,119 +1,82 @@ #!/usr/local/bin/ksh93 -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 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotplug_011_pos.ksh 1.1 07/07/31 SMI" # . $STF_SUITE/tests/hotplug/hotplug.kshlib ################################################################################# # # __stc_assertion_start # # ID: hotplug_011_pos # # DESCRIPTION: # Removing device offlined, verify device status is UNAVAIL, when the # system is onlined. # # STRATEGY: # 1. Create mirror/raidz/raidz2 pool w/a hot spare device. # 2. Synchronise with device in the background. # 3. Set or unset autoreplace # 4. Unmount all filesystems and disable syseventd and fmd. # 5. Unload ZFS module and remove devices. # 6. Load ZFS module and verify device the device's status is 'UNAVAIL'. # 7. Verify no FMA fault was generated. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2007-06-01) # # __stc_assertion_end # ################################################################################ -verify_runnable "global" +log_assert "If a vdev is missing when a pool is imported, its status will be " \ + "UNAVAIL" -fstype=$(get_fstype '/') -if [[ $fstype == 'zfs' ]]; then - log_unsupported "This test cases is not supported on ZFS root system." -fi - -function cleanup -{ - typeset fmri - for fmri in 'sysevent' 'fmd'; do - typeset stat=$($SVCS -H -o STATE $fmri) - if [[ $stat != 'online' ]]; then - log_must $SVCADM enable $fmri - fi - $SLEEP 5 - done - - cleanup_testenv $TESTPOOL -} - -log_assert "Removing device offlined, verify device status is UNAVAIL, " \ - "when the system is onlined." -log_onexit cleanup - for type in "mirror" "raidz" "raidz2"; do - setup_testenv $TESTPOOL $type - typeset val=$(random_get 'off' 'on') - log_must $ZPOOL set autoreplace=$val $TESTPOOL + setup_testenv $type - # - # Piror to unmount, stop background writing to avoid mount failed - # due to mountpoint is not empty - # - log_must kill_bg_write + log_must $ZPOOL export $TESTPOOL - # - # Unloading ZFS module to simulate system powered off - # - log_must unload_zfs - # Random remove one of devices - typeset file=$(random_get $DEV_FILES) - typeset device=$(convert_lofi $file) - log_must remove_device $device + log_must destroy_gnop $DISK0 - # Reload ZFS module - log_must load_zfs + # reimport the pool + log_must $ZPOOL import $TESTPOOL - # After mount, restart background writing process - log_must start_bg_write $TESTPOOL - log_must verify_device_status $TESTPOOL $device 'UNAVAIL' - log_must fma_faulty 'FALSE' + log_must check_state $TESTPOOL $DISK0.nop 'UNAVAIL' + log_must create_gnop $DISK0 cleanup_testenv $TESTPOOL done -log_pass "Removing device offlined, verify device status is UNAVAIL, " \ - "when the system is onlined." +log_pass "If a vdev is missing when a pool is imported, its status will be " \ + "UNAVAIL" Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_test.sh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_test.sh (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_test.sh (revision 328572) @@ -1,327 +1,335 @@ # 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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # atf_test_case hotplug_001_pos cleanup hotplug_001_pos_head() { - atf_set "descr" "When removing a device from a redundant pool, the device'sstate will be indicated as 'REMOVED'. No FMA faulty message." - atf_set "require.progs" zpool lofiadm - atf_set "timeout" 1800 + atf_set "descr" "When removing a device from a redundant pool, the device'sstate will be indicated as 'REMOVED'." + atf_set "require.progs" zpool gnop } hotplug_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_001_pos.ksh || atf_fail "Testcase failed" } hotplug_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_002_pos cleanup hotplug_002_pos_head() { - atf_set "descr" "When removing and reinserting a device, the device status isONLINE with no FMA errors." - atf_set "require.progs" zpool lofiadm - atf_set "timeout" 1800 + atf_set "descr" "When removing and reinserting a device, the device status is ONLINE." + atf_set "require.progs" zpool gnop } hotplug_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "redundant with zfsd_replace_001_pos" + verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_002_pos.ksh || atf_fail "Testcase failed" } hotplug_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_003_pos cleanup hotplug_003_pos_head() { atf_set "descr" "Having removed a device from a redundant pool and inserted a newdevice, the new device state will be 'ONLINE' when autoreplace is on,\and 'UNAVAIL' when autoreplace is off" atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_003_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "redundant with zfsd_autoreplace_00[12]*" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_003_pos.ksh || atf_fail "Testcase failed" } hotplug_003_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_004_pos cleanup hotplug_004_pos_head() { atf_set "descr" "When device replacement fails, the original device's state willbe 'UNAVAIL' and an FMA fault will be generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_004_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "Does not apply to FreeBSD" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_004_pos.ksh || atf_fail "Testcase failed" } hotplug_004_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_005_pos cleanup hotplug_005_pos_head() { atf_set "descr" "Regarding of autoreplace, when removing offline device andreinserting again. This device's status is 'ONLINE'. \No FMA fault was generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_005_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "TODO: move to the zfsd directory" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_005_pos.ksh || atf_fail "Testcase failed" } hotplug_005_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_006_pos cleanup hotplug_006_pos_head() { atf_set "descr" "When unsetting/setting autoreplace, then replacing device, verifythe device's status is 'UNAVAIL/ONLINE'. No FMA fault is generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_006_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "redundant with hotplug_050_pos" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_006_pos.ksh || atf_fail "Testcase failed" } hotplug_006_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_007_pos cleanup hotplug_007_pos_head() { atf_set "descr" "When autoreplace is 'on', replacing the device with a smaller one.Verify the device's status is 'UNAVAIL'. FMA fault has been generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_007_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "TODO: move to cli_root/zpool_replace" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_007_pos.ksh || atf_fail "Testcase failed" } hotplug_007_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_008_pos cleanup hotplug_008_pos_head() { atf_set "descr" "When removing hotspare device, verify device status is 'REMOVED'." - atf_set "require.progs" zpool lofiadm - atf_set "timeout" 1800 + atf_set "require.progs" zpool gnop } hotplug_008_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_008_pos.ksh || atf_fail "Testcase failed" } hotplug_008_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_009_pos cleanup hotplug_009_pos_head() { atf_set "descr" "Power off machine and replacing device, verify device status isONLINE when autoreplace is on and UNAVAIL when autoreplace is off" atf_set "require.progs" zpool lofiadm svcadm svcs atf_set "timeout" 1800 } hotplug_009_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "redundant with zfsd_import_001_pos" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_009_pos.ksh || atf_fail "Testcase failed" } hotplug_009_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_010_pos cleanup hotplug_010_pos_head() { atf_set "descr" "Removing device offlined and reinserting onlined,verify the device status ONLINE." atf_set "require.progs" zpool lofiadm svcadm svcs atf_set "timeout" 1800 } hotplug_010_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + atf_skip "redundant with zfsd_replace_001_pos" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_010_pos.ksh || atf_fail "Testcase failed" } hotplug_010_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_011_pos cleanup hotplug_011_pos_head() { atf_set "descr" "Removing device offlined, verify device status is UNAVAIL,when the system is onlined." - atf_set "require.progs" zpool lofiadm svcadm svcs - atf_set "timeout" 1800 + atf_set "require.progs" zpool gnop } hotplug_011_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg + verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_011_pos.ksh || atf_fail "Testcase failed" } hotplug_011_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_init_test_cases() { atf_add_test_case hotplug_001_pos atf_add_test_case hotplug_002_pos atf_add_test_case hotplug_003_pos atf_add_test_case hotplug_004_pos atf_add_test_case hotplug_005_pos atf_add_test_case hotplug_006_pos atf_add_test_case hotplug_007_pos atf_add_test_case hotplug_008_pos atf_add_test_case hotplug_009_pos atf_add_test_case hotplug_010_pos atf_add_test_case hotplug_011_pos } Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/setup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/setup.ksh (revision 328571) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/setup.ksh (revision 328572) @@ -1,51 +1,33 @@ #!/usr/local/bin/ksh93 -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 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)setup.ksh 1.3 08/11/03 SMI" # . $STF_SUITE/tests/hotplug/hotplug.kshlib -if ! $LOFIADM -f > /dev/null 2>&1; then - log_unsupported -fi - -verify_runnable "global" - -if [[ -d $VDEV_DIR ]]; then - log_must $RM -rf $VDEV_DIR -fi - -log_must $MKDIR -p $VDEV_DIR -log_must $TRUNCATE -s 100M $DEV_FILES $SPARE_FILES $NEWFILE -log_must create_lofi_device $DEV_FILES $SPARE_FILES - -# -# record repair to resource(s) to cleanup fma faulty -# -log_must repair_faulty - +log_must create_gnops $ALL_DISKS log_pass