svn commit: r292374 - in projects/zfsd/head/tests/sys/cddl/zfs: include tests/hotspare tests/zfsd

Alan Somers asomers at FreeBSD.org
Wed Dec 16 21:32:23 UTC 2015


Author: asomers
Date: Wed Dec 16 21:32:21 2015
New Revision: 292374
URL: https://svnweb.freebsd.org/changeset/base/292374

Log:
  Fix ZFS test suite bugs introduced by change 292346
  
  These bugs were all ksh93 syntax bugs.  Oddly, ksh93 will exit 0 when it
  encounters a syntax error, so these bugs weren't noticed at the time.  Kyua
  thought that the tests were passing.  Also, Improve a few tests while I'm at
  it.
  
  tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh
  	Fix ksh93 syntax errors and typos.  Also, fix some comments.
  
  tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib
  tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh
  tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh
  	Turn wait_for_disk_to_reappear's global variables into arguments
  
  tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh
  	Improve a debugging statement and a comment
  
  tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh
  	* wait_for_pool_removal only works for tests that disable a single
  	  disk.  Replace its use by wait_for_pool_dev_state_change
  
  	* Fix a ksh93 scoping issue.  reconnect_disk declares EXPANDER and
  	  PHY as local variables, shadowing globals of the same name, but
  	  then uses them as if they were still global.
  
  	* Get rid of the DEVNAME_MUST_DIFFER check.  It never worked because
  	  the variable was referenced by two different names.  And it's not
  	  necessary because we always want to perform the check.
  
  	* Fix some variable definitions that don't match their references:
  	  s/_disks/_disk/
  
  	* In reconnect_disk, call wait_for_pool_dev_state_change with the
  	  correct devname.
  
  	* If the test should start with the DISKS array not in ascending
  	  order, detect this and disable the disks in the correct order to
  	  produce the desired behavior.
  
  tests/sys/cddl/zfs/tests/hotspare/hotspare.kshlib
  	When failing a test in wait_for_resilver, show the final zpool
  	status to assist debugging efforts.
  
  tests/sys/cddl/zfs/include/libsas.kshlib
  	Style.
  
  tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib
  	Remark zfsd_hotspare_007_pos and zfsd_degrade_002_pos as failing.
  	They were previously unmarked after change 292346 made them appear
  	to pass, but, but that was erroneous.  They were still failing, but
  	were exiting 0 due to syntax errors so Kyua thought that they were
  	passing.
  
  tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
  	Increase the amount of io in corrupt_pool_vdev to ensure that there
  	are enough checksum errors for the device to become degraded.  The
  	I/O was unintentionally decreased by change 292346.
  
  Sponsored by:	Spectra Logic Corp

Modified:
  projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib
  projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare.kshlib
  projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib
  projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh
  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_007_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh

Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/libsas.kshlib	Wed Dec 16 21:32:21 2015	(r292374)
@@ -131,7 +131,7 @@ function find_disk_by_phy
 		IFS=", \n"
 		set -A PERIPHLIST $j
 		unset IFS
-		[ "${PERIPHLIST[0]}" != "$2" ] && continue
+		[ "${PERIPHLIST[0]}" != "$PHY" ] && continue
 
 		typeset NUMPERIPHS=${#PERIPHLIST[*]}
 

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare.kshlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare.kshlib	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare.kshlib	Wed Dec 16 21:32:21 2015	(r292374)
@@ -117,6 +117,7 @@ while [[ $i -lt $timeout ]]; do
 	fi
 	(( i += 1 ))
 	if [[ $i == $timeout ]]; then
+		$ZPOOL status $TESTPOOL
 		log_fail "Pool didn't resilver in ${timeout} seconds"
 	fi
 	$SLEEP 1

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib	Wed Dec 16 21:32:21 2015	(r292374)
@@ -30,14 +30,15 @@
 function wait_for_disk_to_reappear
 {
 	typeset -i timeout=$1
-	typeset EXPECTED_DISK=$2
+	typeset EXPANDER=$2
+	typeset PHY=$3
 
 	for ((; $timeout > 0; timeout=$timeout-1)); do
 		find_disk_by_phy $EXPANDER $PHY
 		[ -n "$FOUNDDISK" -a -e "/dev/$FOUNDDISK" ] && return
 		$SLEEP 1
 	done
-	log_fail "ERROR: Disk ${EXPECTED_DISK} never reappeared"
+	log_fail "ERROR: Disk at ${EXPANDER}:${PHY} never reappeared"
 }
 
 function wait_for_pool_dev_state_change
@@ -79,7 +80,7 @@ function corrupt_pool_vdev
 	typeset file=$3
 
 	# do some IO on the pool
-	log_must $DD if=/dev/zero of=$file bs=1024k count=16
+	log_must $DD if=/dev/zero of=$file bs=1024k count=128
 	# scribble on the underlying file to corrupt the vdev
 	log_must $DD if=/dev/urandom of=$vdev bs=1024k count=64 conv=notrunc
 
@@ -135,7 +136,7 @@ function do_autoreplace
 	log_note "Reenabling phy on expander $EXPANDER phy $PHY"
 	enable_sas_disk $EXPANDER $PHY
 	rescan_disks $EXPANDER
-	wait_for_disk_to_reappear 30 $REMOVAL_DISK
+	wait_for_disk_to_reappear 30 $EXPANDER $PHY
 
 	# Erase the missing dev's ZFS label
 	log_must $ZPOOL labelclear -f $( find_disks $FOUNDDISK )
@@ -158,7 +159,7 @@ function do_autoreplace
 	log_note "Reenabling phy on expander $EXPANDER phy $PHY"
 	enable_sas_disk $EXPANDER $PHY
 	rescan_disks $EXPANDER
-	wait_for_disk_to_reappear 30 $REMOVAL_DISK
+	wait_for_disk_to_reappear 30 $EXPANDER $PHY
 }
 
 function autoreplace_cleanup

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_001_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -28,6 +28,7 @@
 # $FreeBSD$
 
 . $STF_SUITE/include/libtest.kshlib
+. $STF_SUITE/tests/zfsd/zfsd.kshlib
 
 ################################################################################
 #
@@ -81,7 +82,7 @@ for type in "raidz" "mirror"; do
 	log_note "Testing raid type $type"
 
 	create_pool $TESTPOOL $type ${VDEVS}
-	corrupt_pool $TESTPOOL $VDEV1 $TESTFILE
+	corrupt_pool_vdev $TESTPOOL $VDEV1 $TESTFILE
 	destroy_pool $TESTPOOL
 done
 

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_degrade_002_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -28,12 +28,13 @@
 # $FreeBSD$
 
 . $STF_SUITE/include/libtest.kshlib
+. $STF_SUITE/tests/zfsd/zfsd.kshlib
 
 ################################################################################
 #
 # __stc_assertion_start
 #
-# ID: zfsd_degrade_001_pos
+# ID: zfsd_degrade_002_pos
 #
 # DESCRIPTION: 
 #   If an active hotspare experiences checksum errors, it will become degraded.
@@ -74,7 +75,7 @@ function cleanup
 	$RM -f $VDEVS
 }
 
-log_assert "ZFS will degrade a vdev that produces checksum errors"
+log_assert "ZFS will degrade a spare vdev that produces checksum errors"
 
 log_onexit cleanup
 
@@ -93,7 +94,7 @@ for type in "mirror" "raidz"; do
 	# (though it's usually faster).  
 	wait_for_pool_dev_state_change 60 $SPARE_VDEV INUSE
 
-	corrupt_pool $TESTPOOL $SPARE_VDEV $TESTFILE
+	corrupt_pool_vdev $TESTPOOL $SPARE_VDEV $TESTFILE
 	destroy_pool $TESTPOOL
 done
 

Modified: 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	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -89,14 +89,14 @@ function verify_assertion # spare_dev
 	# Reenable the  missing disk
 	log_note "Reenabling phy on expander $EXPANDER phy $PHY"
 	enable_sas_disk $EXPANDER $PHY
-	wait_for_disk_to_reappear 20
+	wait_for_disk_to_reappear 20 $EXPANDER $PHY
 
 	# Check that the disk has rejoined the pool & resilvered
 	wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE
 	wait_until_resilvered
 
 	# Finally, check that the spare deactivated
-	wait_for_pool_state_change $spare_dev AVAIL
+	wait_for_pool_dev_state_change 20 $spare_dev AVAIL
 }
 
 

Modified: 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	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -87,12 +87,12 @@ function verify_assertion # spare_dev
 	restart_zfsd
 
 	# Check that the spare was activated
-	wait_for_pool_dev_state_change $spare_dev INUSE
+	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
-	wait_for_disk_to_reappear 20
+	wait_for_disk_to_reappear 20 $EXPANDER $PHY
 }
 
 typeset REMOVAL_DISK=$DISK0

Modified: 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	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_import_001_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -38,7 +38,7 @@
 #
 # DESCRIPTION: 
 #   If a removed drive gets reinserted while the pool is exported, it will
-#   replace its spare when reinserted.
+#   replace its spare when reimported.
 #
 #   This also applies to drives that get reinserted while the machine is
 #   powered off.
@@ -92,7 +92,7 @@ function verify_assertion # spare_dev
 	enable_sas_disk $EXPANDER $PHY
 
 	# Check that the disk has returned
-	wait_for_disk_to_reappear 20
+	wait_for_disk_to_reappear 20 $EXPANDER $PHY
 
 	# Import the pool
 	log_must $ZPOOL import $TESTPOOL
@@ -104,7 +104,7 @@ function verify_assertion # spare_dev
 	while ! is_pool_resilvered $TESTPOOL; do
 		$SLEEP 2
 	done
-	log_must $ZPOOL status
+	log_must $ZPOOL status $TESTPOOL
 
 	#Finally, check that the spare deactivated
 	wait_for_pool_dev_state_change 20 $spare_dev AVAIL

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_001_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -79,7 +79,7 @@ for type in "raidz" "mirror"; do
 	# 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
-	wait_for_disk_to_reappear 20
+	wait_for_disk_to_reappear 20 $EXPANDER $PHY
 
 	# Disk should auto-join the zpool & be resilvered.
 	wait_for_pool_dev_state_change 20 $REMOVAL_DISK ONLINE

Modified: 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	Wed Dec 16 21:30:45 2015	(r292373)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_replace_003_pos.ksh	Wed Dec 16 21:32:21 2015	(r292374)
@@ -35,6 +35,7 @@
 
 . $STF_SUITE/include/libtest.kshlib
 . $STF_SUITE/include/libsas.kshlib
+. $STF_SUITE/tests/hotspare/hotspare.kshlib
 . $STF_SUITE/tests/zfsd/zfsd.kshlib
 
 verify_runnable "global"
@@ -68,7 +69,7 @@ function remove_disk
 	[ -n "$FOUNDDISK" ] && log_fail "Disk \"$DISK\" was not removed"
 
 	# Check to make sure ZFS sees the disk as removed
-	wait_for_pool_removal 20
+	wait_for_pool_dev_state_change 20 $DISK REMOVED
 }
 
 # arg1: disk's old devname
@@ -80,7 +81,6 @@ function reconnect_disk
 	typeset DISK=$1
 	typeset EXPANDER=$2
 	typeset PHY=$3
-	typeset DEVNAME_DIFFERS=$4
 
 	# Re-enable the disk, we don't want to leave it turned off
 	log_note "Re-enabling phy $PHY on expander $EXPANDER"
@@ -88,20 +88,18 @@ function reconnect_disk
 
 	log_note "Checking to see whether disk has reappeared"
 	# Make sure the disk is back in the topology
-	wait_for_disk_to_reappear 20
+	wait_for_disk_to_reappear 20 $EXPANDER $PHY
 
-	if [ -n "$DEVNAME_MUST_DIFFER" ]; then
-		prev_disks=$(find_disks $FOUNDDISK)
-		cur_disks=$(find_disks $DISK)
-
-		# 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."
-	fi
+	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 $DISK ONLINE
+	wait_for_pool_dev_state_change 20 $FOUNDDISK ONLINE
 }
 
 log_assert "ZFSD will correctly replace disks that disappear and reappear \
@@ -122,6 +120,12 @@ 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
 
 for type in "raidz2" "mirror"; do
 	# Create a pool on the supplied disks


More information about the svn-src-projects mailing list