diff options
author | Yuri Pankov <yuri.pankov@nexenta.com> | 2017-01-13 09:25:15 -0800 |
---|---|---|
committer | Matthew Ahrens <mahrens@delphix.com> | 2017-01-13 10:20:58 -0800 |
commit | c95076cee9c3910b6b803dc213adbf74a57acf8e (patch) | |
tree | b050310e12f7bb372238bb1be17b20f7e13eee76 | |
parent | 64723e361134b2a2c45341334174f9d34002f8d0 (diff) | |
download | illumos-joyent-c95076cee9c3910b6b803dc213adbf74a57acf8e.tar.gz |
6865 want zfs-tests cases for zpool labelclear command
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
8 files changed, 215 insertions, 1 deletions
diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index fc7bbb8235..0a6c645807 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -11,8 +11,8 @@ # # Copyright (c) 2012, 2016 by Delphix. All rights reserved. -# Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright 2016, OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2016 Nexenta Systems, Inc. # set name=pkg.fmri value=pkg:/system/test/zfstest@$(PKGVERS) @@ -75,6 +75,7 @@ dir path=opt/zfs-tests/tests/functional/cli_root/zpool_get dir path=opt/zfs-tests/tests/functional/cli_root/zpool_history dir path=opt/zfs-tests/tests/functional/cli_root/zpool_import dir path=opt/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles +dir path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear dir path=opt/zfs-tests/tests/functional/cli_root/zpool_offline dir path=opt/zfs-tests/tests/functional/cli_root/zpool_online dir path=opt/zfs-tests/tests/functional/cli_root/zpool_remove @@ -1296,6 +1297,15 @@ file \ file \ path=opt/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg \ + mode=0444 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active \ + mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_offline/cleanup \ mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_offline/setup \ diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run index 3067f09138..5f6972b6fb 100644 --- a/usr/src/test/zfs-tests/runfiles/delphix.run +++ b/usr/src/test/zfs-tests/runfiles/delphix.run @@ -272,6 +272,11 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos', 'zpool_import_rename_001_pos'] +[/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +pre = +post = + [/opt/zfs-tests/tests/functional/cli_root/zpool_offline] tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg'] diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index 4f8f0d7787..3696f98b63 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -269,6 +269,11 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos', 'zpool_import_rename_001_pos'] +[/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +pre = +post = + [/opt/zfs-tests/tests/functional/cli_root/zpool_offline] tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg'] diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index 4e6ac6d29d..9377e702e8 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -269,6 +269,11 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos', 'zpool_import_rename_001_pos'] +[/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +pre = +post = + [/opt/zfs-tests/tests/functional/cli_root/zpool_offline] tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg'] diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile new file mode 100644 index 0000000000..dc62d6f3bb --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile @@ -0,0 +1,21 @@ +# +# 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. +# + +include $(SRC)/Makefile.master + +ROOTOPTPKG= $(ROOT)/opt/zfs-tests +TARGETDIR= $(ROOTOPTPKG)/tests/functional/cli_root/zpool_labelclear + +include $(SRC)/test/zfs-tests/Makefile.com diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg new file mode 100644 index 0000000000..6ae5395635 --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg @@ -0,0 +1,26 @@ +#! /usr/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/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh new file mode 100644 index 0000000000..a29c09095f --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh @@ -0,0 +1,68 @@ +#! /usr/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/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh new file mode 100644 index 0000000000..82df8216eb --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh @@ -0,0 +1,74 @@ +#! /usr/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" |