ZTS: clean_mirror and scrub_mirror cleanup

Remove the dependency on partitionable devices for the clean_mirror
and scrub_mirror test cases.  This allows for the setup and cleanup
of the test cases to be simplified by removing the need for complex
partitioning.

This change also resolves a issue where the clean_mirror devices
were not being properly damaged since the device name was not a
full path.  The result being loopX files were being left in the
top level test_results directory.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7434 
Closes #7690
This commit is contained in:
Brian Behlendorf 2018-07-09 12:46:14 -07:00 committed by GitHub
parent 94370f5955
commit 66df02497c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 32 additions and 228 deletions

View File

@ -202,7 +202,6 @@ maybe = {
'cache/setup': ['SKIP', disk_reason], 'cache/setup': ['SKIP', disk_reason],
'cache/cache_010_neg': ['FAIL', known_reason], 'cache/cache_010_neg': ['FAIL', known_reason],
'chattr/setup': ['SKIP', exec_reason], 'chattr/setup': ['SKIP', exec_reason],
'clean_mirror/setup': ['SKIP', disk_reason],
'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason], 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason], 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason],
'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'], 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'],
@ -251,7 +250,6 @@ maybe = {
'rsend/rsend_021_pos': ['FAIL', '6446'], 'rsend/rsend_021_pos': ['FAIL', '6446'],
'rsend/rsend_024_pos': ['FAIL', '5665'], 'rsend/rsend_024_pos': ['FAIL', '5665'],
'rsend/send-c_volume': ['FAIL', '6087'], 'rsend/send-c_volume': ['FAIL', '6087'],
'scrub_mirror/setup': ['SKIP', disk_reason],
'snapshot/clone_001_pos': ['FAIL', known_reason], 'snapshot/clone_001_pos': ['FAIL', known_reason],
'snapused/snapused_004_pos': ['FAIL', '5513'], 'snapused/snapused_004_pos': ['FAIL', '5513'],
'tmpfile/setup': ['SKIP', tmpfile_reason], 'tmpfile/setup': ['SKIP', tmpfile_reason],

View File

@ -32,12 +32,6 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/clean_mirror/default.cfg . $STF_SUITE/tests/functional/clean_mirror/default.cfg
# Most of the code related to the clearing of mirrors is duplicated in all
# the test cases below this directory, barring a few minor changes
# involving the device to be affected and the 'object' to use to mangle
# the contents of the mirror.
# This code is sourced into each of these test cases.
function overwrite_verify_mirror function overwrite_verify_mirror
{ {
typeset AFFECTED_DEVICE=$1 typeset AFFECTED_DEVICE=$1
@ -56,7 +50,7 @@ function overwrite_verify_mirror
(( atfile = atfile + 1 )) (( atfile = atfile + 1 ))
done done
# dd the primary side of the mirror # dd the affected side of the mirror
log_must dd if=$OVERWRITING_DEVICE of=$AFFECTED_DEVICE \ log_must dd if=$OVERWRITING_DEVICE of=$AFFECTED_DEVICE \
seek=8 bs=$DD_BLOCK count=$(( DD_COUNT - 128 )) conv=notrunc seek=8 bs=$DD_BLOCK count=$(( DD_COUNT - 128 )) conv=notrunc
@ -66,7 +60,7 @@ function overwrite_verify_mirror
# Flush out the cache so that we ensure we're reading from disk. # Flush out the cache so that we ensure we're reading from disk.
# #
log_must zpool export $TESTPOOL log_must zpool export $TESTPOOL
log_must zpool import $TESTPOOL log_must zpool import -d $SIDE_DIR $TESTPOOL
typeset -i failedcount=0 typeset -i failedcount=0
while (( atfile < FILE_COUNT )); do while (( atfile < FILE_COUNT )); do
@ -84,5 +78,6 @@ function overwrite_verify_mirror
"have the same checksum before and after." "have the same checksum before and after."
fi fi
sync_pool $TESTPOOL log_must zpool scrub $TESTPOOL
log_must wait_scrubbed $TESTPOOL
} }

View File

@ -34,22 +34,8 @@
verify_runnable "global" verify_runnable "global"
df -F zfs -h | grep "$TESTFS " >/dev/null
[[ $? == 0 ]] && log_must zfs umount -f $TESTDIR
destroy_pool $TESTPOOL destroy_pool $TESTPOOL
log_must rm -f $SIDE_PRIMARY $SIDE_SECONDARY
if ( is_mpath_device $MIRROR_PRIMARY || is_loop_device $MIRROR_SECONDARY); then log_must rmdir $SIDE_DIR
parted $DEV_DSKDIR/$MIRROR_PRIMARY -s rm 1
fi
if ( is_mpath_device $MIRROR_SECONDARY || is_loop_device $MIRROR_SECONDARY); then
parted $DEV_DSKDIR/$MIRROR_SECONDARY -s rm 1
fi
# recreate and destroy a zpool over the disks to restore the partitions to
# normal
if [[ -n $SINGLE_DISK ]]; then
log_must cleanup_devices $MIRROR_PRIMARY
else
log_must cleanup_devices $MIRROR_PRIMARY $MIRROR_SECONDARY
fi
log_pass log_pass

View File

@ -28,80 +28,10 @@
# Copyright (c) 2013 by Delphix. All rights reserved. # Copyright (c) 2013 by Delphix. All rights reserved.
# #
. $STF_SUITE/include/libtest.shlib export SIDE_DIR="${TEST_BASE_DIR}/clean_mirror"
export SIDE_PRIMARY="${SIDE_DIR}/dev1"
typeset -i NUMBER_OF_DISKS=0 export SIDE_SECONDARY="${SIDE_DIR}/dev2"
for i in $DISKS; do
[[ -n $MIRROR_PRIMARY ]] && MIRROR_SECONDARY=$i
[[ -z $MIRROR_PRIMARY ]] && MIRROR_PRIMARY=$i
done
if [[ -z $MIRROR_SECONDARY ]]; then
# We need to repartition the single disk to two slices
SINGLE_DISK=$MIRROR_PRIMARY
MIRROR_SECONDARY=$MIRROR_PRIMARY
SIDE_PRIMARY_PART=0
SIDE_SECONDARY_PART=1
if is_linux; then
if is_mpath_device $SINGLE_DISK; then
export DEV_DSKDIR=$DEV_MPATHDIR
else
export DEV_DSKDIR=$DEV_RDSKDIR
fi
if ( is_mpath_device $SINGLE_DISK ) && [[ -z $(echo $SINGLE_DISK | awk 'substr($1,18,1)\
~ /^[[:digit:]]+$/') ]] || ( is_real_device $SINGLE_DISK ); then
SIDE_PRIMARY=${SINGLE_DISK}1
SIDE_SECONDARY=${SINGLE_DISK}2
elif ( is_mpath_device $SINGLE_DISK || is_loop_device $SINGLE_DISK ); then
SIDE_PRIMARY=${SINGLE_DISK}p1
SIDE_SECONDARY=${SINGLE_DISK}p2
else
log_fail "$SINGLE_DISK not supported for partitioning."
fi
else
export DEV_DSKDIR="/dev"
SIDE_PRIMARY=${SINGLE_DISK}s${SIDE_PRIMARY_PART}
SIDE_SECONDARY=${SINGLE_DISK}s${SIDE_SECONDARY_PART}
fi
else
SIDE_PRIMARY_PART=0
SIDE_SECONDARY_PART=0
if is_linux; then
if is_mpath_device $MIRROR_PRIMARY; then
export DEV_DSKDIR=$DEV_MPATHDIR
else
export DEV_DSKDIR=$DEV_RDSKDIR
fi
if ( is_mpath_device $MIRROR_PRIMARY ) && [[ -z $(echo $MIRROR_PRIMARY | awk 'substr($1,18,1)\
~ /^[[:digit:]]+$/') ]] || ( is_real_device $MIRROR_PRIMARY ); then
SIDE_PRIMARY=${MIRROR_PRIMARY}1
elif ( is_mpath_device $MIRROR_PRIMARY || is_loop_device $MIRROR_PRIMARY ); then
SIDE_PRIMARY=${MIRROR_PRIMARY}p1
else
log_fail "$MIRROR_PRIMARY not supported for partitioning."
fi
if ( is_mpath_device $MIRROR_SECONDARY ) && [[ -z $(echo $MIRROR_SECONDARY | awk 'substr($1,18,1)\
~ /^[[:digit:]]+$/') ]] || ( is_real_device $MIRROR_SECONDARY ); then
SIDE_SECONDARY=${MIRROR_SECONDARY}1
elif ( is_mpath_device $MIRROR_SECONDARY || is_loop_device $MIRROR_SECONDARY ); then
SIDE_SECONDARY=${MIRROR_SECONDARY}p1
else
log_fail "$MIRROR_SECONDARY not supported for partitioning."
fi
else
export DEV_DSKDIR="/dev"
SIDE_PRIMARY=${MIRROR_PRIMARY}s${SIDE_PRIMARY_PART}
SIDE_SECONDARY=${MIRROR_SECONDARY}s${SIDE_SECONDARY_PART}
fi
fi
export MIRROR_PRIMARY MIRROR_SECONDARY SINGLE_DISK SIDE_PRIMARY SIDE_SECONDARY
export FILE_COUNT=10 export FILE_COUNT=10
export FILE_SIZE=$(( 1024 * 1024 )) export FILE_SIZE=$(( 1024 * 1024 ))
export MIRROR_MEGS=100
export MIRROR_SIZE=${MIRROR_MEGS}m # default mirror size
export DD_BLOCK=$(( 64 * 1024 )) export DD_BLOCK=$(( 64 * 1024 ))
export DD_COUNT=$(( MIRROR_MEGS * 1024 * 1024 / DD_BLOCK )) export DD_COUNT=$(( MINVDEVSIZE / DD_BLOCK ))

View File

@ -34,19 +34,8 @@
verify_runnable "global" verify_runnable "global"
if ! is_physical_device $DISKS; then log_must mkdir -p $SIDE_DIR
log_unsupported "This directory cannot be run on raw files." log_must truncate -s $MINVDEVSIZE $SIDE_PRIMARY $SIDE_SECONDARY
fi
if [[ -n $SINGLE_DISK ]]; then
log_note "Partitioning a single disk ($SINGLE_DISK)"
else
log_note "Partitioning disks ($MIRROR_PRIMARY $MIRROR_SECONDARY)"
fi
log_must set_partition $SIDE_PRIMARY_PART "" $MIRROR_SIZE $MIRROR_PRIMARY
log_must set_partition $SIDE_SECONDARY_PART "" $MIRROR_SIZE $MIRROR_SECONDARY
default_mirror_setup $SIDE_PRIMARY $SIDE_SECONDARY default_mirror_setup $SIDE_PRIMARY $SIDE_SECONDARY
log_pass log_pass

View File

@ -35,21 +35,8 @@
verify_runnable "global" verify_runnable "global"
df -F zfs -h | grep "$TESTFS " >/dev/null
[[ $? == 0 ]] && log_must zfs umount -f $TESTDIR
destroy_pool $TESTPOOL destroy_pool $TESTPOOL
log_must rm -f $SIDE_PRIMARY $SIDE_SECONDARY
DISK=${DISKS%% *} log_must rmdir $SIDE_DIR
if is_mpath_device $DISK; then
delete_partitions
fi
# recreate and destroy a zpool over the disks to restore the partitions to
# normal
if [[ -n $SINGLE_DISK ]]; then
log_must cleanup_devices $MIRROR_PRIMARY
else
log_must cleanup_devices $MIRROR_PRIMARY $MIRROR_SECONDARY
fi
log_pass log_pass

View File

@ -28,80 +28,10 @@
# Copyright (c) 2013 by Delphix. All rights reserved. # Copyright (c) 2013 by Delphix. All rights reserved.
# #
export DISKSARRAY=$DISKS export SIDE_DIR="${TEST_BASE_DIR}/scrub_mirror"
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') export SIDE_PRIMARY="${SIDE_DIR}/dev1"
export SIDE_SECONDARY="${SIDE_DIR}/dev2"
typeset -i NUMBER_OF_DISKS=0
for i in $DISKS; do
[[ -n $MIRROR_PRIMARY ]] && MIRROR_SECONDARY=$i
[[ -z $MIRROR_PRIMARY ]] && MIRROR_PRIMARY=$i
done
if [[ -z $MIRROR_SECONDARY ]]; then
# We need to repartition the single disk to two slices
SINGLE_DISK=$MIRROR_PRIMARY
MIRROR_SECONDARY=$MIRROR_PRIMARY
SIDE_PRIMARY_PART=0
SIDE_SECONDARY_PART=1
if is_linux; then
if is_mpath_device $MIRROR_PRIMARY; then
export DEV_DSKDIR=$DEV_MPATHDIR
else
export DEV_DSKDIR=$DEV_RDSKDIR
fi
if ( is_mpath_device $SINGLE_DISK ) && [[ -z $(echo $SINGLE_DISK | awk 'substr($1,18,1)\
~ /^[[:digit:]]+$/') ]] || ( is_real_device $SINGLE_DISK ); then
SIDE_PRIMARY=${SINGLE_DISK}1
SIDE_SECONDARY=${SINGLE_DISK}2
elif ( is_mpath_device $SINGLE_DISK || is_loop_device $SINGLE_DISK ); then
SIDE_PRIMARY=${SINGLE_DISK}p1
SIDE_SECONDARY=${SINGLE_DISK}p2
else
log_fail "$SINGLE_DISK not supported for partitioning."
fi
else
export DEV_DSKDIR="/dev"
SIDE_PRIMARY=${SINGLE_DISK}s${SIDE_PRIMARY_PART}
SIDE_SECONDARY=${SINGLE_DISK}s${SIDE_SECONDARY_PART}
fi
else
SIDE_PRIMARY_PART=0
SIDE_SECONDARY_PART=0
if is_linux; then
if is_mpath_device $MIRROR_PRIMARY; then
export DEV_DSKDIR=$DEV_MPATHDIR
else
export DEV_DSKDIR=$DEV_RDSKDIR
fi
if ( is_mpath_device $MIRROR_PRIMARY ) && [[ -z $(echo $MIRROR_PRIMARY | awk 'substr($1,18,1)\
~ /^[[:digit:]]+$/') ]] || ( is_real_device $MIRROR_PRIMARY ); then
SIDE_PRIMARY=${MIRROR_PRIMARY}1
elif ( is_mpath_device $MIRROR_PRIMARY || is_loop_device $MIRROR_PRIMARY ); then
SIDE_PRIMARY=${MIRROR_PRIMARY}p1
else
log_fail "$MIRROR_PRIMARY not supported for partitioning."
fi
if ( is_mpath_device $MIRROR_SECONDARY ) && [[ -z $(echo $MIRROR_SECONDARY | awk 'substr($1,18,1)\
~ /^[[:digit:]]+$/') ]] || ( is_real_device $MIRROR_SECONDARY ); then
SIDE_SECONDARY=${MIRROR_SECONDARY}1
elif ( is_mpath_device $MIRROR_SECONDARY || is_loop_device $MIRROR_SECONDARY ); then
SIDE_SECONDARY=${MIRROR_SECONDARY}p1
else
log_fail "$MIRROR_SECONDARY not supported for partitioning."
fi
else
export DEV_DSKDIR="/dev"
SIDE_PRIMARY=${MIRROR_PRIMARY}s${SIDE_PRIMARY_PART}
SIDE_SECONDARY=${MIRROR_SECONDARY}s${SIDE_SECONDARY_PART}
fi
fi
export MIRROR_PRIMARY MIRROR_SECONDARY SINGLE_DISK SIDE_PRIMARY SIDE_SECONDARY
export FILE_COUNT=10 export FILE_COUNT=10
export FILE_SIZE=$(( 1024 * 1024 )) export FILE_SIZE=$(( 1024 * 1024 ))
export MIRROR_MEGS=100
export MIRROR_SIZE=${MIRROR_MEGS}m # default mirror size
export DD_BLOCK=$(( 64 * 1024 )) export DD_BLOCK=$(( 64 * 1024 ))
export DD_COUNT=$(( MIRROR_MEGS * 1024 * 1024 / DD_BLOCK )) export DD_COUNT=$(( MINVDEVSIZE / DD_BLOCK ))

View File

@ -48,6 +48,6 @@ verify_runnable "global"
log_assert "The primary side of a zpool mirror may be completely wiped" \ log_assert "The primary side of a zpool mirror may be completely wiped" \
"without affecting the content of the pool" "without affecting the content of the pool"
overwrite_verify_mirror $TESTPOOL $SIDE_PRIMARY /dev/zero overwrite_verify_mirror $SIDE_PRIMARY /dev/zero
log_pass "The overwrite had no effect on the data" log_pass "The overwrite had no effect on the data"

View File

@ -48,6 +48,6 @@ verify_runnable "global"
log_assert "The primary side of a zpool mirror may be completely wiped" \ log_assert "The primary side of a zpool mirror may be completely wiped" \
"without affecting the content of the pool" "without affecting the content of the pool"
overwrite_verify_mirror $TESTPOOL $SIDE_SECONDARY /dev/zero overwrite_verify_mirror $SIDE_SECONDARY /dev/zero
log_pass "The overwrite had no effect on the data" log_pass "The overwrite had no effect on the data"

View File

@ -48,6 +48,6 @@ verify_runnable "global"
log_assert "The primary side of a zpool mirror may be completely mangled" \ log_assert "The primary side of a zpool mirror may be completely mangled" \
"without affecting the content of the pool" "without affecting the content of the pool"
overwrite_verify_mirror $TESTPOOL $SIDE_PRIMARY /dev/urandom overwrite_verify_mirror $SIDE_PRIMARY /dev/urandom
log_pass "The overwrite did not have any effect on the data" log_pass "The overwrite did not have any effect on the data"

View File

@ -48,6 +48,6 @@ verify_runnable "global"
log_assert "The primary side of a zpool mirror may be completely mangled" \ log_assert "The primary side of a zpool mirror may be completely mangled" \
"without affecting the content of the pool" "without affecting the content of the pool"
overwrite_verify_mirror $TESTPOOL $SIDE_SECONDARY /dev/urandom overwrite_verify_mirror $SIDE_SECONDARY /dev/urandom
log_pass "The overwrite had no effect on the data" log_pass "The overwrite had no effect on the data"

View File

@ -27,13 +27,14 @@
# #
# Copyright (c) 2013, 2016 by Delphix. All rights reserved. # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
# #
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/scrub_mirror/default.cfg . $STF_SUITE/tests/functional/scrub_mirror/default.cfg
function overwrite_verify_mirror function overwrite_verify_mirror
{ {
typeset POOL=$1 typeset AFFECTED_DEVICE=$1
typeset AFFECTED_DEVICE=$2 typeset OVERWRITING_DEVICE=$2
typeset OVERWRITING_DEVICE=$3
typeset atfile=0 typeset atfile=0
set -A files set -A files
@ -49,14 +50,11 @@ function overwrite_verify_mirror
done done
# dd the affected side of the mirror # dd the affected side of the mirror
log_must dd if=$OVERWRITING_DEVICE of=${DEV_DSKDIR}/$AFFECTED_DEVICE \ log_must dd if=$OVERWRITING_DEVICE of=$AFFECTED_DEVICE \
seek=8 bs=$DD_BLOCK count=$(( DD_COUNT - 128 )) conv=notrunc seek=8 bs=$DD_BLOCK count=$(( DD_COUNT - 128 )) conv=notrunc
log_must zpool scrub $POOL log_must zpool scrub $TESTPOOL
log_must wait_scrubbed $TESTPOOL
while is_pool_scrubbing $POOL; do
sleep 2
done
atfile=0 atfile=0

View File

@ -29,22 +29,13 @@
# Copyright (c) 2013 by Delphix. All rights reserved. # Copyright (c) 2013 by Delphix. All rights reserved.
# #
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/scrub_mirror/default.cfg . $STF_SUITE/tests/functional/scrub_mirror/default.cfg
. $STF_SUITE/include/libtest.shlib
verify_runnable "global" verify_runnable "global"
if ! $(is_physical_device $DISKS) ; then log_must mkdir -p $SIDE_DIR
log_unsupported "This directory cannot be run on raw files." log_must truncate -s $MINVDEVSIZE $SIDE_PRIMARY $SIDE_SECONDARY
fi
if [[ -n $SINGLE_DISK ]]; then
log_note "Partitioning a single disk ($SINGLE_DISK)"
else
log_note "Partitioning disks ($MIRROR_PRIMARY $MIRROR_SECONDARY)"
fi
log_must set_partition $SIDE_PRIMARY_PART "" $MIRROR_SIZE $MIRROR_PRIMARY
log_must set_partition $SIDE_SECONDARY_PART "" $MIRROR_SIZE $MIRROR_SECONDARY
default_mirror_setup $SIDE_PRIMARY $SIDE_SECONDARY default_mirror_setup $SIDE_PRIMARY $SIDE_SECONDARY