diff options
author | John Wren Kennedy <[email protected]> | 2016-08-17 15:15:27 -0600 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-06-04 14:55:02 -0700 |
commit | ab44e511e2546567a296a88e71ed2056372fd5a4 (patch) | |
tree | 866d0a8097b872edfa119612b44e4589627c3fea | |
parent | 8a393be353c3bfffbfbe0f4d2bc57210b658dcde (diff) |
OpenZFS 9245 - zfs-test failures: slog_013_pos and slog_014_pos
Test 13 would fail because of attempts to zpool destroy -f a pool that
was still busy. Changed those calls to destroy_pool which does a retry
loop, and the problem is no longer reproducible. Also removed some non
functional code in the test which is why it was originally commented out
by placing it after the call to log_pass.
Test 14 would fail because sometimes the check for a degraded pool would
complete before the pool had changed state. Changed the logic to check
in a loop with a timeout and the problem is no longer reproducible.
Authored by: John Wren Kennedy <[email protected]>
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: Chris Williamson <[email protected]>
Reviewed by: Yuri Pankov <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Approved by: Dan McDonald <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>
Porting Notes:
* Re-enabled slog_013_pos.ksh
OpenZFS-issue: https://illumos.org/issues/9245
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/8f323b5
Closes #7585
-rw-r--r-- | tests/zfs-tests/include/libtest.shlib | 19 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/slog/slog.kshlib | 8 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/slog/slog_013_pos.ksh | 25 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh | 14 |
4 files changed, 28 insertions, 38 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index e8def35f8..53914d3d0 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2152,6 +2152,25 @@ function is_pool_removed #pool return $? } +function wait_for_degraded +{ + typeset pool=$1 + typeset timeout=${2:-30} + typeset t0=$SECONDS + + while :; do + [[ $(get_pool_prop health $pool) == "DEGRADED" ]] && break + log_note "$pool is not yet degraded." + sleep 1 + if ((SECONDS - t0 > $timeout)); then + log_note "$pool not degraded after $timeout seconds." + return 1 + fi + done + + return 0 +} + # # Use create_pool()/destroy_pool() to clean up the information in # in the given disk to avoid slice overlapping. diff --git a/tests/zfs-tests/tests/functional/slog/slog.kshlib b/tests/zfs-tests/tests/functional/slog/slog.kshlib index b32d18f2e..6ed7e4e05 100644 --- a/tests/zfs-tests/tests/functional/slog/slog.kshlib +++ b/tests/zfs-tests/tests/functional/slog/slog.kshlib @@ -33,12 +33,8 @@ function cleanup { - if datasetexists $TESTPOOL ; then - log_must zpool destroy -f $TESTPOOL - fi - if datasetexists $TESTPOOL2 ; then - log_must zpool destroy -f $TESTPOOL2 - fi + poolexists $TESTPOOL && destroy_pool $TESTPOOL + poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2 rm -rf $TESTDIR } diff --git a/tests/zfs-tests/tests/functional/slog/slog_013_pos.ksh b/tests/zfs-tests/tests/functional/slog/slog_013_pos.ksh index 1436feab9..bbe5adc24 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_013_pos.ksh @@ -44,16 +44,9 @@ verify_runnable "global" -if ! $(is_physical_device $DISKS) ; then - log_unsupported "This directory cannot be run on raw files." -fi - function cleanup_testenv { cleanup - if datasetexists $TESTPOOL2 ; then - log_must zpool destroy -f $TESTPOOL2 - fi if [[ -n $lofidev ]]; then if is_linux; then losetup -d $lofidev @@ -71,19 +64,19 @@ log_onexit cleanup_testenv dsk1=${DISKS%% *} log_must zpool create $TESTPOOL ${DISKS#$dsk1} -# Add nomal disk +# Add provided disk log_must zpool add $TESTPOOL log $dsk1 log_must verify_slog_device $TESTPOOL $dsk1 'ONLINE' -# Add nomal file +# Add normal file log_must zpool add $TESTPOOL log $LDEV ldev=$(random_get $LDEV) log_must verify_slog_device $TESTPOOL $ldev 'ONLINE' -# Add lofi device +# Add loop back device if is_linux; then lofidev=$(losetup -f) - lofidev=${lofidev##*/} log_must losetup $lofidev ${LDEV2%% *} + lofidev=${lofidev##*/} else lofidev=${LDEV2%% *} log_must lofiadm -a $lofidev @@ -94,13 +87,3 @@ log_must verify_slog_device $TESTPOOL $lofidev 'ONLINE' log_pass "Verify slog device can be disk, file, lofi device or any device " \ "that presents a block interface." - -# Add file which reside in the itself -mntpnt=$(get_prop mountpoint $TESTPOOL) -log_must mkfile $MINVDEVSIZE $mntpnt/vdev -log_must zpool add $TESTPOOL $mntpnt/vdev - -# Add ZFS volume -vol=$TESTPOOL/vol -log_must zpool create -V $MINVDEVSIZE $vol -log_must zpool add $TESTPOOL ${ZVOL_DEVDIR}/$vol diff --git a/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh b/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh index bc0c2fec5..7e1872893 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh @@ -45,10 +45,8 @@ verify_runnable "global" log_assert "log device can survive when one of the pool device get corrupted." -for type in "mirror" "raidz" "raidz2" -do - for spare in "" "spare" - do +for type in "mirror" "raidz" "raidz2"; do + for spare in "" "spare"; do log_must zpool create $TESTPOOL $type $VDEV $spare $SDEV \ log $LDEV @@ -64,14 +62,8 @@ do fi log_must zpool scrub $TESTPOOL log_must display_status $TESTPOOL - log_must zpool status $TESTPOOL 2>&1 >/dev/null log_must zpool offline $TESTPOOL $VDIR/a - - zpool status -v $TESTPOOL | \ - grep "state: DEGRADED" 2>&1 >/dev/null - if (( $? != 0 )); then - log_fail "pool $TESTPOOL status should be DEGRADED" - fi + log_must wait_for_degraded $TESTPOOL zpool status -v $TESTPOOL | grep logs | \ grep "DEGRADED" 2>&1 >/dev/null |