Index: projects/zfsd/head/tests/sys/cddl/zfs/include/stf.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/stf.kshlib (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/stf.kshlib (nonexistent) @@ -1,39 +0,0 @@ -# -# 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 "@(#)stf.kshlib 1.4 07/04/12 SMI" -# - -# -# This file is for korn shell functionality only. -# Any functionality that is compatible with bourne shell -# should be put in stf.shlib so it can be used by sh scripts as well. -# - -. ${STF_SUITE}/include/stf.shlib - -# do this to use the array: ${STF_RESULT_NAMES[$result]} -set -A STF_RESULT_NAMES "PASS" "FAIL" "UNRESOLVED" "NOTINUSE" "UNSUPPORTED" \ - "UNTESTED" "UNINITIATED" "NORESULT" "WARNING" "TIMED_OUT" "OTHER" Index: projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile (revision 273990) @@ -1,26 +1,25 @@ # $FreeBSD$ .include STFSUITEDIR=${TESTSBASE}/sys/cddl/zfs MAN= FILESDIR= ${TESTSBASE}/sys/cddl/zfs/include FILES+= libremote.kshlib FILES+= libsas.kshlib FILES+= logapi.kshlib FILES+= libtest.kshlib FILES+= stf.shlib -FILES+= stf.kshlib FILES+= commands.cfg commands.cfg: translatecommands.awk commands.txt awk -v stfsuitedir=${STFSUITEDIR} -f ${.ALLSRC} > ${.TARGET} CLEANFILES+= commands.cfg FILES+= default.cfg default.cfg: default.cfg.in sed "s:%%STFSUITEDIR%%:${STFSUITEDIR}:" ${.ALLSRC} > ${.TARGET} CLEANFILES+= default.cfg .include Index: projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib (revision 273990) @@ -1,389 +1,367 @@ # # 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 "@(#)logapi.kshlib 1.2 07/03/14 SMI" # # # This is a ksh function library. It is intended to be sourced into # other ksh scripts and not executed directly. # -. ${STF_SUITE}/include/stf.kshlib +. ${STF_SUITE}/include/stf.shlib # Output an assertion # # $@ - assertion text function log_assert { _printline ASSERTION: "$@" } # Output a comment # # $@ - comment text function log_note { _printline NOTE: "$@" } -# Execute and print command with status where success equals non-zero result -# -# $@ - command to execute -# -# return 0 if command fails, otherwise return 1 - -function log_neg -{ - log_neg_expect "" "$@" - return $? -} - # Execute a positive test and exit $STF_FAIL is test fails # # $@ - command to execute function log_must { log_pos "$@" (( $? != 0 )) && log_fail } # Execute a negative test and exit $STF_FAIL if test passes # # $@ - command to execute function log_mustnot { log_neg "$@" (( $? != 0 )) && log_fail } -# Execute a negative test with keyword expected, and exit -# $STF_FAIL if test passes -# -# $1 - keyword expected -# $2-$@ - command to execute - -function log_mustnot_expect -{ - log_neg_expect "$@" - (( $? != 0 )) && log_fail -} - # Execute and print command with status where success equals non-zero result # or output includes expected keyword # -# $1 - keyword expected # $2-$@ - command to execute # +# Summary: execute $@. Return 1 if any of the following hold: +# 1) The command exited 0, 127, 138, or 139 +# 2) The command's stderr included "internal error" or +# "assertion failed" +# # return 0 if command fails, or the output contains the keyword expected, # return 1 otherwise -function log_neg_expect +function log_neg { typeset out="" typeset logfile="$TMPDIR/log.$$" typeset ret=1 - typeset expect=$1 - shift while [[ -e $logfile ]]; do logfile="$logfile.$$" done "$@" 2>$logfile typeset status=$? out="/bin/cat $logfile" # unexpected status if (( $status == 0 )); then print -u2 $($out) _printerror "$@" "unexpectedly exited $status" # missing binary elif (( $status == 127 )); then print -u2 $($out) _printerror "$@" "unexpectedly exited $status (File not found)" # bus error - core dump elif (( $status == 138 )); then print -u2 $($out) _printerror "$@" "unexpectedly exited $status (Bus Error)" # segmentation violation - core dump elif (( $status == 139 )); then print -u2 $($out) _printerror "$@" "unexpectedly exited $status (SEGV)" else $out | /usr/bin/egrep -i "internal error|assertion failed" \ > /dev/null 2>&1 # internal error or assertion failed if (( $? == 0 )); then print -u2 $($out) _printerror "$@" "internal error or assertion failure" \ " exited $status" - elif [[ -n $expect ]] ; then - $out | /usr/bin/grep -i "$expect" > /dev/null 2>&1 - if (( $? == 0 )); then - ret=0 - else - print -u2 $($out) - _printerror "$@" "unexpectedly exited $status" - fi else ret=0 fi if (( $ret == 0 )); then [[ -n $LOGAPI_DEBUG ]] && print $($out) _printsuccess "$@" "exited $status" fi fi _recursive_output $logfile "false" return $ret } # Execute and print command with status where success equals zero result # # $@ command to execute # +# Summary: run $@. return 1 if its exit status was nonzero or if it printed +# "internal error" or "assertion failed" to stderr. +# print stderr on failure or if LOGAPI_DEBUG is set. +# # return command exit status function log_pos { typeset out="" typeset logfile="$TMPDIR/log.$$" while [[ -e $logfile ]]; do logfile="$logfile.$$" done "$@" 2>$logfile typeset status=$? out="/bin/cat $logfile" if (( $status != 0 )) ; then print -u2 $($out) _printerror "$@" "exited $status" else $out | /usr/bin/egrep -i "internal error|assertion failed" \ > /dev/null 2>&1 # internal error or assertion failed if [[ $? -eq 0 ]]; then print -u2 $($out) _printerror "$@" "internal error or assertion failure" \ " exited $status" status=1 else [[ -n $LOGAPI_DEBUG ]] && print $($out) _printsuccess "$@" fi fi _recursive_output $logfile "false" return $status } # Set an exit handler # # $@ - function(s) to perform on exit function log_onexit { _CLEANUP="$@" } # # Exit functions # # Perform cleanup and exit $STF_PASS # # $@ - message text function log_pass { _endlog $STF_PASS "$@" } # Perform cleanup and exit $STF_FAIL # # $@ - message text function log_fail { _endlog $STF_FAIL "$@" } # Perform cleanup and exit $STF_UNRESOLVED # # $@ - message text function log_unresolved { _endlog $STF_UNRESOLVED "$@" } # Perform cleanup and exit $STF_NOTINUSE # # $@ - message text function log_notinuse { _endlog $STF_NOTINUSE "$@" } # Perform cleanup and exit $STF_UNSUPPORTED # # $@ - message text function log_unsupported { _endlog $STF_UNSUPPORTED "$@" } # Perform cleanup and exit $STF_UNTESTED # # $@ - message text function log_untested { _endlog $STF_UNTESTED "$@" } # Perform cleanup and exit $STF_UNINITIATED # # $@ - message text function log_uninitiated { _endlog $STF_UNINITIATED "$@" } # Perform cleanup and exit $STF_NORESULT # # $@ - message text function log_noresult { _endlog $STF_NORESULT "$@" } # Perform cleanup and exit $STF_WARNING # # $@ - message text function log_warning { _endlog $STF_WARNING "$@" } # Perform cleanup and exit $STF_TIMED_OUT # # $@ - message text function log_timed_out { _endlog $STF_TIMED_OUT "$@" } # Perform cleanup and exit $STF_OTHER # # $@ - message text function log_other { _endlog $STF_OTHER "$@" } # # Internal functions # # Perform cleanup and exit # +# Summary: Runs any cleanup routine registered with log_onexit. Prints a +# message and exits $1. Note: the _recursive_output does +# nothing, because the rest of this api guarantees that the +# logfile will not exist. # $1 - stf exit code # $2-$n - message text function _endlog { typeset logfile="$TMPDIR/log.$$" _recursive_output $logfile export STF_EXITCODE=$1 if [[ -n $_CLEANUP ]] ; then typeset cleanup=$_CLEANUP log_onexit "" log_note "Performing local cleanup via log_onexit ($cleanup)" $cleanup fi shift (( ${#@} > 0 )) && _printline "$@" exit $STF_EXITCODE } # Output a formatted line # # $@ - message text function _printline { print `/bin/date +%H:%M:%S` "$@" } # Output an error message # # $@ - message text function _printerror { _printline ERROR: "$@" } # Output a success message # # $@ - message text function _printsuccess { _printline SUCCESS: "$@" } # Output logfiles recursively # # $1 - start file # $2 - indicate whether output the start file itself, default as yes. function _recursive_output #logfile { typeset logfile=$1 while [[ -e $logfile ]]; do if [[ -z $2 || $logfile != $1 ]]; then /bin/cat $logfile fi /bin/rm -f $logfile logfile="$logfile.$$" done } Index: projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib (revision 273990) @@ -1,60 +1,52 @@ # # 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 "@(#)stf.shlib 1.2 07/04/12 SMI" # -# -# This file is for bourne shell functionality only. -# Any ksh functionality must go into stf.kshlib. -# stf.kshlib includes this file, so any code here must -# work for ksh also or the sharable code must be moved -# to a different (new) common file -# - STF_PASS=0 STF_FAIL=1 STF_UNRESOLVED=2 STF_NOTINUSE=3 STF_UNSUPPORTED=4 STF_UNTESTED=5 STF_UNINITIATED=6 STF_NORESULT=7 STF_WARNING=8 STF_TIMED_OUT=9 STF_OTHER=10 # do this to use the names: eval echo \$STF_RESULT_NAME_${result} STF_RESULT_NAME_0="PASS" STF_RESULT_NAME_1="FAIL" STF_RESULT_NAME_2="UNRESOLVED" STF_RESULT_NAME_3="NOTINUSE" STF_RESULT_NAME_4="UNSUPPORTED" STF_RESULT_NAME_5="UNTESTED" STF_RESULT_NAME_6="UNINITIATED" STF_RESULT_NAME_7="NORESULT" STF_RESULT_NAME_8="WARNING" STF_RESULT_NAME_9="TIMED_OUT" STF_RESULT_NAME_10="OTHER" Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh (revision 273990) @@ -1,203 +1,213 @@ #!/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 "@(#)zfs_destroy_001_pos.ksh 1.3 09/08/06 SMI" # . $STF_SUITE/include/libtest.kshlib . $STF_SUITE/tests/cli_root/zfs_destroy/zfs_destroy_common.kshlib ################################################################################# # # __stc_assertion_start # # ID: zfs_destroy_001_pos # # DESCRIPTION: # 'zfs destroy -r|-rf|-R|-Rf ' should recursively destroy # all children and clones based on options. # # STRATEGY: # 1. Create test environment according to options. There are three test # models can be created. Only ctr, fs & vol; with snap; with clone. # 2. According to option, make the dataset busy or not. # 3. Run 'zfs destroy [-rRf] ' # 4. According to dataset and option, check if get the expected results. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2005-07-22) # # __stc_assertion_end # ################################################################################ verify_runnable "both" # # According to parameters, 1st, create suitable testing environment. 2nd, # run 'zfs destroy $opt '. 3rd, check the system status. # # $1 option of 'zfs destroy' # $2 dataset will be destroied. # function test_n_check { typeset opt=$1 typeset dtst=$2 if ! is_global_zone ; then if [[ $dtst == $VOL || $dtst == $VOLSNAP ]]; then log_note "UNSUPPORTED: Volume are unavailable in LZ." return fi fi # '-f' has no effect on non-filesystems if [[ $opt == -f ]]; then if [[ $dtst != $FS || $dtst != $CTR ]]; then log_note "UNSUPPORTED: '-f ' is only available for FS." return fi fi # Clean the test environment and make it clear. if datasetexists $CTR; then log_must $ZFS destroy -Rf $CTR fi # According to option create test compatible environment. case $opt in -r|-rf) setup_testenv snap ;; -R|-Rf) setup_testenv clone ;; -f) setup_testenv ;; *) log_fail "Incorrect option: '$opt'." ;; esac # # According to different dataset type, create busy condition when try to # destroy this dataset. # typeset mpt_dir case $dtst in $CTR|$FS) if [[ $opt == *f* ]]; then mpt_dir=$(get_prop mountpoint $FS) make_dir_busy $mpt_dir log_mustnot $ZFS destroy -rR $dtst make_dir_unbusy $mpt_dir fi ;; $VOL) if [[ $opt == *f* ]]; then make_dir_busy $TESTDIR1 log_mustnot $ZFS destroy -rR $dtst make_dir_unbusy $TESTDIR1 fi ;; - $FSSNAP|$VOLSNAP) + $FSSNAP) if [[ $opt == *f* ]]; then mpt_dir=$(snapshot_mountpoint $dtst) + init_dir=$PWD + make_dir_busy $mpt_dir + log_must $ZFS destroy -rR $dtst + log_must $ZFS snapshot $dtst + make_dir_unbusy $mpt_dir + fi + ;; + $VOLSNAP) + if [[ $opt == *f* ]]; then + mpt_dir=$TESTDIR1 init_dir=$PWD make_dir_busy $mpt_dir log_must $ZFS destroy -rR $dtst log_must $ZFS snapshot $dtst make_dir_unbusy $mpt_dir fi ;; *) log_fail "Unsupported dataset: '$dtst'." esac # Firstly, umount ufs filesystem which was created by zfs volume. if is_global_zone; then log_must $UMOUNT -f $TESTDIR1 fi # Invoke 'zfs destroy [-rRf] ' log_must $ZFS destroy $opt $dtst case $dtst in $CTR) check_dataset datasetnonexists \ $CTR $FS $VOL $FSSNAP $VOLSNAP if [[ $opt == *R* ]]; then check_dataset datasetnonexists \ $FSCLONE $VOLCLONE fi ;; $FS) check_dataset datasetexists $CTR $VOL check_dataset datasetnonexists $FS if [[ $opt != -f ]]; then check_dataset datasetexists $VOLSNAP check_dataset datasetnonexists $FSSNAP fi if [[ $opt == *R* ]]; then check_dataset datasetexists $VOLCLONE check_dataset datasetnonexists $FSCLONE fi ;; $VOL) check_dataset datasetexists $CTR $FS $FSSNAP check_dataset datasetnonexists $VOL $VOLSNAP if [[ $opt == *R* ]]; then check_dataset datasetexists $FSCLONE check_dataset datasetnonexists $VOLCLONE fi ;; $FSSNAP) check_dataset datasetexists $CTR $FS $VOL $VOLSNAP check_dataset datasetnonexists $FSSNAP if [[ $opt == *R* ]]; then check_dataset datasetexists $VOLCLONE check_dataset datasetnonexists $FSCLONE fi ;; $VOLSNAP) check_dataset datasetexists $CTR $FS $VOL $FSSNAP check_dataset datasetnonexists $VOLSNAP if [[ $opt == *R* ]]; then check_dataset datasetexists $FSCLONE check_dataset datasetnonexists $VOLCLONE fi ;; esac log_note "'$ZFS destroy $opt $dtst' passed." } log_assert "'zfs destroy -r|-R|-f|-rf|-Rf ' should " \ "recursively destroy all children." log_onexit cleanup_testenv typeset dtst="" typeset opt="" for dtst in $CTR $FS $VOL $FSSNAP $VOLSNAP; do for opt in "-r" "-R" "-f" "-rf" "-Rf"; do log_note "Starting test: $ZFS destroy $opt $dtst" test_n_check $opt $dtst done done log_pass "'zfs destroy -r|-R|-f|-rf|-Rf ' passed." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh (revision 273990) @@ -1,87 +1,84 @@ #!/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 "@(#)zfs_destroy_007_neg.ksh 1.2 07/01/09 SMI" # . $STF_SUITE/include/libtest.kshlib ################################################################################# # # __stc_assertion_start # # ID: zfs_destroy_007_neg # # DESCRIPTION: # 'zpool destroy' failed if this filesystem is namespace-parent # of origin. # # STRATEGY: # 1. Create pool, fs and snapshot. # 2. Create a namespace-parent of origin clone. # 3. Promote this clone # 4. Verify the original fs can not be destroyed. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2006-07-18) # # __stc_assertion_end # ################################################################################ verify_runnable "both" function cleanup { if datasetexists $clonesnap; then log_must $ZFS promote $fs fi datasetexists $clone && log_must $ZFS destroy $clone datasetexists $fssnap && log_must $ZFS destroy $fssnap } log_assert "Destroy dataset which is namespace-parent of origin should failed." log_onexit cleanup # Define variable $fssnap & and namespace-parent of origin clone. fs=$TESTPOOL/$TESTFS fssnap=$fs@snap clone=$fs/clone clonesnap=$fs/clone@snap -# Define key word for expected failure. -KEY_WORDS="filesystem has children" - log_must $ZFS snapshot $fssnap log_must $ZFS clone $fssnap $clone log_must $ZFS promote $clone -log_mustnot_expect "$KEY_WORDS" $ZFS destroy $fs -log_mustnot_expect "$KEY_WORDS" $ZFS destroy $clone +log_mustnot $ZFS destroy $fs +log_mustnot $ZFS destroy $clone log_pass "Destroy dataset which is namespace-parent of origin passed." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib (revision 273990) @@ -1,263 +1,264 @@ # # 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 "@(#)zfs_set_common.kshlib 1.7 09/05/19 SMI" # . $STF_SUITE/include/libtest.kshlib set -A VALID_NAME_CHAR a b c d e f g h i j k l m n o p q r s t u v w x y z \ 0 1 2 3 4 5 6 7 8 9 ':' '-' '.' '_' set -A INVALID_NAME_CHAR A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ '`' '~' '!' '@' '#' '$' '%' '^' '&' '(' ')' '+' '=' \ '|' '{' '[' ']' '}' ';' '"' '<' ',' '>' '?' '/' \ ' ' set -A ALL_CHAR ${VALID_NAME_CHAR[*]} ${INVALID_NAME_CHAR[*]} # # Firstly, set the property value to dataset. Then checking if the property # value is equal with the expected value, according to the expected result. # # $1 property value # $2 property name # $3 dataset # $4 expected result # function set_n_check_prop { typeset expect_value=$1 typeset prop=$2 typeset dataset=$3 typeset expect_result=${4:-true} typeset old_value="" typeset cur_value="" [[ -n $prop ]] && old_value=$(get_prop $prop $dataset) if [[ $expect_result == true ]]; then [[ -z $prop || -z $dataset ]] && \ log_fail "property or dataset isn't defined." log_must $ZFS set $prop=$expect_value $dataset if [[ $expect_value == "gzip-6" ]]; then expect_value="gzip" fi [[ -n $prop ]] && cur_value=$(get_prop $prop $dataset) case $prop in reservation|reserv|quota ) if [[ $expect_value == "none" ]]; then [[ $cur_value != "0" ]] && \ log_fail "The '$dataset' '$prop' value \ '$cur_value' is not expected." elif [[ $cur_value != $expect_value ]]; then log_fail "The '$dataset' '$prop' value '$cur_value' \ does not equal the expected value '$expect_value'." fi ;; * ) if [[ $cur_value != $expect_value ]]; then log_fail "The '$dataset' '$prop' value '$cur_value' \ does not equal the expected value '$expect_value'." fi ;; esac else log_mustnot $ZFS set $prop=$expect_value $dataset [[ -n $prop ]] && cur_value=$(get_prop $prop $dataset) if [[ "$expect_value" != "" && "$cur_value" != "$old_value" ]]; then log_fail "The '$dataset' '$prop' value '$cur_value' \ should equal with '$old_value'." fi fi } # # Cleanup all the user properties of the pool and the dataset reside it. # # $1 pool name # function cleanup_user_prop { typeset pool=$1 typeset dtst=$($ZFS list -H -r -o name -t filesystem,volume $pool) typeset user_prop for dt in $dtst; do user_prop=$($ZFS get -H -o property all $dtst | grep ":") typeset prop for prop in $user_prop; do $ZFS inherit $prop $dt (($? != 0)) && log_must $ZFS inherit $prop $dt done done } # # Random select charactor from the specified charactor set and combine into a # random string # # $1 character set name # $2 String length # function random_string { typeset char_set=${1:-VALID_NAME_CHAR} typeset -i len=${2:-5} eval typeset -i count=\${#$char_set[@]} typeset str typeset -i i=0 while ((i < len)); do typeset -i ind ((ind = RANDOM % count)) eval str=\${str}\${$char_set[\$ind]} ((i += 1)) done $ECHO "$str" } # # Get vaild user defined property name # # $1 user defined property name length # function valid_user_property { typeset -i sumlen=${1:-10} ((sumlen < 2 )) && sumlen=2 typeset -i len ((len = RANDOM % sumlen)) typeset part1 part2 while true; do part1="$(random_string VALID_NAME_CHAR $len)" if [[ "$part1" == "-"* ]]; then continue fi break done ((len = sumlen - (len + 1))) while true; do part2="$(random_string VALID_NAME_CHAR $len)" if [[ -z $part1 && -z $part2 ]]; then continue fi break done $ECHO "${part1}:${part2}" } # # Get invaild user defined property name # # $1 user defined property name length # function invalid_user_property { typeset -i sumlen=${1:-10} ((sumlen == 0)) && sumlen=1 typeset -i len ((len = RANDOM % sumlen)) typeset part1 part2 while true; do part1="$(random_string VALID_NAME_CHAR $len)" ((len = sumlen - len)) part2="$(random_string INVALID_NAME_CHAR $len)" # Avoid $part1 is *:* and $part2 is "=*" if [[ "$part1" == *":"* && "$part2" == "="* ]]; then continue fi break done $ECHO "${part1}${part2}" } # # Get user property value # # $1 user defined property name length # function user_property_value { typeset -i len=${1:-100} + ((len < 1 )) && len=1 typeset value=$(random_string ALL_CHAR $len) $ECHO "$value" } # # Check if the user property is identical to the expected value. # # $1 dataset # $2 user property # $3 expected value # function check_user_prop { typeset dtst=$1 typeset user_prop="$2" typeset expect_value="$3" typeset value=$($ZFS get -p -H -o value "$user_prop" $dtst 2>&1) if [[ "$expect_value" == "$value" ]]; then return 0 else return 1 fi } # # Get source of the dataset # function get_source { typeset prop=$1 typeset dataset=$2 typeset source source=$($ZFS get -H -o source $prop $dataset) if (($? != 0)); then log_fail "Unable to get $prop source for dataset $dataset" fi $ECHO "$source" } Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_user/zfs_list/zfs_list_003_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_user/zfs_list/zfs_list_003_pos.ksh (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_user/zfs_list/zfs_list_003_pos.ksh (revision 273990) @@ -1,87 +1,88 @@ #!/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 "@(#)zfs_list_003_pos.ksh 1.1 07/06/05 SMI" # . $STF_SUITE/include/libtest.kshlib ################################################################################ # # __stc_assertion_start # # ID: zfs_list_003_pos # # DESCRIPTION: # Verify 'zfs list -r' could recursively display any children # of the dataset. # # STRATEGY: # 1. Prepare a set of datasets by hierarchy. # 2. Execute 'zfs list -r' at the top of these datasets. # 3. Verify all child datasets are all be shown. # # TESTABILITY: explicit # # TEST_AUTOMATION_LEVEL: automated # # CODING_STATUS: COMPLETED (2007-05-24) # # __stc_assertion_end # ################################################################################ function cleanup { if [[ -f $tmpfile ]]; then $RM -f $tmpfile fi } verify_runnable "both" log_onexit cleanup log_assert "Verify 'zfs list -r' could display any children recursively." tmpfile=$TMPDIR/zfslist.out.${TESTCASE_ID} children="$TESTPOOL/$TESTFS" for fs in $DATASETS ; do children="$children $TESTPOOL/$TESTFS/$fs" done -cd $TMPDIR +cd /tmp for path in $TESTPOOL/$TESTFS $TESTDIR ./../$TESTDIR ; do $ZFS list -rH -o name $path > $tmpfile for fs in $children ; do - $GREP "^${fs}$" $tmpfile > /dev/null 2>&1 + $GREP -q "^${fs}$" $tmpfile if (( $? != 0 )); then + cat $tmpfile log_fail "$fs not shown in the output list." fi done done log_pass "'zfs list -r' could display any children recursively." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile (revision 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile (revision 273990) @@ -1,33 +1,34 @@ # $FreeBSD$ .include TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/zfsd FILESDIR=${TESTSDIR} ATF_TESTS_KSH93+= zfsd_test -FILES+= zfsd_hotspare_006_pos.ksh -FILES+= zfsd_hotspare_002_pos.ksh -FILES+= zfsd_fault_001_pos.ksh -FILES+= zfsd_autoreplace_001_neg.ksh +FILES+= cleanup.ksh FILES+= hotspare_cleanup.ksh FILES+= hotspare_setup.ksh -FILES+= zfsd_degrade_002_pos.ksh -FILES+= zfsd_hotspare_003_pos.ksh -FILES+= zfsd_import_001_pos.ksh -FILES+= zfsd_replace_001_pos.ksh +FILES+= setup.ksh +FILES+= zfsd.cfg FILES+= zfsd.kshlib -FILES+= zfsd_hotspare_005_pos.ksh +FILES+= zfsd_autoreplace_001_neg.ksh +FILES+= zfsd_autoreplace_002_pos.ksh FILES+= zfsd_autoreplace_003_pos.ksh +FILES+= zfsd_degrade_001_pos.ksh +FILES+= zfsd_degrade_002_pos.ksh +FILES+= zfsd_fault_001_pos.ksh FILES+= zfsd_hotspare_001_pos.ksh -FILES+= zfsd.cfg -FILES+= zfsd_replace_003_pos.ksh +FILES+= zfsd_hotspare_002_pos.ksh +FILES+= zfsd_hotspare_003_pos.ksh FILES+= zfsd_hotspare_004_pos.ksh -FILES+= zfsd_autoreplace_002_pos.ksh -FILES+= cleanup.ksh +FILES+= zfsd_hotspare_005_pos.ksh +FILES+= zfsd_hotspare_006_pos.ksh +FILES+= zfsd_hotspare_007_pos.ksh +FILES+= zfsd_import_001_pos.ksh +FILES+= zfsd_replace_001_pos.ksh FILES+= zfsd_replace_002_pos.ksh -FILES+= setup.ksh -FILES+= zfsd_degrade_001_pos.ksh +FILES+= zfsd_replace_003_pos.ksh .include 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 (nonexistent) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh (revision 273990) @@ -0,0 +1,159 @@ +#!/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/include/libsas.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. +# 2. Turn off zfsd +# 3. Remove one vdev by turning off its SAS phy. +# 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" +verify_disk_count "$DISKS" 5 + +function cleanup +{ + poolexists $TESTPOOL && \ + destroy_pool $TESTPOOL + + # See if the phy has been disabled, and try to re-enable it if possible. + if [ ! -z "$REMOVAL_DISK" ]; then + camcontrol inquiry $REMOVAL_DISK > /dev/null + if [ $? != 0 ]; then + if [ ! -z "$EXPANDER" ] && [ ! -z "$PHY" ]; then + enable_sas_disk $EXPANDER $PHY + fi + fi + fi + + [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/* + + partition_cleanup +} + + +log_assert "zfsd will spare missing drives on startup" + +log_onexit cleanup + + +function verify_assertion # spare_dev +{ + typeset sdev=$1 + find_verify_sas_disk $REMOVAL_DISK + stop_zfsd + + log_note "Disabling \"$REMOVAL_DISK\" on expander $EXPANDER phy $PHY" + disable_sas_disk $EXPANDER $PHY + + #Check to make sure the disk is gone + camcontrol inquiry $REMOVAL_DISK > /dev/null 2>&1 + if [ $? = 0 ]; then + log_fail "Disk \"$REMOVAL_DISK\" was not removed" + fi + + # Check to make sure ZFS sees the disk as removed + for ((timeout=0; $timeout<20; timeout=$timeout+1)); do + check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" + is_removed=$? + if [[ $is_removed == 0 ]]; then + break + fi + $SLEEP 3 + done + log_must check_state $TESTPOOL "$REMOVAL_DISK" "REMOVED" + + restart_zfsd + + # Check that the spare was activated + for ((timeout=0; $timeout<20; timeout=$timeout+1)); do + check_state $TESTPOOL "$sdev" "INUSE" + spare_inuse=$? + if [[ $spare_inuse == 0 ]]; then + break + fi + $SLEEP 3 + done + log_must $ZPOOL status $TESTPOOL + log_must check_state $TESTPOOL "$sdev" "INUSE" + + # Reenable the missing disk + log_note "Reenabling phy on expander $EXPANDER phy $PHY" + enable_sas_disk $EXPANDER $PHY + + # Check that the disk has returned + for ((timeout=0; $timeout<20; timeout=$timeout+1)); do + find_disk_by_phy $EXPANDER $PHY + if [[ -n "$FOUNDDISK" ]]; then + break + fi + $SLEEP 3 + done + + if [[ -z "$FOUNDDISK" ]]; then + log_fail "Disk $REMOVAL_DISK never reappeared" + fi +} + + +typeset REMOVAL_DISK=$DISK0 +typeset SDEV=$DISK4 +typeset POOLDEVS="$DISK0 $DISK1 $DISK2 $DISK3" +set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" +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 + + destroy_pool "$TESTPOOL" +done 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 273989) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh (revision 273990) @@ -1,575 +1,610 @@ # 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.config" rt_long atf_set "require.config" at_least_2_disks atf_set "require.progs" zfs zpool zfsd atf_set "timeout" 300 } zfsd_fault_001_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.config" at_least_2_disks atf_set "require.progs" mkfile zpool zfsd atf_set "timeout" 300 } zfsd_degrade_001_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.config" at_least_3_disks atf_set "require.progs" mkfile zpool zfsd atf_set "timeout" 300 } zfsd_degrade_002_pos_body() { atf_expect_fail "BUG25761 An active spare on a raidz array will incorrectly account its checksum errors" export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.progs" zpool zfsd atf_set "timeout" 3600 } zfsd_hotspare_001_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_002_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.config" at_least_5_disks atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_003_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_003_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_003_pos_cleanup() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.config" at_least_5_disks atf_set "require.progs" zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_hotspare_004_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_004_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_hotspare_004_pos_cleanup() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_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.config" rt_long atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_005_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.progs" zpool zfsd zinject atf_set "timeout" 3600 } zfsd_hotspare_006_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long + atf_set "require.config" at_least_5_disks + atf_set "require.progs" zpool camcontrol zfsd + atf_set "timeout" 3600 +} +zfsd_hotspare_007_pos_body() +{ + atf_expect_fail "P3_28731: ZFSD will not replace a vdev that dissappears while power is off" + export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") + . $(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_007_pos.ksh + if [[ $? != 0 ]]; then + save_artifacts + atf_fail "Testcase failed" + fi +} +zfsd_hotspare_007_pos_cleanup() +{ + export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") + . $(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.config" rt_long atf_set "require.config" at_least_5_disks atf_set "require.progs" zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_autoreplace_001_neg_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_autoreplace_001_neg.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_autoreplace_001_neg_cleanup() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_002_pos cleanup zfsd_autoreplace_002_pos_head() { atf_set "descr" "A pool with autoreplace set will replace by physical path" atf_set "require.config" rt_long atf_set "require.config" at_least_5_disks atf_set "require.progs" zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_autoreplace_002_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_autoreplace_002_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_autoreplace_002_pos_cleanup() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_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.config" rt_long atf_set "require.config" at_least_5_disks atf_set "require.progs" zpool camcontrol zfsd atf_set "timeout" 3600 } zfsd_autoreplace_003_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_autoreplace_003_pos.ksh if [[ $? != 0 ]]; then save_artifacts atf_fail "Testcase failed" fi } zfsd_autoreplace_003_pos_cleanup() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_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.config" rt_long atf_set "require.config" at_least_2_disks atf_set "require.progs" zpool camcontrol zfsd zfs } zfsd_replace_001_pos_body() { atf_expect_fail "TeamTrack P3_29531 zpool status prematurely indicates resilver completion" export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.config" at_least_2_disks atf_set "require.progs" zpool camcontrol zfsd zfs } zfsd_replace_002_pos_body() { atf_expect_fail "ZFS hangs when an array becomes critical" export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.config" at_least_3_disks atf_set "require.progs" zpool camcontrol zfsd zfs } zfsd_replace_003_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/zfsd.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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.config" rt_long atf_set "require.progs" zfsd zpool atf_set "timeout" 3600 } zfsd_import_001_pos_body() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib . $(atf_get_srcdir)/../hotspare/hotspare.cfg 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() { export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(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_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 }