ZTS: Cleanup some cleanup functions

Cleanup functions should make a best effort to clean up as much as
possible.

Do a consistency pass in a bunch of tests to make the cleanup
functions less prone to failure and fix a few typos here and there.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9993
This commit is contained in:
Ryan Moeller 2020-02-13 15:05:32 -05:00 committed by GitHub
parent 523bc0d548
commit 5ceccda5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 41 additions and 67 deletions

View File

@ -43,7 +43,7 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL && destroy_pool $TESTPOOL
log_must rm -f $disk1 $disk2
rm -f $disk1 $disk2
}
log_assert "zpool add -o ashift=<n>' works with different ashift values"

View File

@ -42,8 +42,7 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
log_must rm -f $disk1
log_must rm -f $disk2
rm -f $disk1 $disk2
}
log_assert "zpool attach -o ashift=<n>' works with different ashift values"

View File

@ -44,8 +44,8 @@ verify_runnable "global"
function cleanup
{
destroy_pool $TESTPOOL
log_must rm -f $disk
poolexists $TESTPOOL && destroy_pool $TESTPOOL
rm -f $disk
}
#

View File

@ -47,7 +47,8 @@ verify_runnable "global"
function cleanup
{
[[ -e $tmpfile ]] && log_must rm -f $tmpfile
poolexists $TESTPOOL && destroy_pool $TESTPOOL
rm -f $tmpfile
}
tmpfile="$TEST_BASE_DIR/zpool_create_003.tmp$$"

View File

@ -45,12 +45,10 @@ verify_runnable "global"
function cleanup
{
typeset pool=""
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
poolexists $TESTPOOL && destroy_pool $TESTPOOL
[[ -d $TESTDIR ]] && log_must rm -rf $TESTDIR
rm -rf $TESTDIR
partition_disk $SIZE $disk 6
}

View File

@ -46,12 +46,8 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL && \
log_must zpool destroy -f $TESTPOOL
for dir in $TESTDIR $TESTDIR1; do
[[ -d $dir ]] && rm -rf $dir
done
poolexists $TESTPOOL && destroy_pool $TESTPOOL
rm -rf $TESTDIR $TESTDIR1
}
log_assert "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create" \
@ -64,13 +60,11 @@ set -A pooltype "" "mirror" "raidz" "raidz1" "raidz2"
# cleanup the pools created in previous case if zpool_create_004_pos timedout
#
for pool in $TESTPOOL2 $TESTPOOL1 $TESTPOOL; do
if poolexists $pool; then
destroy_pool $pool
fi
poolexists $pool && destroy_pool $pool
done
#prepare raw file for file disk
[[ -d $TESTDIR ]] && rm -rf $TESTDIR
rm -rf $TESTDIR
log_must mkdir -p $TESTDIR
typeset -i i=1
while (( i < 4 )); do
@ -80,7 +74,7 @@ while (( i < 4 )); do
done
#Remove the directory with name as pool name if it exists
[[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
rm -rf /$TESTPOOL
file=$TESTDIR/file
for opt in "-R $TESTDIR1" "-m $TESTDIR1" \

View File

@ -46,8 +46,8 @@ verify_runnable "global"
function cleanup
{
datasetexists $TESTPOOL1 && destroy_pool $TESTPOOL1
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}

View File

@ -48,12 +48,13 @@ verify_runnable "global"
function cleanup
{
poolexists $TOOSMALL && destroy_pool $TOOSMALL
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
typeset pool
poolexists $TESTPOOL && destroy_pool $TESTPOOL
for pool in $TOOSMALL $TESTPOOL1 $TESTPOOL; do
poolexists $pool && destroy_pool $pool
done
[[ -d $TESTDIR ]] && rm -rf $TESTDIR
rm -rf $TESTDIR
partition_disk $SIZE $disk 6
}

View File

@ -47,9 +47,7 @@ verify_runnable "global"
function cleanup
{
if poolexists $TESTPOOL; then
destroy_pool $TESTPOOL
fi
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
if is_linux; then

View File

@ -54,9 +54,7 @@ function cleanup
zfs destroy $vol_name
fi
if poolexists $TESTPOOL; then
destroy_pool $TESTPOOL
fi
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_assert "'zpool create' should fail with regular file in swap."

View File

@ -56,9 +56,7 @@ function cleanup
fi
for pool in $TESTPOOL1 $TESTPOOL; do
if poolexists $pool; then
destroy_pool $pool
fi
poolexists $pool && destroy_pool $pool
done
}

View File

@ -48,9 +48,7 @@ verify_runnable "global"
function cleanup
{
if poolexists $TESTPOOL; then
destroy_pool $TESTPOOL
fi
poolexists $TESTPOOL && destroy_pool $TESTPOOL
#recover swap devices
FSTAB=$TEST_BASE_DIR/fstab_$$

View File

@ -47,13 +47,8 @@ verify_runnable "global"
function cleanup
{
if poolexists $TESTPOOL; then
destroy_pool $TESTPOOL
fi
if [[ -d $TESTDIR ]]; then
log_must rm -rf $TESTDIR
fi
poolexists $TESTPOOL && destroy_pool $TESTPOOL
rm -rf $TESTDIR
}
if [[ -n $DISK ]]; then

View File

@ -47,7 +47,7 @@
function cleanup
{
poolexists $TESTPOOL && destroy_pool $TESTPOOL
[[ -f $CPATH ]] && log_must rm $CPATH
rm -f $CPATH
}
log_onexit cleanup

View File

@ -43,9 +43,7 @@
function cleanup
{
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_onexit cleanup

View File

@ -46,14 +46,9 @@
function cleanup
{
if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi
if [ -d /${TESTPOOL}.root ]
then
log_must rmdir /${TESTPOOL}.root
fi
[[ -e $values ]] && log_must rm -f $values
poolexists $TESTPOOL && destroy_pool $TESTPOOL
rm -rf /${TESTPOOL}.root
rm -f $values
}
log_onexit cleanup
@ -69,11 +64,11 @@ else
fi
log_must rm -f /etc/zfs/zpool.cache
log_must mkdir /${TESTPOOL}.root
log_must rm -rf /${TESTPOOL}.root
log_must zpool create -R /${TESTPOOL}.root $TESTPOOL $disk
if [ ! -d /${TESTPOOL}.root ]
then
log_fail "Mountpoint was not create when using zpool with -R flag!"
log_fail "Mountpoint was not created when using zpool with -R flag!"
fi
FS=$(zfs list $TESTPOOL)

View File

@ -48,7 +48,7 @@ verify_runnable "global"
function cleanup
{
datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_onexit cleanup

View File

@ -45,7 +45,7 @@ verify_runnable "global"
function cleanup
{
datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_onexit cleanup

View File

@ -30,9 +30,11 @@ verify_runnable "global"
function cleanup
{
destroy_pool $TESTPOOL
destroy_pool $TEMPPOOL
typeset pool
for pool in $TESTPOOL $TEMPPOOL; do
poolexists $pool && destroy_pool $pool
done
}
log_assert "'zpool create -t <tempname>' can create a pool with the specified" \

View File

@ -42,8 +42,7 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
log_must rm -f $disk1
log_must rm -f $disk2
rm -f $disk1 $disk2
}
log_assert "zpool replace -o ashift=<n>' works with different ashift values"

View File

@ -44,7 +44,7 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
log_must rm -f $disk1 $disk2
rm -f $disk1 $disk2
}
log_assert "'zpool replace' uses the ashift pool property value as default."

View File

@ -44,7 +44,7 @@ verify_runnable "both"
function cleanup
{
log_must zpool destroy $TESTPOOL1
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
}
log_onexit cleanup