Index: projects/zfsd/head/tests/sys/cddl/zfs/include/libgnop.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/libgnop.kshlib (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/libgnop.kshlib (revision 329027) @@ -1,89 +1,97 @@ # # 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 { + # Name of disk to use, with or without /dev/ typeset disk=$1 + # Optional physical path to use + typeset physpath=$2 # 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 + typeset args - disk_size=`diskinfo da0 | cut -f 3` + disk_size=`diskinfo $disk | 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} + args="-s ${nop_size} -o ${nop_offset}" + if [ -n "$physpath" ]; then + args="$args -z $physpath" + fi - gnop create -s ${nop_size} -o ${nop_offset} ${disk} + gnop create ${args} ${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/zfsd/cleanup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/cleanup.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/cleanup.ksh (revision 329027) @@ -1,36 +1,37 @@ #!/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 (c) 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib +. ${STF_SUITE}/include/libgnop.kshlib -verify_runnable "global" - # Rotate logs now, because this test can generate a great volume of log entries newsyslog -default_cleanup +default_cleanup_noexit +destroy_gnops ${DISKS} +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/setup.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/setup.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/setup.ksh (revision 329027) @@ -1,46 +1,34 @@ #!/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 (c) 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # # $FreeBSD$ . ${STF_SUITE}/include/libtest.kshlib -. ${STF_SUITE}/include/libsas.kshlib - -verify_runnable "global" -echo "list of disks: $DISKS" - -# Make sure that all of the disks that we've been given are attached to a -# SAS expander, and that we can find the phy they're attached to. This -# function will cause the script to exit if it fails. -for disk in $DISKS -do - find_verify_sas_disk $disk -done # Rotate logs now, because this test can generate a great volume of log entries newsyslog log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_001_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_001_neg.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_001_neg.ksh (revision 329027) @@ -1,92 +1,93 @@ #!/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 2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_007_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_autoreplace_001_neg # # DESCRIPTION: -# In a pool with the autoreplace property unset, a vdev will not be +# In a pool without the autoreplace property unset, a vdev will not be # replaced by physical path # # STRATEGY: # 1. Create 1 storage pool without hot spares -# 2. Remove a vdev by disabling its SAS phy -# 3. Export the pool -# 4. Reenable the missing dev's SAS phy -# 5. Erase the missing dev's ZFS label -# 6. Disable the missing dev's SAS phy again -# 7. Import the pool -# 8. Reenable the missing dev's SAS phy +# 2. Remove a vdev +# 4. Create a new vdev with the same physical path as the first one # 9. Verify that it does not get added to the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2013-02-4) # # __stc_assertion_end # ############################################################################### -verify_runnable "global" +log_assert "A pool without the autoreplace property set will not replace disks by physical path" -log_assert "A pool with the autoreplace property set will replace disks by physical path" - - -log_onexit autoreplace_cleanup - function verify_assertion { - do_autoreplace # 9. Verify that it does not get added to the pool for ((timeout=0; timeout<4; timeout=$timeout+1)); do log_mustnot check_state $TESTPOOL $REMOVAL_DISK "ONLINE" $SLEEP 5 done } - +typeset PHYSPATH="some_physical_path" typeset REMOVAL_DISK=$DISK0 -typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" +typeset REMOVAL_NOP=${DISK0}.nop +typeset NEW_DISK=$DISK4 +typeset NEW_NOP=${DISK4}.nop +typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" +typeset ALLDISKS="${DISK0} ${DISK1} ${DISK2} ${DISK3}" +typeset ALLNOPS=${ALLDISKS//~(E)([[:space:]]+|$)/.nop\1} set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" ensure_zfsd_running +log_must create_gnops $OTHER_DISKS for keyword in "${MY_KEYWORDS[@]}" ; do - log_must create_pool $TESTPOOL $keyword $POOLDEVS - log_must poolexists "$TESTPOOL" - log_must $ZPOOL set autoreplace=off $TESTPOOL + log_must create_gnop $REMOVAL_DISK $PHYSPATH + log_must create_pool $TESTPOOL $keyword $ALLNOPS + log_must $ZPOOL set autoreplace=on $TESTPOOL + + log_must destroy_gnop $REMOVAL_DISK + log_must create_gnop $NEW_DISK $PHYSPATH verify_assertion destroy_pool "$TESTPOOL" + log_must destroy_gnop $NEW_DISK done + +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_002_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_002_pos.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_002_pos.ksh (revision 329027) @@ -1,87 +1,90 @@ #!/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 2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_007_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_autoreplace_002_pos # # DESCRIPTION: # In a pool with the autoreplace property set, a vdev will be # replaced by physical path # # STRATEGY: # 1. Create 1 storage pool without hot spares -# 2. Remove a vdev by disabling its SAS phy -# 3. Export the pool -# 4. Reenable the missing dev's SAS phy -# 5. Erase the missing dev's ZFS label -# 6. Disable the missing dev's SAS phy again -# 7. Import the pool -# 8. Reenable the missing dev's SAS phy +# 2. Remove a vdev +# 4. Create a new vdev with the same physical path as the first one # 9. Verify that it does get added to the pool. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2013-02-4) # # __stc_assertion_end # ############################################################################### -verify_runnable "global" - log_assert "A pool with the autoreplace property will replace disks by physical path" -log_onexit autoreplace_cleanup - function verify_assertion { - do_autoreplace - wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE + wait_for_pool_dev_state_change 20 $NEW_DISK ONLINE } +typeset PHYSPATH="some_physical_path" typeset REMOVAL_DISK=$DISK0 -typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" +typeset REMOVAL_NOP=${DISK0}.nop +typeset NEW_DISK=$DISK4 +typeset NEW_NOP=${DISK4}.nop +typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" +typeset ALLDISKS="${DISK0} ${DISK1} ${DISK2} ${DISK3}" +typeset ALLNOPS=${ALLDISKS//~(E)([[:space:]]+|$)/.nop\1} set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" ensure_zfsd_running +log_must create_gnops $OTHER_DISKS for keyword in "${MY_KEYWORDS[@]}" ; do - log_must create_pool $TESTPOOL $keyword $POOLDEVS - log_must poolexists "$TESTPOOL" + log_must create_gnop $REMOVAL_DISK $PHYSPATH + log_must create_pool $TESTPOOL $keyword $ALLNOPS log_must $ZPOOL set autoreplace=on $TESTPOOL + + log_must destroy_gnop $REMOVAL_DISK + log_must create_gnop $NEW_DISK $PHYSPATH verify_assertion destroy_pool "$TESTPOOL" + log_must destroy_gnop $NEW_DISK done + +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh (revision 329027) @@ -1,97 +1,100 @@ #!/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 2014 Spectra Logic. All rights reserved. # Use is subject to license terms. # # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_autoreplace_003_pos # # DESCRIPTION: # In a pool with the autoreplace property set, a vdev will be # replaced by physical path even if a spare is already active for that # vdev # # STRATEGY: # 1. Create 1 storage pool with a hot spare -# 2. Remove a vdev by disabling its SAS phy +# 2. Remove a vdev # 3. Wait for the hotspare to fully resilver -# 4. Export the pool -# 5. Reenable the missing dev's SAS phy -# 6. Erase the missing dev's ZFS label -# 7. Disable the missing dev's SAS phy again -# 8. Import the pool -# 9. Reenable the missing dev's SAS phy +# 4. Create a new vdev with the same physical path as the first one # 10. Verify that it does get added to the pool. # 11. Verify that the hotspare gets removed. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2013-05-13) # # __stc_assertion_end # ############################################################################### -verify_runnable "global" +log_assert "A pool with the autoreplace property will replace disks by physical path, even if a spare is active" -log_assert "A pool with the autoreplace property will replace disks by physical path" - -log_onexit autoreplace_cleanup - function verify_assertion { - do_autoreplace "$SPARE_DISK" - # Verify that the original disk gets added to the pool - wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE + # Verify that the replacement disk gets added to the pool + wait_for_pool_dev_state_change 20 $NEW_DISK ONLINE # Wait for resilvering to complete wait_until_resilvered # Check that the spare is deactivated wait_for_pool_dev_state_change 20 "$SPARE_DISK" "AVAIL" } -typeset SPARE_DISK=$DISK0 -typeset REMOVAL_DISK=$DISK1 -typeset POOLDEVS="$DISK1 $DISK2 $DISK3 $DISK4" +typeset PHYSPATH="some_physical_path" +typeset REMOVAL_DISK=$DISK0 +typeset REMOVAL_NOP=${DISK0}.nop +typeset NEW_DISK=$DISK4 +typeset NEW_NOP=${DISK4}.nop +typeset SPARE_DISK=${DISK5} +typeset SPARE_NOP=${DISK5}.nop +typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" +typeset OTHER_NOPS=${OTHER_DISKS//~(E)([[:space:]]+|$)/.nop\1} set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" ensure_zfsd_running +log_must create_gnops $OTHER_DISKS $SPARE_DISK for keyword in "${MY_KEYWORDS[@]}" ; do - log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SPARE_DISK - log_must poolexists "$TESTPOOL" + log_must create_gnop $REMOVAL_DISK $PHYSPATH + log_must create_pool $TESTPOOL $keyword $REMOVAL_NOP $OTHER_NOPS spare $SPARE_NOP log_must $ZPOOL set autoreplace=on $TESTPOOL + + log_must destroy_gnop $REMOVAL_DISK + log_must create_gnop $NEW_DISK $PHYSPATH verify_assertion destroy_pool "$TESTPOOL" + log_must destroy_gnop $NEW_DISK done + +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh (revision 329027) @@ -1,108 +1,106 @@ #!/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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_006_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfs_hotspare_004_pos # # DESCRIPTION: # If a vdev gets removed from a pool with a spare, the spare will be # activated. # # # STRATEGY: -# 1. Create 1 storage pools with hot spares. Use disks instead of files -# because they can be removed. -# 2. Remove one vdev by turning off its SAS phy. +# 1. Create 1 storage pools with hot spares. +# 2. Remove one vdev # 3. Verify that the spare is in use. -# 4. Reinsert the vdev by enabling its phy +# 4. Recreate the vdev # 5. Verify that the vdev gets resilvered and the spare gets removed # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2012-08-10) # # __stc_assertion_end # ############################################################################### -verify_runnable "global" - log_assert "Removing a disk from a pool results in the spare activating" -log_onexit autoreplace_cleanup - - function verify_assertion # spare_dev { typeset spare_dev=$1 - find_verify_sas_disk $REMOVAL_DISK - log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" - disable_sas_disk $EXPANDER $PHY + log_must destroy_gnop $REMOVAL_DISK # Check to make sure ZFS sees the disk as removed wait_for_pool_removal 20 # Check that the spare was activated wait_for_pool_dev_state_change 20 $spare_dev INUSE log_must $ZPOOL status $TESTPOOL # Reenable the missing disk - log_note "Reenabling phy on expander $EXPANDER phy $PHY" - enable_sas_disk $EXPANDER $PHY + log_must create_gnop $REMOVAL_DISK $PHYSPATH # Check that the disk has rejoined the pool & resilvered - wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE + wait_for_pool_dev_state_change 20 $REMOVAL_NOP ONLINE wait_until_resilvered # Finally, check that the spare deactivated wait_for_pool_dev_state_change 20 $spare_dev AVAIL } +typeset PHYSPATH="some_physical_path" typeset REMOVAL_DISK=$DISK0 -typeset SDEV=$DISK4 -typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" +typeset REMOVAL_NOP=${DISK0}.nop +typeset SPARE_DISK=$DISK4 +typeset SPARE_NOP=${DISK4}.nop +typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" +typeset OTHER_NOPS=${OTHER_DISKS//~(E)([[:space:]]+|$)/.nop\1} set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" ensure_zfsd_running +log_must create_gnops $OTHER_DISKS $SPARE_DISK +log_must create_gnop $REMOVAL_DISK $PHYSPATH for keyword in "${MY_KEYWORDS[@]}" ; do - log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SDEV - log_must poolexists "$TESTPOOL" - log_must $ZPOOL set autoreplace=on "$TESTPOOL" - iterate_over_hotspares verify_assertion $SDEV + log_must create_pool $TESTPOOL $keyword $REMOVAL_NOP $OTHER_NOPS spare $SPARE_NOP + log_must $ZPOOL set autoreplace=on $TESTPOOL + iterate_over_hotspares verify_assertion $SPARE_NOP destroy_pool "$TESTPOOL" done + +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh (revision 329027) @@ -1,102 +1,106 @@ #!/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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_replace_006_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfs_hotspare_007_pos # # DESCRIPTION: # If a vdev gets removed from a pool with a spare while zfsd is shut # down, then the spare will be activated when zfsd restarts # # # STRATEGY: -# 1. Create 1 storage pools with hot spares. Use disks instead of files -# because they can be removed. +# 1. Create 1 storage pools with hot spares. # 2. Turn off zfsd -# 3. Remove one vdev by turning off its SAS phy. +# 3. Remove one vdev # 4. Restart zfsd # 5. Verify that the spare is in use. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2014-09-17) # # __stc_assertion_end # ############################################################################### verify_runnable "global" log_assert "zfsd will spare missing drives on startup" log_onexit autoreplace_cleanup function verify_assertion # spare_dev { typeset spare_dev=$1 - find_verify_sas_disk $REMOVAL_DISK stop_zfsd - log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" - disable_sas_disk $EXPANDER $PHY + log_must destroy_gnop $REMOVAL_DISK # Check to make sure ZFS sees the disk as removed wait_for_pool_removal 20 restart_zfsd # Check that the spare was activated wait_for_pool_dev_state_change 20 $spare_dev INUSE # Reenable the missing disk - log_note "Reenabling phy on expander $EXPANDER phy $PHY" - enable_sas_disk $EXPANDER $PHY + log_must create_gnop $REMOVAL_DISK $PHYSPATH } +typeset PHYSPATH="some_physical_path" typeset REMOVAL_DISK=$DISK0 -typeset SDEV=$DISK4 -typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" +typeset REMOVAL_NOP=${DISK0}.nop +typeset SPARE_DISK=$DISK4 +typeset SPARE_NOP=${DISK4}.nop +typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" +typeset OTHER_NOPS=${OTHER_DISKS//~(E)([[:space:]]+|$)/.nop\1} set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" ensure_zfsd_running +log_must create_gnops $OTHER_DISKS $SPARE_DISK +log_must create_gnop $REMOVAL_DISK $PHYSPATH for keyword in "${MY_KEYWORDS[@]}" ; do - log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SDEV - log_must poolexists "$TESTPOOL" - iterate_over_hotspares verify_assertion $SDEV + log_must create_pool $TESTPOOL $keyword $REMOVAL_NOP $OTHER_NOPS spare $SPARE_NOP + log_must $ZPOOL set autoreplace=on $TESTPOOL + iterate_over_hotspares verify_assertion $SPARE_NOP destroy_pool "$TESTPOOL" done + +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh (revision 329027) @@ -1,154 +1,150 @@ #!/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 2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # # ident "@(#)zfsd_zfsd_002_pos.ksh 1.0 12/08/10 SL" # . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfsd_import_001_pos # # DESCRIPTION: # If a removed drive gets reinserted while the pool is exported, it will # replace its spare when reimported. # # This also applies to drives that get reinserted while the machine is # powered off. # # # STRATEGY: -# 1. Create 1 storage pools with hot spares. Use disks instead of files -# because they can be removed. -# 2. Remove one disk by turning off its SAS phy. +# 1. Create 1 storage pools with hot spares. +# 2. Remove one disk # 3. Verify that the spare is in use. -# 4. Reinsert the vdev by enabling its phy -# 5. Verify that the vdev gets resilvered and the spare gets removed -# 6. Use additional zpool history data to verify that the pool +# 4. Export the pool +# 5. Recreate the vdev +# 6. Import the pool +# 7. Verify that the vdev gets resilvered and the spare gets removed +# 8. Use additional zpool history data to verify that the pool # finished resilvering _before_ zfsd detached the spare. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2012-08-10) # # __stc_assertion_end # ############################################################################### verify_runnable "global" function verify_assertion # spare_dev { typeset spare_dev=$1 - find_verify_sas_disk $REMOVAL_DISK - log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" - disable_sas_disk $EXPANDER $PHY + log_must destroy_gnop $REMOVAL_DISK # Check to make sure ZFS sees the disk as removed wait_for_pool_removal 20 # Wait for zfsd to activate the spare wait_for_pool_dev_state_change 20 $spare_dev INUSE log_must $ZPOOL status $TESTPOOL # Export the pool log_must $ZPOOL export $TESTPOOL # Reenable the missing disk - log_note "Reenabling phy on expander $EXPANDER phy $PHY" - enable_sas_disk $EXPANDER $PHY + log_must create_gnop $REMOVAL_DISK # Import the pool log_must $ZPOOL import $TESTPOOL # Check that the disk has rejoined the pool wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE # Check that the pool resilvered while ! is_pool_resilvered $TESTPOOL; do $SLEEP 2 done log_must $ZPOOL status $TESTPOOL #Finally, check that the spare deactivated wait_for_pool_dev_state_change 20 $spare_dev AVAIL # Verify that the spare was detached after the scrub was complete # Note that resilvers and scrubs are recorded identically in zpool # history $ZPOOL history -i $TESTPOOL | awk ' BEGIN { scrub_txg=0; detach_txg=0 } /scrub done/ { split($6, s, "[:\\]]"); t=s[2]; scrub_txg = scrub_txg > t ? scrub_txg : t } /vdev detach/ { split($6, s, "[:\\]]"); t=s[2]; done_txg = done_txg > t ? done_txg : t } END { print("Scrub completed at txg", scrub_txg); print("Spare detached at txg", detach_txg); exit(detach_txg > scrub_txg) }' [ $? -ne 0 ] && log_fail "The spare detached before the resilver completed" } -if ! $(is_physical_device $DISKS) ; then - log_unsupported "This directory cannot be run on raw files." -fi - log_assert "If a removed drive gets reinserted while the pool is exported, \ it will replace its spare when reinserted." -log_onexit autoreplace_cleanup - ensure_zfsd_running -set_devs typeset REMOVAL_DISK=$DISK0 -typeset SDEV=$DISK4 -typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" +typeset REMOVAL_NOP=${DISK0}.nop +typeset SPARE_DISK=$DISK4 +typeset SPARE_NOP=${DISK4}.nop +typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" +typeset OTHER_NOPS=${OTHER_DISKS//~(E)([[:space:]]+|$)/.nop\1} set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" +ensure_zfsd_running +log_must create_gnops $REMOVAL_DISK $OTHER_DISKS $SPARE_DISK for keyword in "${MY_KEYWORDS[@]}" ; do - log_must create_pool $TESTPOOL $keyword $POOLDEVS spare $SDEV - log_must poolexists "$TESTPOOL" - iterate_over_hotspares verify_assertion $SDEV - + log_must create_pool $TESTPOOL $keyword $REMOVAL_NOP $OTHER_NOPS spare $SPARE_NOP + verify_assertion destroy_pool "$TESTPOOL" done + +log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh (revision 329027) @@ -1,147 +1,121 @@ #!/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. # # Copyright 2012,2013 Spectra Logic Corporation. All rights reserved. # Use is subject to license terms. # # Portions taken from: # ident "@(#)replacement_001_pos.ksh 1.4 08/02/27 SMI" # # $FreeBSD$ . $STF_SUITE/include/libtest.kshlib -. $STF_SUITE/include/libsas.kshlib +. $STF_SUITE/include/libgnop.kshlib . $STF_SUITE/tests/hotspare/hotspare.kshlib . $STF_SUITE/tests/zfsd/zfsd.kshlib -verify_runnable "global" - function cleanup { - # See if the phy has been disabled, and try to re-enable it if possible. - [ -n "$EXPANDER0" -a -n "$PHY0" ] && enable_sas_disk $EXPANDER0 $PHY0 - [ -n "$EXPANDER1" -a -n "$PHY1" ] && enable_sas_disk $EXPANDER1 $PHY1 - [ -n "$EXPANDER" -a -n "$PHY" ] && enable_sas_disk $EXPANDER $PHY - destroy_pool $TESTPOOL [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* + for md in $MD0 $MD1 $MD2 $MD3; do + gnop destroy -f $md + for ((i=0; i<5; i=i+1)); do + $MDCONFIG -d -u $md && break + $SLEEP 1 + done + done } -# arg1: disk devname -# Leaves EXPANDER and PHY set appropriately -function remove_disk -{ - typeset DISK=$1 - # Find the first disk, get the expander and phy - log_note "Looking for expander and phy information for $DISK" - find_verify_sas_disk $DISK - - log_note "Disabling \"$DISK\" on expander $EXPANDER phy $PHY" - # Disable the first disk. - disable_sas_disk $EXPANDER $PHY - - # Check to make sure ZFS sees the disk as removed - wait_for_pool_dev_state_change 20 $DISK "REMOVED|UNAVAIL" -} - -# arg1: disk's old devname -# arg2: disk's expander's devname -# arg3: disk's phy number -# arg4: whether the devname must differ after reconnecting -function reconnect_disk -{ - typeset DISK=$1 - typeset EXPANDER=$2 - typeset PHY=$3 - - # Re-enable the disk, we don't want to leave it turned off - log_note "Re-enabling phy $PHY on expander $EXPANDER" - enable_sas_disk $EXPANDER $PHY - - log_note "Checking to see whether disk has reappeared" - - prev_disk=$(find_disks $DISK) - cur_disk=$(find_disks $FOUNDDISK) - - # If you get this, the test must be fixed to guarantee that - # it will reappear with a different name. - [ "${prev_disk}" = "${cur_disk}" ] && log_unsupported \ - "Disk $DISK reappeared with the same devname." - - #Disk should have auto-joined the zpool. Verify it's status is online. - wait_for_pool_dev_state_change 20 $FOUNDDISK ONLINE -} - log_assert "ZFSD will correctly replace disks that disappear and reappear \ with different devnames" # Outline +# Use gnop on top of file-backed md devices +# * file-backed md devices so we can destroy them and recreate them with +# different devnames +# * gnop so we can destroy them while still in use # Create a double-parity pool -# Remove two disks by disabling their SAS phys -# Reenable the phys in the opposite order -# Check that the disks's devnames have swapped +# Remove two vdevs +# Destroy the md devices and recreate in the opposite order +# Check that the md's devnames have swapped # Verify that the pool regains its health log_onexit cleanup ensure_zfsd_running -child_pids="" -set -A DISKS_ARRAY $DISKS -typeset DISK0=${DISKS_ARRAY[0]} -typeset DISK1=${DISKS_ARRAY[1]} -if [ ${DISK0##/dev/da} -gt ${DISK1##/dev/da} ]; then - # Swap disks so we'll disable the lowest numbered first - typeset TMP="$DISK1" - DISK1="$DISK0" - DISK0="$TMP" -fi +N_DEVARRAY_FILES=4 +set_devs +typeset FILE0="${devarray[0]}" +typeset FILE1="${devarray[1]}" +typeset FILE2="${devarray[2]}" +typeset FILE3="${devarray[3]}" +typeset MD0=`$MDCONFIG -a -t vnode -f ${FILE0}` +[ $? -eq 0 ] || atf_fail "Failed to create md device" +typeset MD1=`$MDCONFIG -a -t vnode -f ${FILE1}` +[ $? -eq 0 ] || atf_fail "Failed to create md device" +typeset MD2=`$MDCONFIG -a -t vnode -f ${FILE2}` +[ $? -eq 0 ] || atf_fail "Failed to create md device" +typeset MD3=`$MDCONFIG -a -t vnode -f ${FILE3}` +[ $? -eq 0 ] || atf_fail "Failed to create md device" +log_must create_gnops $MD0 $MD1 $MD2 $MD3 for type in "raidz2" "mirror"; do # Create a pool on the supplied disks - create_pool $TESTPOOL $type $DISKS + create_pool $TESTPOOL $type ${MD0}.nop ${MD1}.nop ${MD2}.nop ${MD3}.nop - remove_disk $DISK0 - typeset EXPANDER0=$EXPANDER - typeset PHY0=$PHY - remove_disk $DISK1 - typeset EXPANDER1=$EXPANDER - typeset PHY1=$PHY + log_must destroy_gnop $MD0 + for ((i=0; i<5; i=i+1)); do + $MDCONFIG -d -u $MD0 && break + $SLEEP 1 + done + [ -c /dev/$MD0.nop ] && atf_fail "failed to destroy $MD0" + log_must destroy_gnop $MD1 + for ((i=0; i<5; i=i+1)); do + $MDCONFIG -d -u $MD1 && break + $SLEEP 1 + done + [ -c /dev/$MD1.nop ] && atf_fail "failed to destroy $MD0" # Make sure that the pool is degraded $ZPOOL status $TESTPOOL |grep "state:" |grep DEGRADED > /dev/null if [ $? != 0 ]; then log_fail "Pool $TESTPOOL not listed as DEGRADED" fi - reconnect_disk $DISK1 $EXPANDER1 $PHY1 - reconnect_disk $DISK0 $EXPANDER0 $PHY0 + # Recreate the vdevs in the opposite order + typeset MD0=`$MDCONFIG -a -t vnode -f ${FILE1}` + [ $? -eq 0 ] || atf_fail "Failed to create md device" + typeset MD1=`$MDCONFIG -a -t vnode -f ${FILE0}` + [ $? -eq 0 ] || atf_fail "Failed to create md device" + log_must create_gnops $MD0 $MD1 + wait_until_resilvered destroy_pool $TESTPOOL - log_must $RM -rf /$TESTPOOL done log_pass Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh (revision 329026) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh (revision 329027) @@ -1,589 +1,589 @@ # 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,2013 Spectra Logic. All rights reserved. # Use is subject to license terms. # atf_test_case zfsd_fault_001_pos cleanup zfsd_fault_001_pos_head() { atf_set "descr" "ZFS will fault a vdev that produces IO errors" atf_set "require.progs" zfs zpool zfsd atf_set "timeout" 300 } zfsd_fault_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_fault_001_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_fault_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_degrade_001_pos cleanup zfsd_degrade_001_pos_head() { atf_set "descr" "ZFS will degrade a vdev that produces checksum errors" atf_set "require.progs" zpool zfsd atf_set "timeout" 600 } zfsd_degrade_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_degrade_001_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_degrade_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_degrade_002_pos cleanup zfsd_degrade_002_pos_head() { atf_set "descr" "ZFS will degrade a spare that produces checksum errors" atf_set "require.progs" zpool zfsd atf_set "timeout" 600 } zfsd_degrade_002_pos_body() { atf_expect_fail "https://www.illumos.org/issues/8614 Checksum errors on a mirrored child of a raidz are incorrectly accounted" . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_degrade_002_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_degrade_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_001_pos cleanup zfsd_hotspare_001_pos_head() { atf_set "descr" "An active, damaged spare will be replaced by an available spare" atf_set "require.progs" zpool zfsd atf_set "timeout" 3600 } zfsd_hotspare_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_001_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_002_pos cleanup zfsd_hotspare_002_pos_head() { atf_set "descr" "If a vdev becomes degraded, the spare will be activated." atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_002_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_003_pos cleanup zfsd_hotspare_003_pos_head() { atf_set "descr" "A faulted vdev will be replaced by an available spare" atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_003_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_003_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_003_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_004_pos cleanup zfsd_hotspare_004_pos_head() { atf_set "descr" "Removing a disk from a pool results in the spare activating" - atf_set "require.progs" zpool camcontrol zfsd + atf_set "require.progs" gnop zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_hotspare_004_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_004_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_004_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg - ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_005_pos cleanup zfsd_hotspare_005_pos_head() { atf_set "descr" "A spare that is added to a degraded pool will be activated" atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_005_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_005_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_005_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_006_pos cleanup zfsd_hotspare_006_pos_head() { atf_set "descr" "zfsd will replace two vdevs that fail simultaneously" atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_006_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_006_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_006_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_007_pos cleanup zfsd_hotspare_007_pos_head() { atf_set "descr" "zfsd will swap failed drives at startup" - atf_set "require.progs" zpool camcontrol zfsd + atf_set "require.progs" gnop zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_hotspare_007_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_007_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_007_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg - ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_hotspare_008_neg cleanup zfsd_hotspare_008_neg_head() { atf_set "descr" "zfsd will not use newly added spares on replacing vdevs" atf_set "require.progs" zpool zfsd atf_set "timeout" 3600 } zfsd_hotspare_008_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_hotspare_008_neg.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_008_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_autoreplace_001_neg cleanup zfsd_autoreplace_001_neg_head() { atf_set "descr" "A pool without autoreplace set will not replace by physical path" atf_set "require.progs" zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_autoreplace_001_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_autoreplace_001_neg.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_autoreplace_001_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg - ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_autoreplace_002_pos cleanup zfsd_autoreplace_002_pos_head() { atf_set "descr" "A pool with autoreplace set will replace by physical path" - atf_set "require.progs" zpool camcontrol zfsd + atf_set "require.progs" gnop zpool zfsd atf_set "timeout" 3600 } zfsd_autoreplace_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_autoreplace_002_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_autoreplace_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg - ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_autoreplace_003_pos cleanup zfsd_autoreplace_003_pos_head() { atf_set "descr" "A pool with autoreplace set will replace by physical path even if a spare is active" atf_set "require.progs" zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_autoreplace_003_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_autoreplace_003_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_autoreplace_003_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg - ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed" + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_replace_001_pos cleanup zfsd_replace_001_pos_head() { atf_set "descr" "ZFSD will automatically replace a SAS disk that dissapears and reappears in the same location, with the same devname" atf_set "require.progs" zpool camcontrol zfsd zfs } zfsd_replace_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_replace_001_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_replace_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_replace_002_pos cleanup zfsd_replace_002_pos_head() { atf_set "descr" "A pool can come back online after all disks have dissapeared and reappeared" atf_set "require.progs" zpool camcontrol zfsd zfs } zfsd_replace_002_pos_body() { atf_expect_fail "ZFS hangs when an array becomes critical" . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_replace_002_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_replace_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_replace_003_pos cleanup zfsd_replace_003_pos_head() { atf_set "descr" "ZFSD will correctly replace disks that dissapear and reappear with different devnames" atf_set "require.progs" zpool camcontrol zfsd zfs } zfsd_replace_003_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg - . $(atf_get_srcdir)/zfsd.cfg + . $(atf_get_srcdir)/../hotspare/hotspare.kshlib + . $(atf_get_srcdir)/../hotspare/hotspare.cfg - verify_disk_count "$DISKS" 3 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_replace_003_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_replace_003_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zfsd_import_001_pos cleanup zfsd_import_001_pos_head() { atf_set "descr" "If a removed drive gets reinserted while the pool is exported, it will detach its spare when imported." - atf_set "require.progs" zfsd zpool + atf_set "require.progs" gnop zfsd zpool atf_set "timeout" 3600 } zfsd_import_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zfsd_import_001_pos.ksh || atf_fail "Testcase failed" if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_import_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_init_test_cases() { atf_add_test_case zfsd_fault_001_pos atf_add_test_case zfsd_degrade_001_pos atf_add_test_case zfsd_degrade_002_pos atf_add_test_case zfsd_hotspare_001_pos atf_add_test_case zfsd_hotspare_002_pos atf_add_test_case zfsd_hotspare_003_pos atf_add_test_case zfsd_hotspare_004_pos atf_add_test_case zfsd_hotspare_005_pos atf_add_test_case zfsd_hotspare_006_pos atf_add_test_case zfsd_hotspare_007_pos atf_add_test_case zfsd_hotspare_008_neg atf_add_test_case zfsd_autoreplace_001_neg atf_add_test_case zfsd_autoreplace_002_pos atf_add_test_case zfsd_autoreplace_003_pos atf_add_test_case zfsd_replace_001_pos atf_add_test_case zfsd_replace_002_pos atf_add_test_case zfsd_replace_003_pos atf_add_test_case zfsd_import_001_pos } save_artifacts() { # If ARTIFACTS_DIR is defined, save test artifacts for # post-mortem analysis if [[ -n $ARTIFACTS_DIR ]]; then TC_ARTIFACTS_DIR=${ARTIFACTS_DIR}/sys/cddl/zfs/tests/zfsd/$(atf_get ident) mkdir -p $TC_ARTIFACTS_DIR cp -a /var/log/zfsd.log* $TC_ARTIFACTS_DIR bzip2 $TC_ARTIFACTS_DIR/zfsd.log fi }