ZTS: zpool_export test improvements
- refactor cleanup routines into common kshlib zpool_export_cleanup func - don't require physical disks to test, just use files Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Will Andrews <will@firepipe.net> Closes #11518
This commit is contained in:
parent
caedada66e
commit
d7265b3309
|
@ -8,4 +8,5 @@ dist_pkgdata_SCRIPTS = \
|
||||||
zpool_export_004_pos.ksh
|
zpool_export_004_pos.ksh
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
dist_pkgdata_DATA = \
|
||||||
zpool_export.cfg
|
zpool_export.cfg \
|
||||||
|
zpool_export.kshlib
|
||||||
|
|
|
@ -30,8 +30,4 @@
|
||||||
|
|
||||||
DISK=${DISKS%% *}
|
DISK=${DISKS%% *}
|
||||||
|
|
||||||
if ! is_physical_device $DISK; then
|
|
||||||
log_unsupported "Only partitionable physical disks can be used"
|
|
||||||
fi
|
|
||||||
|
|
||||||
default_setup $DISK
|
default_setup $DISK
|
||||||
|
|
|
@ -30,30 +30,15 @@
|
||||||
|
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
|
||||||
export DISK_ARRAY_NUM=0
|
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
|
||||||
export DISK_ARRAY_LIMIT=4
|
export DISK1=$(echo $DISKS | awk '{print $1}')
|
||||||
export DISKSARRAY=""
|
export DISK2=$(echo $DISKS | awk '{print $3}')
|
||||||
export VDEVS_NUM=32
|
|
||||||
|
|
||||||
function set_disks
|
if is_linux; then
|
||||||
{
|
set_slice_prefix
|
||||||
typeset -a disk_array=($(find_disks $DISKS))
|
set_device_dir
|
||||||
|
devs_id[0]=$(get_persistent_disk_name $DISK1)
|
||||||
if (( ${#disk_array[*]} <= 1 )); then
|
devs_id[1]=$(get_persistent_disk_name $DISK2)
|
||||||
export DISK=${DISKS%% *}
|
else
|
||||||
else
|
DEV_DSKDIR="/dev"
|
||||||
export DISK=""
|
fi
|
||||||
typeset -i i=0
|
|
||||||
while (( i < ${#disk_array[*]} )); do
|
|
||||||
export DISK${i}="${disk_array[$i]}"
|
|
||||||
DISKSARRAY="$DISKSARRAY ${disk_array[$i]}"
|
|
||||||
(( i = i + 1 ))
|
|
||||||
(( i>$DISK_ARRAY_LIMIT )) && break
|
|
||||||
done
|
|
||||||
export DISK_ARRAY_NUM=$i
|
|
||||||
export DISKSARRAY
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_disks
|
|
||||||
set_device_dir
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#
|
||||||
|
# CDDL HEADER START
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the terms of the
|
||||||
|
# Common Development and Distribution License (the "License").
|
||||||
|
# You may not use this file except in compliance with the License.
|
||||||
|
#
|
||||||
|
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
# or http://www.opensolaris.org/os/licensing.
|
||||||
|
# See the License for the specific language governing permissions
|
||||||
|
# and limitations under the License.
|
||||||
|
#
|
||||||
|
# When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
# If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
#
|
||||||
|
# CDDL HEADER END
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, Klara Systems, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.cfg
|
||||||
|
|
||||||
|
function zpool_export_cleanup
|
||||||
|
{
|
||||||
|
[[ -d $TESTDIR0 ]] && log_must rm -rf $TESTDIR0
|
||||||
|
default_cleanup
|
||||||
|
}
|
|
@ -29,8 +29,7 @@
|
||||||
# Copyright (c) 2016 by Delphix. All rights reserved.
|
# Copyright (c) 2016 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.kshlib
|
||||||
. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.cfg
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
|
@ -46,19 +45,7 @@
|
||||||
|
|
||||||
verify_runnable "global"
|
verify_runnable "global"
|
||||||
|
|
||||||
function cleanup
|
log_onexit zpool_export_cleanup
|
||||||
{
|
|
||||||
typeset dir=$(get_device_dir $DISKS)
|
|
||||||
|
|
||||||
datasetexists "$TESTPOOL/$TESTFS" || \
|
|
||||||
log_must zpool import -d $dir $TESTPOOL
|
|
||||||
|
|
||||||
ismounted "$TESTPOOL/$TESTFS"
|
|
||||||
(( $? != 0 )) && \
|
|
||||||
log_must zfs mount $TESTPOOL/$TESTFS
|
|
||||||
}
|
|
||||||
|
|
||||||
log_onexit cleanup
|
|
||||||
|
|
||||||
log_assert "Verify a pool can be exported."
|
log_assert "Verify a pool can be exported."
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
# Copyright (c) 2016 by Delphix. All rights reserved.
|
# Copyright (c) 2016 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.kshlib
|
||||||
|
|
||||||
#
|
#
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
|
@ -45,19 +45,10 @@ verify_runnable "global"
|
||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
typeset dir=$(get_device_dir $DISKS)
|
|
||||||
cd $olddir || \
|
cd $olddir || \
|
||||||
log_fail "Couldn't cd back to $olddir"
|
log_fail "Couldn't cd back to $olddir"
|
||||||
|
|
||||||
datasetexists "$TESTPOOL/$TESTFS" || \
|
zpool_export_cleanup
|
||||||
log_must zpool import -d $dir $TESTPOOL
|
|
||||||
|
|
||||||
ismounted "$TESTPOOL/$TESTFS"
|
|
||||||
(( $? != 0 )) && \
|
|
||||||
log_must zfs mount $TESTPOOL/$TESTFS
|
|
||||||
|
|
||||||
[[ -e $TESTDIR/$TESTFILE0 ]] && \
|
|
||||||
log_must rm -rf $TESTDIR/$TESTFILE0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
olddir=$PWD
|
olddir=$PWD
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
# Copyright (c) 2016 by Delphix. All rights reserved.
|
# Copyright (c) 2016 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.kshlib
|
||||||
|
|
||||||
#
|
#
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
|
@ -43,18 +43,7 @@
|
||||||
|
|
||||||
verify_runnable "global"
|
verify_runnable "global"
|
||||||
|
|
||||||
function cleanup
|
log_onexit zpool_export_cleanup
|
||||||
{
|
|
||||||
typeset dir=$(get_device_dir $DISKS)
|
|
||||||
datasetexists "$TESTPOOL/$TESTFS" || \
|
|
||||||
log_must zpool import -d $dir $TESTPOOL
|
|
||||||
|
|
||||||
ismounted "$TESTPOOL/$TESTFS"
|
|
||||||
(( $? != 0 )) && \
|
|
||||||
log_must zfs mount $TESTPOOL/$TESTFS
|
|
||||||
}
|
|
||||||
|
|
||||||
log_onexit cleanup
|
|
||||||
|
|
||||||
set -A args "" "-f" "-? $TESTPOOL" "-QWERTYUIO $TESTPOOL"
|
set -A args "" "-f" "-? $TESTPOOL" "-QWERTYUIO $TESTPOOL"
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.kshlib
|
||||||
|
|
||||||
#
|
#
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
|
@ -50,25 +50,8 @@
|
||||||
|
|
||||||
verify_runnable "global"
|
verify_runnable "global"
|
||||||
|
|
||||||
function cleanup
|
|
||||||
{
|
|
||||||
mntpnt=$TESTDIR0
|
|
||||||
datasetexists $TESTPOOL1 || log_must zpool import -d $mntpnt $TESTPOOL1
|
|
||||||
datasetexists $TESTPOOL1 && destroy_pool $TESTPOOL1
|
|
||||||
datasetexists $TESTPOOL2 && destroy_pool $TESTPOOL2
|
|
||||||
typeset -i i=0
|
|
||||||
while ((i < 5)); do
|
|
||||||
if [[ -e $mntpnt/vdev$i ]]; then
|
|
||||||
log_must rm -f $mntpnt/vdev$i
|
|
||||||
fi
|
|
||||||
((i += 1))
|
|
||||||
done
|
|
||||||
log_must rmdir $mntpnt
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
log_assert "Verify zpool export succeed or fail with spare."
|
log_assert "Verify zpool export succeed or fail with spare."
|
||||||
log_onexit cleanup
|
log_onexit zpool_export_cleanup
|
||||||
|
|
||||||
mntpnt=$TESTDIR0
|
mntpnt=$TESTDIR0
|
||||||
log_must mkdir -p $mntpnt
|
log_must mkdir -p $mntpnt
|
||||||
|
|
Loading…
Reference in New Issue