summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/runfiles/linux.run5
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/Makefile.am1
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh2
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am5
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg26
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh68
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh74
-rwxr-xr-xtests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh2
9 files changed, 182 insertions, 3 deletions
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
index f28b18139..a358b5578 100644
--- a/tests/runfiles/linux.run
+++ b/tests/runfiles/linux.run
@@ -308,6 +308,11 @@ tests = ['zpool_import_001_pos',
'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos',
'zpool_import_rename_001_pos']
+[tests/functional/cli_root/zpool_labelclear]
+tests = ['zpool_labelclear_active', 'zpool_labelclear_exported']
+pre =
+post =
+
[tests/functional/cli_root/zpool_offline]
tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg']
diff --git a/tests/zfs-tests/tests/functional/cli_root/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/Makefile.am
index 5dc72de16..f2e3fd0df 100644
--- a/tests/zfs-tests/tests/functional/cli_root/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/Makefile.am
@@ -37,6 +37,7 @@ SUBDIRS = \
zpool_get \
zpool_history \
zpool_import \
+ zpool_labelclear \
zpool_offline \
zpool_online \
zpool_remove \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
index be415f137..6998a50cf 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
@@ -100,7 +100,7 @@ do
log_mustnot zpool add -o ashift="$badval" $disk2
log_must zpool destroy $TESTPOOL
log_must zpool labelclear $disk1
- log_must zpool labelclear $disk2
+ log_mustnot zpool labelclear $disk2
done
log_pass "zpool add -o ashift=<n>' works with different ashift values"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am
new file mode 100644
index 000000000..a8bea6864
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am
@@ -0,0 +1,5 @@
+pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_labelclear
+dist_pkgdata_SCRIPTS = \
+ labelclear.cfg \
+ zpool_labelclear_active.ksh \
+ zpool_labelclear_exported.ksh
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg
new file mode 100644
index 000000000..62d39b05f
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg
@@ -0,0 +1,26 @@
+#!/bin/ksh -p
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Nexenta Systems, Inc.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+typeset LABELCLEAR="zpool labelclear"
+typeset LABELREAD="zdb -lq"
+
+typeset disks=(${DISKS[*]})
+typeset disk1=${disks[0]}
+typeset disk2=${disks[1]}
+typeset disk3=${disks[2]}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh
new file mode 100755
index 000000000..8a30d1a42
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh
@@ -0,0 +1,68 @@
+#!/bin/ksh -p
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Nexenta Systems, Inc.
+#
+
+. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg
+
+# DESCRIPTION:
+# Check that zpool labelclear will refuse to clear the label
+# (with or without -f) on any vdevs of the imported pool.
+#
+# STRATEGY:
+# 1. Create the pool with log device.
+# 2. Try clearing the label on data and log devices.
+# 3. Add auxilary (cache/spare) vdevs.
+# 4. Try clearing the label on auxilary vdevs.
+# 5. Check that zpool labelclear will return non-zero and
+# labels are intact.
+
+verify_runnable "global"
+
+function cleanup
+{
+ poolexists $TESTPOOL && destroy_pool $TESTPOOL
+}
+
+log_onexit cleanup
+log_assert "zpool labelclear will fail on all vdevs of imported pool"
+
+# Create simple pool, skip any mounts
+log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2
+
+# Check that labelclear [-f] will fail on ACTIVE pool vdevs
+log_mustnot $LABELCLEAR $disk1
+log_must $LABELREAD $disk1
+log_mustnot $LABELCLEAR -f $disk1
+log_must $LABELREAD $disk1
+log_mustnot $LABELCLEAR $disk2
+log_must $LABELREAD $disk2
+log_mustnot $LABELCLEAR -f $disk2
+log_must $LABELREAD $disk2
+
+# Add a cache/spare to the pool, check that labelclear [-f] will fail
+# on the vdev and will succeed once it's removed from pool config
+for vdevtype in "cache" "spare"; do
+ log_must zpool add $TESTPOOL $vdevtype $disk3
+ log_mustnot $LABELCLEAR $disk3
+ log_must $LABELREAD $disk3
+ log_mustnot $LABELCLEAR -f $disk3
+ log_must $LABELREAD $disk3
+ log_must zpool remove $TESTPOOL $disk3
+ log_must $LABELCLEAR $disk3
+ log_mustnot $LABELREAD $disk3
+done
+
+log_pass "zpool labelclear will fail on all vdevs of imported pool"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh
new file mode 100755
index 000000000..98385c9b7
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh
@@ -0,0 +1,74 @@
+#!/bin/ksh -p
+#
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Nexenta Systems, Inc.
+#
+
+. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg
+
+# DESCRIPTION:
+# Check that zpool labelclear will refuse to clear the label
+# on ACTIVE vdevs of exported pool without -f, and will succeeded with -f.
+#
+# STRATEGY:
+# 1. Create a pool with log device.
+# 2. Export the pool.
+# 3. Check that zpool labelclear returns non-zero when trying to
+# clear the label on ACTIVE vdevs, and succeeds with -f.
+# 4. Add auxilary vdevs (cache/spare).
+# 5. Check that zpool labelclear succeeds on auxilary vdevs of
+# exported pool.
+
+verify_runnable "global"
+
+function cleanup
+{
+ poolexists $TESTPOOL && destroy_pool $TESTPOOL
+}
+
+log_onexit cleanup
+log_assert "zpool labelclear will fail on ACTIVE vdevs of exported pool and" \
+ "succeed with -f"
+
+for vdevtype in "" "cache" "spare"; do
+ # Create simple pool, skip any mounts
+ log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2
+ # Add auxilary vdevs (cache/spare)
+ if [[ -n $vdevtype ]]; then
+ log_must zpool add $TESTPOOL $vdevtype $disk3
+ fi
+ # Export the pool
+ log_must zpool export $TESTPOOL
+
+ # Check that labelclear will fail without -f
+ log_mustnot $LABELCLEAR $disk1
+ log_must $LABELREAD $disk1
+ log_mustnot $LABELCLEAR $disk2
+ log_must $LABELREAD $disk2
+
+ # Check that labelclear will succeed with -f
+ log_must $LABELCLEAR -f $disk1
+ log_mustnot $LABELREAD $disk1
+ log_must $LABELCLEAR -f $disk2
+ log_mustnot $LABELREAD $disk2
+
+ # Check that labelclear on auxilary vdevs will succeed
+ if [[ -n $vdevtype ]]; then
+ log_must $LABELCLEAR $disk3
+ log_mustnot $LABELREAD $disk3
+ fi
+done
+
+log_pass "zpool labelclear will fail on ACTIVE vdevs of exported pool and" \
+ "succeed with -f"
diff --git a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh
index aa7ab76e7..bf09816bc 100755
--- a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh
@@ -76,7 +76,7 @@ fi
# Clear disk labels
for i in {0..2}
do
- log_must zpool labelclear -f /dev/disk/by-id/"${devs_id[i]}"
+ zpool labelclear -f /dev/disk/by-id/"${devs_id[i]}"
done
if is_loop_device $DISK1; then
diff --git a/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh
index d784f06a6..24f128c3d 100755
--- a/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh
@@ -87,7 +87,7 @@ log_onexit cleanup
# Clear disk labels
for i in {0..2}
do
- log_must zpool labelclear -f /dev/disk/by-id/"${devs_id[i]}"
+ zpool labelclear -f /dev/disk/by-id/"${devs_id[i]}"
done
setup