aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWill Andrews <[email protected]>2021-01-26 15:14:04 -0600
committerGitHub <[email protected]>2021-01-26 13:14:04 -0800
commitd7265b330954fe844958642c5f61e790c58442d5 (patch)
tree2fba4bcf9456a32fedf4dfb89cdd6137f48b9e7b /tests
parentcaedada66e1cb503a2e1d5af6e93280f88d913a5 (diff)
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 <[email protected]> Signed-off-by: Will Andrews <[email protected]> Closes #11518
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_export/setup.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg37
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.kshlib32
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_001_pos.ksh17
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh13
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_003_neg.ksh15
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_004_pos.ksh21
8 files changed, 53 insertions, 89 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am
index 86452e8ac..1c06d5b59 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am
@@ -8,4 +8,5 @@ dist_pkgdata_SCRIPTS = \
zpool_export_004_pos.ksh
dist_pkgdata_DATA = \
- zpool_export.cfg
+ zpool_export.cfg \
+ zpool_export.kshlib
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_export/setup.ksh
index 664fb2ddd..023920dae 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/setup.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/setup.ksh
@@ -30,8 +30,4 @@
DISK=${DISKS%% *}
-if ! is_physical_device $DISK; then
- log_unsupported "Only partitionable physical disks can be used"
-fi
-
default_setup $DISK
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg
index 1501c0463..8bfb067c7 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg
@@ -30,30 +30,15 @@
. $STF_SUITE/include/libtest.shlib
-export DISK_ARRAY_NUM=0
-export DISK_ARRAY_LIMIT=4
-export DISKSARRAY=""
-export VDEVS_NUM=32
+export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
+export DISK1=$(echo $DISKS | awk '{print $1}')
+export DISK2=$(echo $DISKS | awk '{print $3}')
-function set_disks
-{
- typeset -a disk_array=($(find_disks $DISKS))
-
- if (( ${#disk_array[*]} <= 1 )); then
- export DISK=${DISKS%% *}
- else
- export DISK=""
- 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
+if is_linux; then
+ set_slice_prefix
+ set_device_dir
+ devs_id[0]=$(get_persistent_disk_name $DISK1)
+ devs_id[1]=$(get_persistent_disk_name $DISK2)
+else
+ DEV_DSKDIR="/dev"
+fi
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.kshlib
new file mode 100644
index 000000000..5484f2067
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.kshlib
@@ -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
+}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_001_pos.ksh
index b6823553d..111453c7a 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_001_pos.ksh
@@ -29,8 +29,7 @@
# Copyright (c) 2016 by Delphix. All rights reserved.
#
-. $STF_SUITE/include/libtest.shlib
-. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.cfg
+. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.kshlib
#
# DESCRIPTION:
@@ -46,19 +45,7 @@
verify_runnable "global"
-function 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_onexit zpool_export_cleanup
log_assert "Verify a pool can be exported."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh
index 81473d903..8040d12b9 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh
@@ -29,7 +29,7 @@
# 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:
@@ -45,19 +45,10 @@ verify_runnable "global"
function cleanup
{
- typeset dir=$(get_device_dir $DISKS)
cd $olddir || \
log_fail "Couldn't cd back to $olddir"
- datasetexists "$TESTPOOL/$TESTFS" || \
- 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
+ zpool_export_cleanup
}
olddir=$PWD
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_003_neg.ksh
index b188f9c33..a2ee7fbdf 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_003_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_003_neg.ksh
@@ -29,7 +29,7 @@
# 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:
@@ -43,18 +43,7 @@
verify_runnable "global"
-function 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_onexit zpool_export_cleanup
set -A args "" "-f" "-? $TESTPOOL" "-QWERTYUIO $TESTPOOL"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_004_pos.ksh
index 0f1a7c624..9be3f23c4 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_004_pos.ksh
@@ -29,7 +29,7 @@
# 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:
@@ -50,25 +50,8 @@
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_onexit cleanup
+log_onexit zpool_export_cleanup
mntpnt=$TESTDIR0
log_must mkdir -p $mntpnt