Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/history/history_004_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/history/history_004_pos.ksh (revision 292369) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/history/history_004_pos.ksh (revision 292370) @@ -1,112 +1,112 @@ #!/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 "@(#)history_004_pos.ksh 1.2 07/01/09 SMI" # . $STF_SUITE/tests/history/history_common.kshlib ################################################################################# # # __stc_assertion_start # # ID: history_004_pos # # DESCRIPTION: # 'zpool history' can copes with many simultaneous command. # # STRATEGY: # 1. Create test pool and test fs. # 2. Loop 100 times, set properties to test fs simultaneously. # 3. Wait for all the command execution complete. # 4. Make sure all the commands was logged by 'zpool history'. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2006-07-05) # # __stc_assertion_end # ################################################################################ verify_runnable "global" log_assert "'zpool history' can copes with many simultaneous command." -typeset -i orig_count=$($ZPOOL history $spool | $WC -l | $AWK '{print $1}') +typeset -i orig_count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}') typeset -i i=0 while ((i < 10)); do $ZFS set compression=off $TESTPOOL/$TESTFS & $ZFS set atime=off $TESTPOOL/$TESTFS & $ZFS create $TESTPOOL/$TESTFS1 & $ZFS create $TESTPOOL/$TESTFS2 & $ZFS create $TESTPOOL/$TESTFS3 & wait $ZFS snapshot $TESTPOOL/$TESTFS1@snap & $ZFS snapshot $TESTPOOL/$TESTFS2@snap & $ZFS snapshot $TESTPOOL/$TESTFS3@snap & wait $ZFS clone $TESTPOOL/$TESTFS1@snap $TESTPOOL/clone1 & $ZFS clone $TESTPOOL/$TESTFS2@snap $TESTPOOL/clone2 & $ZFS clone $TESTPOOL/$TESTFS3@snap $TESTPOOL/clone3 & wait $ZFS promote $TESTPOOL/clone1 & $ZFS promote $TESTPOOL/clone2 & $ZFS promote $TESTPOOL/clone3 & wait $ZFS destroy $TESTPOOL/$TESTFS1 & $ZFS destroy $TESTPOOL/$TESTFS2 & $ZFS destroy $TESTPOOL/$TESTFS3 & wait $ZFS destroy -Rf $TESTPOOL/clone1 & $ZFS destroy -Rf $TESTPOOL/clone2 & $ZFS destroy -Rf $TESTPOOL/clone3 & wait ((i += 1)) done -typeset -i entry_count=$($ZPOOL history $spool | $WC -l | $AWK '{print $1}') +typeset -i count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}') -if ((entry_count - orig_count != 200)); then - log_fail "The entries count error: entry_count=$entry_count " \ - "orig_count = $orig_count" +if ((count - orig_count != 200)); then + $ZPOOL history $spool + log_fail "Expected 200 more than $orig_count entries, but got $count" fi log_pass "zpool history copes with simultaneous commands passed." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_onoffline_004_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_onoffline_004_neg.ksh (revision 292369) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_onoffline_004_neg.ksh (revision 292370) @@ -1,166 +1,162 @@ #!/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 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)hotspare_onoffline_004_neg.ksh 1.5 09/06/22 SMI" # . $STF_SUITE/tests/hotspare/hotspare.kshlib ################################################################################ # # __stc_assertion_start # # ID: hotspare_onoffline_004_neg # # DESCRIPTION: # If a hot spare has been activated, # turning that basic vdev offline and back online during I/O completes. # Make sure the integrity of the file system and the resilvering. # # STRATEGY: # 1. Create a storage pool with hot spares # 2. Activate the hot spare # 3. Start some random I/O # 4. Try 'zpool offline' & 'zpool online' with the basic vdev # 5. Verify the integrity of the file system and the resilvering. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING STATUS: COMPLETED (2006-06-07) # # __stc_assertion_end # ############################################################################### verify_runnable "global" function cleanup { kill_all_wp poolexists $TESTPOOL && \ destroy_pool $TESTPOOL [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup } function kill_all_wp { for wait_pid in $child_pids do $KILL $wait_pid $WAIT $wait_pid done } function start_all_wp { typeset -i i=0 typeset -i iters=1 child_pids="" while (( i < iters )); do log_note "Invoking $FILE_TRUNC with: $options_display" $FILE_TRUNC $options $TESTDIR/$TESTFILE.$i & typeset pid=$! - $SLEEP 1 - if ! $PS -p $pid > /dev/null 2>&1; then - log_fail "$FILE_TRUNC $options $TESTDIR/$TESTFILE.$i" - fi - child_pids="$child_pids $pid" ((i = i + 1)) done } function verify_assertion # dev { typeset dev=$1 typeset -i i=0 typeset -i iters=1 typeset odev=${pooldevs[0]} log_must $ZPOOL replace $TESTPOOL $odev $dev i=0 while (( i < iters )); do start_all_wp while ! is_pool_resilvered "$TESTPOOL"; do $SLEEP 2 done kill_all_wp + log_must test -f $TESTDIR/$TESTFILE.$i log_must $ZPOOL offline $TESTPOOL $odev log_must check_state $TESTPOOL $odev "offline" log_must $ZPOOL online $TESTPOOL $odev log_must check_state $TESTPOOL $odev "online" (( i = i + 1 )) done log_must $ZPOOL detach $TESTPOOL $dev } log_assert "'zpool offline/online ' against a spared basic vdev during I/O completes." log_onexit cleanup set_devs options="" options_display="default options" [[ -n "$HOLES_FILESIZE" ]] && options=" $options -f $HOLES_FILESIZE " [[ -n "$HOLES_BLKSIZE" ]] && options="$options -b $HOLES_BLKSIZE " [[ -n "$HOLES_COUNT" ]] && options="$options -c $HOLES_COUNT " [[ -n "$HOLES_SEED" ]] && options="$options -s $HOLES_SEED " [[ -n "$HOLES_FILEOFFSET" ]] && options="$options -o $HOLES_FILEOFFSET " options="$options -r" [[ -n "$options" ]] && options_display=$options typeset child_pid="" for keyword in "${keywords[@]}" ; do setup_hotspares "$keyword" log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL iterate_over_hotspares verify_assertion verify_filesys "$TESTPOOL" "$TESTPOOL" "$HOTSPARE_TMPDIR" destroy_pool "$TESTPOOL" done log_pass "'zpool offline/online ' against a spared basic vdev during I/O completes." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib (revision 292369) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd.kshlib (revision 292370) @@ -1,184 +1,184 @@ #!/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. # # Common routines used by multiple zfsd tests function wait_for_disk_to_reappear { typeset -i timeout=$1 typeset EXPECTED_DISK=$2 for ((; $timeout > 0; timeout=$timeout-1)); do find_disk_by_phy $EXPANDER $PHY - [ -n "$FOUNDDISK" ] && return - $SLEEP 3 + [ -n "$FOUNDDISK" -a -e "/dev/$FOUNDDISK" ] && return + $SLEEP 1 done log_fail "ERROR: Disk ${EXPECTED_DISK} never reappeared" } function wait_for_pool_dev_state_change { typeset -i timeout=$1 typeset disk=$2 typeset state=$3 log_note "Waiting up to $timeout seconds for $disk to become $state ..." for ((; $timeout > 0; timeout=$timeout-1)); do check_state $TESTPOOL "$disk" "$state" [ $? -eq 0 ] && return $SLEEP 1 done log_must $ZPOOL status $TESTPOOL log_fail "ERROR: Disk $disk not marked as $state in $TESTPOOL" } function wait_for_pool_removal { typeset -i timeout=$1 wait_for_pool_dev_state_change $timeout $REMOVAL_DISK REMOVED } function wait_until_scrubbed { typeset pool=$1 while is_pool_scrubbing $pool; do log_note "$pool still scrubbing..." $SLEEP 1 done } function corrupt_pool_vdev { typeset pool=$1 typeset vdev=$2 typeset file=$3 # do some IO on the pool log_must $DD if=/dev/zero of=$file bs=1024k count=16 # scribble on the underlying file to corrupt the vdev log_must $DD if=/dev/urandom of=$vdev bs=1024k count=64 conv=notrunc # Scrub the pool to detect the corruption $SYNC log_must $ZPOOL scrub $pool wait_until_scrubbed $pool # ZFSD can take up to 60 seconds to degrade an array in response to # errors (though it's usually faster). wait_for_pool_dev_state_change 60 $vdev DEGRADED } # # do_autoreplace # Common code that walks through an autoreplace scenario # Does not verify the final behavior # # $1 spare disk name. Empty if no spare # function do_autoreplace { typeset SPARE_DISK=$1 # Remove a vdev by disabling its SAS phy find_verify_sas_disk $REMOVAL_DISK log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" disable_sas_disk $EXPANDER $PHY # Check to make sure the disk is gone log_mustnot camcontrol inquiry $REMOVAL_DISK # Check to make sure ZFS sees the disk as removed wait_for_pool_removal 30 if [ -n "$SPARE_DISK" ]; then # Verify that the spare activates for ((timeout=0; $timeout<10; timeout=$timeout+1)); do check_state $TESTPOOL $SPARE_DISK "ONLINE" && break $SLEEP 6 done log_must check_state $TESTPOOL "$SPARE_DISK" "ONLINE" wait_until_resilvered fi # Export the pool # This is to prevent REMOVAL_DISK from being added to the pool when # we reenable its phy log_must $ZPOOL export $TESTPOOL # Reenable the missing dev's SAS phy 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 # Erase the missing dev's ZFS label log_must $ZPOOL labelclear -f $( find_disks $FOUNDDISK ) # Disable the missing dev's SAS phy again find_verify_sas_disk $FOUNDDISK log_note "Disabling \"$FOUNDDISK\" on expander $EXPANDER phy $PHY" disable_sas_disk $EXPANDER $PHY # Check to make sure the disk is gone log_mustnot camcontrol inquiry $REMOVAL_DISK # Import the pool log_must $ZPOOL import $TESTPOOL # Wait 5 seconds before enabling the phy so zfsd.log will be easier # to interpret $SLEEP 5 # Reenable the missing dev's SAS phy 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 } function autoreplace_cleanup { destroy_pool $TESTPOOL # See if the phy has been disabled, and try to re-enable it if possible. if [ -n "$REMOVAL_DISK" -a -n "$EXPANDER" -a -n "$PHY" ]; then log_note "Renabling ${EXPANDER}:${PHY} for disk ${REMOVAL_DISK}" enable_sas_disk $EXPANDER $PHY rescan_disks $EXPANDER # For debugging purposes, log the partial output of # camcontrol to see if the disk actually came back. out=$(camcontrol smpphylist ${EXPANDER} | ${GREP} "^ *${PHY}") log_note "Expander has: ${out}" fi [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* partition_cleanup restart_zfsd }