svn commit: r292300 - projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy
Alan Somers
asomers at FreeBSD.org
Wed Dec 16 00:13:42 UTC 2015
Author: asomers
Date: Wed Dec 16 00:13:40 2015
New Revision: 292300
URL: https://svnweb.freebsd.org/changeset/base/292300
Log:
Fix various issues with the redundancy test suite.
- Remove randomness as a factor. Instead of picking a random number of
vdevs to create in the pool, always pick a specific subset that will
adequately exercise redundancy, as well as make the test results more
deterministic.
- sync_pool(): To complete, in addition to being scrubbed, the pool must not
be in the resilvered state. There appears to be a race in which the pool
can have resilvered previously, and where this state isn't immediately
reset upon scrubbing. This is probably because the resilver state is only
updated when the scan context runs, which may be delayed from the return.
- replace_missing_devs(): Don't recreate the vdev if it already exists. In
the case where damage_devs() is used (as opposed to remove_devs()), the
vdev file already exists and its state reconciled (but not healthy until
replaced later in this function).
Submitted by: Will
Sponsored by: Spectra Logic Corp
Modified:
projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib
projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_001_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_002_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_003_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_004_neg.ksh
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib Wed Dec 16 00:13:16 2015 (r292299)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib Wed Dec 16 00:13:40 2015 (r292300)
@@ -30,9 +30,7 @@
function cleanup
{
- if poolexists $TESTPOOL; then
- destroy_pool $TESTPOOL
- fi
+ destroy_pool $TESTPOOL
typeset dir
for dir in $TESTDIR $BASEDIR; do
if [[ -d $dir ]]; then
@@ -42,28 +40,6 @@ function cleanup
}
#
-# Get random number between min and max number.
-#
-# $1 Minimal value
-# $2 Maximal value
-#
-function random
-{
- typeset -i min=$1
- typeset -i max=$2
- typeset -i value
-
- while true; do
- ((value = RANDOM % (max + 1)))
- if ((value >= min)); then
- break
- fi
- done
-
- $ECHO $value
-}
-
-#
# Record the directories construction and checksum all the files which reside
# within the specified pool
#
@@ -108,20 +84,14 @@ function setup_test_env
((i += 1))
done
- if [[ ! -d $BASEDIR ]]; then
- log_must $MKDIR $BASEDIR
- fi
-
- if poolexists $pool ; then
- destroy_pool $pool
- fi
-
+ log_must $MKDIR -p $BASEDIR
+ destroy_pool $pool
log_must $MKFILE $DEV_SIZE $vdevs
$ECHO $vdevs | tr ' ' '\n' > $BASEDIR/vdevs
log_must $ZPOOL create -m $TESTDIR $pool $keyword $vdevs
- log_note "Filling up the filesystem ..."
+ log_note "Pool $pool created with $vdev_cnt vdevs, filling up..."
typeset -i ret=0
typeset -i i=0
typeset file=$TESTDIR/file
@@ -222,10 +192,9 @@ function sync_pool #pool
is_pool_scrubbing $pool || is_pool_scrubbed $pool || \
log_fail "$ZPOOL scrub $pool failed."
- while ! is_pool_scrubbed $pool; do
- if is_pool_resilvered $pool ; then
- log_fail "$pool should not be resilver completed."
- fi
+ # The pool has been damaged; the sync should notice this fact.
+ log_note "Waiting for pool to sync..."
+ while ! is_pool_scrubbed $pool || is_pool_resilvered $pool; do
log_must $SLEEP 2
done
}
@@ -245,12 +214,8 @@ function replace_missing_devs
for vdev in $@; do
log_must $MKFILE $DEV_SIZE $vdev
log_must $ZPOOL replace -f $pool $vdev $vdev
- while true; do
- if ! is_pool_resilvered $pool ; then
- log_must $SLEEP 2
- else
- break
- fi
+ while ! is_pool_resilvered $pool; do
+ log_must $SLEEP 2
done
done
}
@@ -286,6 +251,7 @@ function damage_devs
fi
sync_pool $pool
+ log_note "Pool $pool vdevs $vdevs damage completed."
}
#
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_001_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_001_pos.ksh Wed Dec 16 00:13:16 2015 (r292299)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_001_pos.ksh Wed Dec 16 00:13:40 2015 (r292300)
@@ -62,27 +62,28 @@ verify_runnable "global"
log_assert "Verify raidz pool can withstand one device is failing."
log_onexit cleanup
-typeset -i cnt=$(random 2 5)
-setup_test_env $TESTPOOL raidz $cnt
+for cnt in 3 2; do
+ setup_test_env $TESTPOOL raidz $cnt
-#
-# Inject data corruption error for raidz pool
-#
-damage_devs $TESTPOOL 1 "label"
-log_must is_data_valid $TESTPOOL
-log_must clear_errors $TESTPOOL
+ #
+ # Inject data corruption error for raidz pool
+ #
+ damage_devs $TESTPOOL 1 "label"
+ log_must is_data_valid $TESTPOOL
+ log_must clear_errors $TESTPOOL
-#
-# Inject bad device error for raidz pool
-#
-damage_devs $TESTPOOL 1
-log_must is_data_valid $TESTPOOL
-log_must recover_bad_missing_devs $TESTPOOL 1
+ #
+ # Inject bad device error for raidz pool
+ #
+ damage_devs $TESTPOOL 1
+ log_must is_data_valid $TESTPOOL
+ log_must recover_bad_missing_devs $TESTPOOL 1
-#
-# Inject missing device error for raidz pool
-#
-remove_devs $TESTPOOL 1
-log_must is_data_valid $TESTPOOL
+ #
+ # Inject missing device error for raidz pool
+ #
+ remove_devs $TESTPOOL 1
+ log_must is_data_valid $TESTPOOL
+done
log_pass "Raidz pool can withstand one devices is failing passed."
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_002_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_002_pos.ksh Wed Dec 16 00:13:16 2015 (r292299)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_002_pos.ksh Wed Dec 16 00:13:40 2015 (r292300)
@@ -62,34 +62,35 @@ verify_runnable "global"
log_assert "Verify raidz2 pool can withstand two devices are failing."
log_onexit cleanup
-typeset -i cnt=$(random 3 5)
-setup_test_env $TESTPOOL raidz2 $cnt
+for cnt in 3 4; do
+ setup_test_env $TESTPOOL raidz2 $cnt
-#
-# Inject data corruption errors for raidz2 pool
-#
-for i in 1 2; do
- damage_devs $TESTPOOL $i "label"
- log_must is_data_valid $TESTPOOL
- log_must clear_errors $TESTPOOL
-done
+ #
+ # Inject data corruption errors for raidz2 pool
+ #
+ for i in 1 2; do
+ damage_devs $TESTPOOL $i "label"
+ log_must is_data_valid $TESTPOOL
+ log_must clear_errors $TESTPOOL
+ done
-#
-# Inject bad devices errors for raidz2 pool
-#
-for i in 1 2; do
- damage_devs $TESTPOOL $i
- log_must is_data_valid $TESTPOOL
- log_must recover_bad_missing_devs $TESTPOOL $i
-done
+ #
+ # Inject bad devices errors for raidz2 pool
+ #
+ for i in 1 2; do
+ damage_devs $TESTPOOL $i
+ log_must is_data_valid $TESTPOOL
+ log_must recover_bad_missing_devs $TESTPOOL $i
+ done
-#
-# Inject missing device errors for raidz2 pool
-#
-for i in 1 2; do
- remove_devs $TESTPOOL $i
- log_must is_data_valid $TESTPOOL
- log_must recover_bad_missing_devs $TESTPOOL $i
+ #
+ # Inject missing device errors for raidz2 pool
+ #
+ for i in 1 2; do
+ remove_devs $TESTPOOL $i
+ log_must is_data_valid $TESTPOOL
+ log_must recover_bad_missing_devs $TESTPOOL $i
+ done
done
log_pass "Raidz2 pool can withstand two devices are failing passed."
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_003_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_003_pos.ksh Wed Dec 16 00:13:16 2015 (r292299)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_003_pos.ksh Wed Dec 16 00:13:40 2015 (r292300)
@@ -62,44 +62,45 @@ verify_runnable "global"
log_assert "Verify mirrored pool can withstand N-1 devices are failing or missing."
log_onexit cleanup
-typeset -i cnt=$(random 2 5)
-setup_test_env $TESTPOOL mirror $cnt
+for cnt in 3 2; do
+ typeset -i i=1
-typeset -i i=1
+ setup_test_env $TESTPOOL mirror $cnt
-#
-# Inject data corruption errors for mirrored pool
-#
-while (( i < cnt )); do
- damage_devs $TESTPOOL $i "label"
- log_must is_data_valid $TESTPOOL
- log_must clear_errors $TESTPOOL
-
- (( i +=1 ))
-done
-
-#
-# Inject bad devices errors for mirrored pool
-#
-i=1
-while (( i < cnt )); do
- damage_devs $TESTPOOL $i
- log_must is_data_valid $TESTPOOL
- log_must recover_bad_missing_devs $TESTPOOL $i
-
- (( i +=1 ))
-done
-
-#
-# Inject missing device errors for mirrored pool
-#
-i=1
-while (( i < cnt )); do
- remove_devs $TESTPOOL $i
- log_must is_data_valid $TESTPOOL
- log_must recover_bad_missing_devs $TESTPOOL $i
+ #
+ # Inject data corruption errors for mirrored pool
+ #
+ while (( i < cnt )); do
+ damage_devs $TESTPOOL $i "label"
+ log_must is_data_valid $TESTPOOL
+ log_must clear_errors $TESTPOOL
+
+ (( i +=1 ))
+ done
+
+ #
+ # Inject bad devices errors for mirrored pool
+ #
+ i=1
+ while (( i < cnt )); do
+ damage_devs $TESTPOOL $i
+ log_must is_data_valid $TESTPOOL
+ log_must recover_bad_missing_devs $TESTPOOL $i
+
+ (( i +=1 ))
+ done
+
+ #
+ # Inject missing device errors for mirrored pool
+ #
+ i=1
+ while (( i < cnt )); do
+ remove_devs $TESTPOOL $i
+ log_must is_data_valid $TESTPOOL
+ log_must recover_bad_missing_devs $TESTPOOL $i
- (( i +=1 ))
+ (( i +=1 ))
+ done
done
log_pass "Mirrored pool can withstand N-1 devices failing as expected."
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_004_neg.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_004_neg.ksh Wed Dec 16 00:13:16 2015 (r292299)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy_004_neg.ksh Wed Dec 16 00:13:40 2015 (r292300)
@@ -62,11 +62,11 @@ verify_runnable "global"
log_assert "Verify striped pool have no data redundancy."
log_onexit cleanup
-typeset -i cnt=$(random 2 5)
-setup_test_env $TESTPOOL "" $cnt
-
-damage_devs $TESTPOOL 1 "keep_label"
-log_must $ZPOOL clear $TESTPOOL
-log_mustnot is_healthy $TESTPOOL
+for cnt in 2 3; do
+ setup_test_env $TESTPOOL "" $cnt
+ damage_devs $TESTPOOL 1 "keep_label"
+ log_must $ZPOOL clear $TESTPOOL
+ log_mustnot is_healthy $TESTPOOL
+done
log_pass "Striped pool has no data redundancy as expected."
More information about the svn-src-projects
mailing list