svn commit: r273990 - in projects/zfsd/head/tests/sys/cddl/zfs: include tests/cli_root/zfs_destroy tests/cli_root/zfs_set tests/cli_user/zfs_list tests/zfsd
Brad Davis
brd at FreeBSD.org
Sun Nov 2 21:36:43 UTC 2014
Author: brd (doc committer)
Date: Sun Nov 2 21:36:40 2014
New Revision: 273990
URL: https://svnweb.freebsd.org/changeset/base/273990
Log:
Sync Alan Somers (asomers) work from SpectraBSD.
tests/sys/cddl/zfs/include/logapi.kshlib
Eliminate the unfortunate miscombination of
functionality that is log_mustnot_expect. It verified
that the supplied command failed and also printed the
supplied message to stderr. It was only used in one
test, and wasn't really necessary.
tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh
Convert log_mustnot_expect to log_mustnot. Verifying
the error message isn't necessary.
MFSpectraBSD: 1088174 on 2014/09/02
tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh
Don't lookup the mountpoint of a zvol's snapshot,
because it can't be done. Instead, use the mountpoint
that was stored in a variable when the zvol was
formatted and mounted.
MFSpectraBSD: 1088197 on 2014/09/02
tests/sys/cddl/zfs/include/Makefile
tests/sys/cddl/zfs/include/logapi.kshlib
tests/sys/cddl/zfs/include/stf.kshlib
tests/sys/cddl/zfs/include/stf.shlib
Delete stf.kshlib. Nothing uses its contents
MFSpectraBSD: 1088202 on 2014/09/02
tests/sys/cddl/zfs/tests/cli_user/zfs_list/zfs_list_003_pos.ksh
Fix test when TMPDIR != /tmp. We must cd to /tmp
regardless of TMPDIR so relative pathnames will be
correct.
MFSpectraBSD: 1088360 on 2014/09/03
tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib
Don't generate 0-length user property values.
MFSpectraBSD: 1088368 on 2014/09/03
tests/sys/cddl/zfs/tests/zfsd/Makefile
tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
Add a regression test for the as-yet-unresolved
P3_28731: ZFSD will not replace a vdev that dissappears
while power is off.
MFSpectraBSD: 1091329 on 2014/09/17
Differential Revision: D1018
Reviewed by: asomers
Added:
projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
Deleted:
projects/zfsd/head/tests/sys/cddl/zfs/include/stf.kshlib
Modified:
projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile
projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib
projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib
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_007_neg.ksh
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_user/zfs_list/zfs_list_003_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile
projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile Sun Nov 2 21:36:40 2014 (r273990)
@@ -11,7 +11,6 @@ FILES+= libsas.kshlib
FILES+= logapi.kshlib
FILES+= libtest.kshlib
FILES+= stf.shlib
-FILES+= stf.kshlib
FILES+= commands.cfg
commands.cfg: translatecommands.awk commands.txt
Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/logapi.kshlib Sun Nov 2 21:36:40 2014 (r273990)
@@ -31,7 +31,7 @@
# other ksh scripts and not executed directly.
#
-. ${STF_SUITE}/include/stf.kshlib
+. ${STF_SUITE}/include/stf.shlib
# Output an assertion
#
@@ -51,18 +51,6 @@ 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
@@ -83,34 +71,24 @@ function log_mustnot
(( $? != 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.$$"
@@ -144,14 +122,6 @@ function log_neg_expect
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
@@ -169,6 +139,10 @@ function log_neg_expect
#
# $@ 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
@@ -323,6 +297,10 @@ function log_other
# 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
Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/stf.shlib Sun Nov 2 21:36:40 2014 (r273990)
@@ -26,14 +26,6 @@
# 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
Modified: 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 Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh Sun Nov 2 21:36:40 2014 (r273990)
@@ -120,7 +120,7 @@ function test_n_check
make_dir_unbusy $TESTDIR1
fi
;;
- $FSSNAP|$VOLSNAP)
+ $FSSNAP)
if [[ $opt == *f* ]]; then
mpt_dir=$(snapshot_mountpoint $dtst)
init_dir=$PWD
@@ -130,6 +130,16 @@ function test_n_check
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
Modified: 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 Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh Sun Nov 2 21:36:40 2014 (r273990)
@@ -75,13 +75,10 @@ fssnap=$fs at snap
clone=$fs/clone
clonesnap=$fs/clone at 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."
Modified: 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 Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib Sun Nov 2 21:36:40 2014 (r273990)
@@ -218,6 +218,7 @@ function invalid_user_property
function user_property_value
{
typeset -i len=${1:-100}
+ ((len < 1 )) && len=1
typeset value=$(random_string ALL_CHAR $len)
Modified: 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 Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_user/zfs_list/zfs_list_003_pos.ksh Sun Nov 2 21:36:40 2014 (r273990)
@@ -72,13 +72,14 @@ 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
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/Makefile Sun Nov 2 21:36:40 2014 (r273990)
@@ -7,27 +7,28 @@ 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 <bsd.test.mk>
Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh Sun Nov 2 21:36:40 2014 (r273990)
@@ -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
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Sun Nov 2 21:34:24 2014 (r273989)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Sun Nov 2 21:36:40 2014 (r273990)
@@ -315,6 +315,40 @@ zfsd_hotspare_006_pos_cleanup()
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()
{
@@ -553,6 +587,7 @@ atf_init_test_cases()
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
More information about the svn-src-projects
mailing list