mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
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:
parent
523bc0d548
commit
5ceccda5cb
@ -43,7 +43,7 @@ verify_runnable "global"
|
|||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
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"
|
log_assert "zpool add -o ashift=<n>' works with different ashift values"
|
||||||
|
@ -42,8 +42,7 @@ verify_runnable "global"
|
|||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||||
log_must rm -f $disk1
|
rm -f $disk1 $disk2
|
||||||
log_must rm -f $disk2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "zpool attach -o ashift=<n>' works with different ashift values"
|
log_assert "zpool attach -o ashift=<n>' works with different ashift values"
|
||||||
|
@ -44,8 +44,8 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
destroy_pool $TESTPOOL
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
log_must rm -f $disk
|
rm -f $disk
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -47,7 +47,8 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
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$$"
|
tmpfile="$TEST_BASE_DIR/zpool_create_003.tmp$$"
|
||||||
|
@ -45,12 +45,10 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
typeset pool=""
|
|
||||||
|
|
||||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||||
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
|
|
||||||
[[ -d $TESTDIR ]] && log_must rm -rf $TESTDIR
|
rm -rf $TESTDIR
|
||||||
partition_disk $SIZE $disk 6
|
partition_disk $SIZE $disk 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,8 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TESTPOOL && \
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
log_must zpool destroy -f $TESTPOOL
|
rm -rf $TESTDIR $TESTDIR1
|
||||||
|
|
||||||
for dir in $TESTDIR $TESTDIR1; do
|
|
||||||
[[ -d $dir ]] && rm -rf $dir
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create" \
|
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
|
# cleanup the pools created in previous case if zpool_create_004_pos timedout
|
||||||
#
|
#
|
||||||
for pool in $TESTPOOL2 $TESTPOOL1 $TESTPOOL; do
|
for pool in $TESTPOOL2 $TESTPOOL1 $TESTPOOL; do
|
||||||
if poolexists $pool; then
|
poolexists $pool && destroy_pool $pool
|
||||||
destroy_pool $pool
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#prepare raw file for file disk
|
#prepare raw file for file disk
|
||||||
[[ -d $TESTDIR ]] && rm -rf $TESTDIR
|
rm -rf $TESTDIR
|
||||||
log_must mkdir -p $TESTDIR
|
log_must mkdir -p $TESTDIR
|
||||||
typeset -i i=1
|
typeset -i i=1
|
||||||
while (( i < 4 )); do
|
while (( i < 4 )); do
|
||||||
@ -80,7 +74,7 @@ while (( i < 4 )); do
|
|||||||
done
|
done
|
||||||
|
|
||||||
#Remove the directory with name as pool name if it exists
|
#Remove the directory with name as pool name if it exists
|
||||||
[[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
|
rm -rf /$TESTPOOL
|
||||||
file=$TESTDIR/file
|
file=$TESTDIR/file
|
||||||
|
|
||||||
for opt in "-R $TESTDIR1" "-m $TESTDIR1" \
|
for opt in "-R $TESTDIR1" "-m $TESTDIR1" \
|
||||||
|
@ -46,8 +46,8 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
datasetexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||||
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,12 +48,13 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TOOSMALL && destroy_pool $TOOSMALL
|
typeset pool
|
||||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
|
||||||
|
|
||||||
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
|
partition_disk $SIZE $disk 6
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,7 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
if poolexists $TESTPOOL; then
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
destroy_pool $TESTPOOL
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_linux; then
|
if is_linux; then
|
||||||
|
@ -54,9 +54,7 @@ function cleanup
|
|||||||
zfs destroy $vol_name
|
zfs destroy $vol_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if poolexists $TESTPOOL; then
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
destroy_pool $TESTPOOL
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "'zpool create' should fail with regular file in swap."
|
log_assert "'zpool create' should fail with regular file in swap."
|
||||||
|
@ -56,9 +56,7 @@ function cleanup
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for pool in $TESTPOOL1 $TESTPOOL; do
|
for pool in $TESTPOOL1 $TESTPOOL; do
|
||||||
if poolexists $pool; then
|
poolexists $pool && destroy_pool $pool
|
||||||
destroy_pool $pool
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,7 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
if poolexists $TESTPOOL; then
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
destroy_pool $TESTPOOL
|
|
||||||
fi
|
|
||||||
|
|
||||||
#recover swap devices
|
#recover swap devices
|
||||||
FSTAB=$TEST_BASE_DIR/fstab_$$
|
FSTAB=$TEST_BASE_DIR/fstab_$$
|
||||||
|
@ -47,13 +47,8 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
if poolexists $TESTPOOL; then
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
destroy_pool $TESTPOOL
|
rm -rf $TESTDIR
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $TESTDIR ]]; then
|
|
||||||
log_must rm -rf $TESTDIR
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n $DISK ]]; then
|
if [[ -n $DISK ]]; then
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
[[ -f $CPATH ]] && log_must rm $CPATH
|
rm -f $CPATH
|
||||||
}
|
}
|
||||||
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
@ -43,9 +43,7 @@
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
if poolexists $TESTPOOL ; then
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
destroy_pool $TESTPOOL
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
@ -46,14 +46,9 @@
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
if poolexists $TESTPOOL ; then
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
destroy_pool $TESTPOOL
|
rm -rf /${TESTPOOL}.root
|
||||||
fi
|
rm -f $values
|
||||||
if [ -d /${TESTPOOL}.root ]
|
|
||||||
then
|
|
||||||
log_must rmdir /${TESTPOOL}.root
|
|
||||||
fi
|
|
||||||
[[ -e $values ]] && log_must rm -f $values
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
@ -69,11 +64,11 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
log_must rm -f /etc/zfs/zpool.cache
|
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
|
log_must zpool create -R /${TESTPOOL}.root $TESTPOOL $disk
|
||||||
if [ ! -d /${TESTPOOL}.root ]
|
if [ ! -d /${TESTPOOL}.root ]
|
||||||
then
|
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
|
fi
|
||||||
|
|
||||||
FS=$(zfs list $TESTPOOL)
|
FS=$(zfs list $TESTPOOL)
|
||||||
|
@ -48,7 +48,7 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
}
|
}
|
||||||
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
@ -45,7 +45,7 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
|
poolexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||||
}
|
}
|
||||||
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
@ -30,9 +30,11 @@ verify_runnable "global"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
destroy_pool $TESTPOOL
|
typeset pool
|
||||||
destroy_pool $TEMPPOOL
|
|
||||||
|
|
||||||
|
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" \
|
log_assert "'zpool create -t <tempname>' can create a pool with the specified" \
|
||||||
|
@ -42,8 +42,7 @@ verify_runnable "global"
|
|||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||||
log_must rm -f $disk1
|
rm -f $disk1 $disk2
|
||||||
log_must rm -f $disk2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "zpool replace -o ashift=<n>' works with different ashift values"
|
log_assert "zpool replace -o ashift=<n>' works with different ashift values"
|
||||||
|
@ -44,7 +44,7 @@ verify_runnable "global"
|
|||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
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."
|
log_assert "'zpool replace' uses the ashift pool property value as default."
|
||||||
|
@ -44,7 +44,7 @@ verify_runnable "both"
|
|||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
log_must zpool destroy $TESTPOOL1
|
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
||||||
}
|
}
|
||||||
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user