Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile (revision 323938) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile (revision 323939) @@ -1,40 +1,41 @@ # $FreeBSD$ .include PACKAGE=tests TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/cli_root/zpool_import FILESDIR=${TESTSDIR} ATF_TESTS_KSH93+= zpool_import_test ${PACKAGE}FILES+= zpool_import_006_pos.ksh ${PACKAGE}FILES+= zpool_import_002_pos.ksh ${PACKAGE}FILES+= zpool_import_missing_003_pos.ksh ${PACKAGE}FILES+= zpool_import_all_001_pos.ksh ${PACKAGE}FILES+= zpool_import.cfg ${PACKAGE}FILES+= zpool_import_corrupt_001_pos.ksh ${PACKAGE}FILES+= zpool_import_destroyed_001_neg.ksh +${PACKAGE}FILES+= zpool_import_destroyed_002_neg.ksh ${PACKAGE}FILES+= zpool_import_012_pos.ksh ${PACKAGE}FILES+= zpool_import_013_neg.ksh ${PACKAGE}FILES+= zpool_import_007_pos.ksh ${PACKAGE}FILES+= zpool_import_003_pos.ksh ${PACKAGE}FILES+= zpool_import_rename_001_pos.ksh ${PACKAGE}FILES+= zpool_import_missing_002_pos.ksh ${PACKAGE}FILES+= setup.ksh ${PACKAGE}FILES+= zpool_import_010_pos.ksh ${PACKAGE}FILES+= zpool_import_014_pos.ksh ${PACKAGE}FILES+= cleanup.ksh ${PACKAGE}FILES+= zpool_import_011_neg.ksh ${PACKAGE}FILES+= zpool_import_missing_004_pos.ksh ${PACKAGE}FILES+= zpool_import_missing_005_pos.ksh ${PACKAGE}FILES+= zpool_import_005_pos.ksh ${PACKAGE}FILES+= zpool_import_009_neg.ksh ${PACKAGE}FILES+= zpool_import_missing_001_pos.ksh ${PACKAGE}FILES+= zpool_import_008_pos.ksh ${PACKAGE}FILES+= zpool_import_004_pos.ksh ${PACKAGE}FILES+= zpool_import.kshlib SUBDIR+= blockfiles .include Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh (nonexistent) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_002_neg.ksh (revision 323939) @@ -0,0 +1,59 @@ +#!/usr/local/bin/ksh93 +# +# Copyright (c) 2017 Spectra Logic Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions, and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# substantially similar to the "NO WARRANTY" disclaimer below +# ("Disclaimer") and any redistribution must be conditioned upon +# including a substantially similar Disclaimer requirement for further +# binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. +# +# $FreeBSD$ + +. $STF_SUITE/include/libtest.kshlib +set_disks + +# "zpool import" will not show destroyed pools, even if out-of-date +# non-destroyed label is present +# +# This situation can happen any time the following things happen: +# 1) A disk gets removed with its label intact +# 2) The pool gets destroyed +# 3) Somebody run "zpool import" to see importable pools + +log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1} + +# Offline a disk so it's label won't get updated by the upcoming destroy +log_must $ZPOOL offline $TESTPOOL ${DISK0} + +# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed +# state, leaving DISK0's label as the most recent non-destroyed label +log_must $ZPOOL destroy $TESTPOOL + +# Now try to import the pool. It should fail. +if $ZPOOL import | $GREP -q $TESTPOOL; then + $ZPOOL import + log_fail "ERROR: Destroyed pool visible" +else + log_pass +fi Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh (revision 323938) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh (revision 323939) @@ -1,564 +1,587 @@ # 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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # atf_test_case zpool_import_002_pos cleanup zpool_import_002_pos_head() { atf_set "descr" "Verify that an exported pool can be imported and cannot be imported more than once." atf_set "require.progs" zfs zpool sum zdb atf_set "timeout" 2400 } zpool_import_002_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_002_pos.ksh || atf_fail "Testcase failed" } zpool_import_002_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_003_pos cleanup zpool_import_003_pos_head() { atf_set "descr" "Destroyed pools are not listed unless with -D option is specified." atf_set "require.progs" zpool zfs atf_set "timeout" 2400 } zpool_import_003_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_003_pos.ksh || atf_fail "Testcase failed" } zpool_import_003_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_004_pos cleanup zpool_import_004_pos_head() { atf_set "descr" "Destroyed pools devices was moved to another directory,it still can be imported correctly." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_004_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_004_pos.ksh || atf_fail "Testcase failed" } zpool_import_004_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_005_pos cleanup zpool_import_005_pos_head() { atf_set "descr" "Destroyed pools devices was renamed, it still can be importedcorrectly." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_005_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_005_pos.ksh || atf_fail "Testcase failed" } zpool_import_005_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_006_pos cleanup zpool_import_006_pos_head() { atf_set "descr" "For mirror, N-1 destroyed pools devices was removed or usedby other pool, it still can be imported correctly." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_006_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_006_pos.ksh || atf_fail "Testcase failed" } zpool_import_006_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_007_pos cleanup zpool_import_007_pos_head() { atf_set "descr" "For raidz, one destroyed pools devices was removed or used byother pool, it still can be imported correctly." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_007_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_007_pos.ksh || atf_fail "Testcase failed" } zpool_import_007_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_008_pos cleanup zpool_import_008_pos_head() { atf_set "descr" "For raidz2, two destroyed pools devices was removed or used byother pool, it still can be imported correctly." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_008_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_008_pos.ksh || atf_fail "Testcase failed" } zpool_import_008_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_009_neg cleanup zpool_import_009_neg_head() { atf_set "descr" "Badly-formed 'zpool import' with inapplicable scenariosshould return an error." atf_set "require.progs" zfs zpool atf_set "timeout" 2400 } zpool_import_009_neg_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_009_neg.ksh || atf_fail "Testcase failed" } zpool_import_009_neg_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_010_pos cleanup zpool_import_010_pos_head() { atf_set "descr" "'zpool -D -a' can import all the specified directoriesdestroyed pools." atf_set "require.progs" zpool zfs atf_set "timeout" 2400 } zpool_import_010_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_010_pos.ksh || atf_fail "Testcase failed" } zpool_import_010_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_011_neg cleanup zpool_import_011_neg_head() { atf_set "descr" "For strip pool, any destroyed pool devices was demaged,zpool import -D will failed." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_011_neg_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_011_neg.ksh || atf_fail "Testcase failed" } zpool_import_011_neg_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_012_pos cleanup zpool_import_012_pos_head() { atf_set "descr" "Verify all mount & share status of sub-filesystems within a poolcan be restored after import [-Df]." atf_set "require.progs" zfs zpool zdb share atf_set "timeout" 2400 } zpool_import_012_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_012_pos.ksh || atf_fail "Testcase failed" } zpool_import_012_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_013_neg zpool_import_013_neg_head() { atf_set "descr" "'zpool import' fails for pool that was not cleanly exported" atf_set "require.progs" zfs zpool } zpool_import_013_neg_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/zpool_import_013_neg.ksh || atf_fail "Testcase failed" } atf_test_case zpool_import_014_pos cleanup zpool_import_014_pos_head() { atf_set "descr" "'zpool import' can import destroyed disk-backed pools" atf_set "require.progs" zfs zpool } zpool_import_014_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 1 ksh93 $(atf_get_srcdir)/zpool_import_014_pos.ksh || atf_fail "Testcase failed" } zpool_import_014_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_all_001_pos cleanup zpool_import_all_001_pos_head() { atf_set "descr" "Verify that 'zpool import -a' succeeds as root." atf_set "require.progs" zfs zpool sum atf_set "timeout" 2400 } zpool_import_all_001_pos_body() { atf_skip "This test relies heavily on Solaris slices. It could be ported, but that is difficult due to the high degree of obfuscation in the code" . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_all_001_pos.ksh || atf_fail "Testcase failed" } zpool_import_all_001_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_missing_001_pos cleanup zpool_import_missing_001_pos_head() { atf_set "descr" "Verify that import could handle damaged or missing device." atf_set "require.progs" zfs sum zpool zdb atf_set "timeout" 2400 } zpool_import_missing_001_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_missing_001_pos.ksh || atf_fail "Testcase failed" } zpool_import_missing_001_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_missing_002_pos cleanup zpool_import_missing_002_pos_head() { atf_set "descr" "Verify that import could handle moving device." atf_set "require.progs" zpool zfs zdb atf_set "timeout" 2400 } zpool_import_missing_002_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_missing_002_pos.ksh || atf_fail "Testcase failed" } zpool_import_missing_002_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_missing_003_pos cleanup zpool_import_missing_003_pos_head() { atf_set "descr" "Verify that import could handle device overlapped." atf_set "require.progs" zpool sum zfs atf_set "timeout" 2400 } zpool_import_missing_003_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_missing_003_pos.ksh || atf_fail "Testcase failed" } zpool_import_missing_003_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_missing_004_pos zpool_import_missing_004_pos_head() { atf_set "descr" "Verify that zpool import succeeds when devices are missing" atf_set "require.progs" zfs zpool atf_set "timeout" 300 } zpool_import_missing_004_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/zpool_import_missing_004_pos.ksh || atf_fail "Testcase failed" } atf_test_case zpool_import_missing_005_pos zpool_import_missing_005_pos_head() { atf_set "descr" "Verify that zpool import succeeds when devices of all types have been renamed" atf_set "require.progs" mdconfig zfs zpool atf_set "timeout" 300 } zpool_import_missing_005_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/zpool_import_missing_005_pos.ksh || atf_fail "Testcase failed" } atf_test_case zpool_import_rename_001_pos cleanup zpool_import_rename_001_pos_head() { atf_set "descr" "Verify that an imported pool can be renamed." atf_set "require.progs" zfs zpool sum zdb atf_set "timeout" 2400 } zpool_import_rename_001_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_import_rename_001_pos.ksh || atf_fail "Testcase failed" } zpool_import_rename_001_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_corrupt_001_pos cleanup zpool_import_corrupt_001_pos_head() { atf_set "descr" "Verify that a disk-backed exported pool with some of its vdev labels corrupted can still be imported" atf_set "require.progs" zfs zpool zdb atf_set "timeout" 2400 } zpool_import_corrupt_001_pos_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg verify_disk_count "$DISKS" 1 ksh93 $(atf_get_srcdir)/zpool_import_corrupt_001_pos.ksh || atf_fail "Testcase failed" } zpool_import_corrupt_001_pos_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_import.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case zpool_import_destroyed_001_neg cleanup zpool_import_destroyed_001_neg_head() { - atf_set "descr" "A destroyed pool cannot be imported even if an out-of-date non-destroyed label remains" - atf_set "require.progs" zfs zpool + atf_set "descr" "'zpool import' will not show destroyed pools, even if an out-of-date non-destroyed label remains" + atf_set "require.progs" zpool } zpool_import_destroyed_001_neg_body() { . $(atf_get_srcdir)/../../../include/default.cfg verify_disk_count "$DISKS" 3 ksh93 $(atf_get_srcdir)/zpool_import_destroyed_001_neg.ksh || atf_fail "Testcase failed" } zpool_import_destroyed_001_neg_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg + destroy_pool "$TESTPOOL" cleanup_devices "$DISKS" } +atf_test_case zpool_import_destroyed_002_neg cleanup +zpool_import_destroyed_002_neg_head() +{ + atf_set "descr" "'zpool import' will not show destroyed pools, even if an out-of-date non-destroyed label remains" + atf_set "require.progs" zpool +} +zpool_import_destroyed_002_neg_body() +{ + . $(atf_get_srcdir)/../../../include/default.cfg + verify_disk_count "$DISKS" 2 + ksh93 $(atf_get_srcdir)/zpool_import_destroyed_002_neg.ksh || atf_fail "Testcase failed" +} +zpool_import_destroyed_002_neg_cleanup() +{ + . $(atf_get_srcdir)/../../../include/default.cfg + + destroy_pool "$TESTPOOL" + cleanup_devices "$DISKS" +} + + atf_init_test_cases() { atf_add_test_case zpool_import_002_pos atf_add_test_case zpool_import_003_pos atf_add_test_case zpool_import_004_pos atf_add_test_case zpool_import_005_pos atf_add_test_case zpool_import_006_pos atf_add_test_case zpool_import_007_pos atf_add_test_case zpool_import_008_pos atf_add_test_case zpool_import_009_neg atf_add_test_case zpool_import_010_pos atf_add_test_case zpool_import_011_neg atf_add_test_case zpool_import_012_pos atf_add_test_case zpool_import_013_neg atf_add_test_case zpool_import_014_pos atf_add_test_case zpool_import_all_001_pos atf_add_test_case zpool_import_missing_001_pos atf_add_test_case zpool_import_missing_002_pos atf_add_test_case zpool_import_missing_003_pos atf_add_test_case zpool_import_missing_004_pos atf_add_test_case zpool_import_missing_005_pos atf_add_test_case zpool_import_rename_001_pos atf_add_test_case zpool_import_corrupt_001_pos atf_add_test_case zpool_import_destroyed_001_neg + atf_add_test_case zpool_import_destroyed_002_neg } Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh (revision 323938) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_003_neg.ksh (nonexistent) @@ -1,181 +0,0 @@ -#!/usr/local/bin/ksh93 -# -# Copyright (c) 2010 Spectra Logic Corporation -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions, and the following disclaimer, -# without modification. -# 2. Redistributions in binary form must reproduce at minimum a disclaimer -# substantially similar to the "NO WARRANTY" disclaimer below -# ("Disclaimer") and any redistribution must be conditioned upon -# including a substantially similar Disclaimer requirement for further -# binary redistribution. -# -# NO WARRANTY -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGES. -# -# $FreeBSD$ - -. $STF_SUITE/include/libtest.kshlib -. $STF_SUITE/include/libsas.kshlib -. $STF_SUITE/tests/hotspare/hotspare.kshlib - -# "zpool import" should not show destroyed pools, even if a non-destroyed label -# is present. -# -# This situation arose when a user activated a spare, removed the spare disk, -# destroyed the pool, reinserted the spare disk, and then tried to import the -# pool. Since the pool was destroyed, nothing should've happened. But the -# spare disk had a non-destroyed label, so zpool tried to import it. A panic -# ensued. -# -# To reproduce: -# 1. Create a 3 drive raid. -# 2. Disable a drive -# 3. Let a Spare take over -# 4. Disable that Spare when it is done rebuilding. -# 5. Let 2nd spare finish rebuilding -# 6. Enable the first spare -# 7. Enable the original drive -# 8. Destroy the pool. - -cleanup() { - [[ $DISK0_PHY != 0 ]] && enable_sas_disk $DISK0_EXPANDER $DISK0_PHY - [[ $SPARE0_PHY != 0 ]] && enable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY - [[ $SPARE1_PHY != 0 ]] && enable_sas_disk $SPARE1_EXPANDER $SPARE1_PHY - if poolexists $TESTPOOL; then - # Test failed, provide something useful. - log_note "For reference, here is the final $TESTPOOL status:" - zpool status $TESTPOOL - log_must destroy_pool $TESTPOOL - fi - cleanup_devices ${DISKS} -} - -log_onexit cleanup -trap cleanup TERM INT - -typeset -A MEMBERS -typeset -A SPARES -typeset DISK0_EXPANDER=0 -typeset DISK0_PHY=0 -typeset SPARE0_EXPANDER=0 -typeset SPARE0_PHY=0 -typeset SPARE1_EXPANDER=0 -typeset SPARE1_PHY=0 - -for disk in $DISKS; do - if [[ $DISK0_PHY == 0 ]]; then - find_verify_sas_disk $disk - DISK0_PHY=$PHY - DISK0_EXPANDER=$EXPANDER - DISK0_NAME=$disk - set -A MEMBERS "${MEMBERS[@]}" $disk - continue - fi - if [[ $SPARE0_PHY == 0 ]]; then - find_verify_sas_disk $disk - SPARE0_PHY=$PHY - SPARE0_EXPANDER=$EXPANDER - SPARE0_NAME=$disk - set -A SPARES "${SPARES[@]}" $disk - continue - fi - if [[ $SPARE1_PHY == 0 ]]; then - find_verify_sas_disk $disk - SPARE1_PHY=$PHY - SPARE1_EXPANDER=$EXPANDER - SPARE1_NAME=$disk - set -A SPARES "${SPARES[@]}" $disk - continue - fi - # Already filled those positions? Add disks to the raidz. - if [[ ${#DISKS[*]} -lt 3 ]]; then - find_verify_sas_disk $disk - [[ -z "$DISK1_NAME" ]] && DISK1_NAME=$disk - DISK1_LONG_NAME=`find_disks ${DISK1_NAME}` - DISK1_SHORT_NAME=${DISK1_LONG_NAME##/dev/} - set -A MEMBERS "${MEMBERS[@]}" $disk - continue - fi - break -done - -# Remove labels etc. from all the disks we're about to use. -poolexists && log_must destroy_pool $TESTPOOL -cleanup_devices ${MEMBERS[*]} ${SPARES[*]} - -log_must $ZPOOL create -f $TESTPOOL raidz1 ${MEMBERS[@]} spare ${SPARES[@]} -DISK0_GUID=$(get_disk_guid $DISK0_NAME) - -disable_sas_disk $DISK0_EXPANDER $DISK0_PHY -log_must $ZPOOL replace $TESTPOOL $DISK0_GUID $SPARE0_NAME -wait_until_resilvered -SPARE0_GUID=$(get_disk_guid $SPARE0_NAME) - -disable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY -log_must $ZPOOL replace $TESTPOOL $SPARE0_GUID $SPARE1_NAME -wait_until_resilvered - -enable_sas_disk $DISK0_EXPANDER $DISK0_PHY -enable_sas_disk $SPARE0_EXPANDER $SPARE0_PHY - -log_must destroy_pool $TESTPOOL - -# Screen scrape the 'zpool import' output to ensure that the pool doesn't -# show up, since it's been destroyed. -badpoolstate=0 -$ZPOOL import | \ - while read word1 word2 rest; do - echo "$word1 $word2 $rest" - case "$word1 $word2" in - "pool: $TESTPOOL") (( badpoolstate += 1 )) ;; - "$DISK1_LONG_NAME ONLINE") (( badpoolstate += 2 )) ;; - "$DISK1_SHORT_NAME ONLINE") (( badpoolstate += 2 )) ;; - *) ;; - esac - done - -case $badpoolstate in - 0) log_pass ;; - 1) log_note "Destroyed pool visible, but probably another pool" - log_pass ;; - 2) log_fail "One of our disks is visible but pool is not?!" ;; - 3) log_fail "Destroyed pool visible!" ;; - *) log_fail "Unexpected output. Update the test" ;; -esac - -# Bad output looks like this: -# pool: testpool.2358 -# id: 5289863802080396071 -# state: UNAVAIL -# status: One or more devices are missing from the system. -# action: The pool cannot be imported. Attach the missing -# devices and try again. -# see: http://illumos.org/msg/ZFS-8000-6X -# config: -# -# testpool.2358 UNAVAIL missing device -# raidz1-0 DEGRADED -# spare-0 UNAVAIL -# 4564766431272474500 FAULTED corrupted data -# 1988887717739330825 FAULTED corrupted data -# da4 ONLINE -# da5 ONLINE -# spares -# 1988887717739330825 -# da3 Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile (revision 323938) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/Makefile (revision 323939) @@ -1,44 +1,43 @@ # $FreeBSD$ .include PACKAGE=tests TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/hotspare FILESDIR=${TESTSDIR} ATF_TESTS_KSH93+= hotspare_test ${PACKAGE}FILES+= hotspare_create_001_neg.ksh ${PACKAGE}FILES+= setup.ksh ${PACKAGE}FILES+= hotspare_add_004_neg.ksh ${PACKAGE}FILES+= hotspare_scrub_002_pos.ksh ${PACKAGE}FILES+= hotspare_detach_002_pos.ksh ${PACKAGE}FILES+= hotspare_remove_001_pos.ksh ${PACKAGE}FILES+= hotspare_add_001_pos.ksh ${PACKAGE}FILES+= hotspare_import_001_pos.ksh ${PACKAGE}FILES+= hotspare_replace_002_neg.ksh ${PACKAGE}FILES+= hotspare_clone_002_pos.ksh -${PACKAGE}FILES+= hotspare_replace_003_neg.ksh ${PACKAGE}FILES+= hotspare_export_001_neg.ksh ${PACKAGE}FILES+= hotspare_snapshot_001_pos.ksh ${PACKAGE}FILES+= hotspare_remove_004_pos.ksh ${PACKAGE}FILES+= hotspare_detach_003_pos.ksh ${PACKAGE}FILES+= hotspare_onoffline_004_neg.ksh ${PACKAGE}FILES+= cleanup.ksh ${PACKAGE}FILES+= hotspare_replace_001_neg.ksh ${PACKAGE}FILES+= hotspare_scrub_001_pos.ksh ${PACKAGE}FILES+= hotspare_detach_001_pos.ksh ${PACKAGE}FILES+= hotspare_add_003_neg.ksh ${PACKAGE}FILES+= hotspare_remove_003_neg.ksh ${PACKAGE}FILES+= hotspare_add_002_pos.ksh ${PACKAGE}FILES+= hotspare_detach_004_pos.ksh ${PACKAGE}FILES+= hotspare_snapshot_002_pos.ksh ${PACKAGE}FILES+= hotspare.kshlib ${PACKAGE}FILES+= hotspare_detach_005_neg.ksh ${PACKAGE}FILES+= hotspare_remove_002_neg.ksh ${PACKAGE}FILES+= hotspare_onoffline_003_neg.ksh ${PACKAGE}FILES+= hotspare_shared_001_pos.ksh ${PACKAGE}FILES+= hotspare.cfg ${PACKAGE}FILES+= hotspare_clone_001_pos.ksh .include Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh (revision 323938) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh (revision 323939) @@ -1,788 +1,760 @@ # 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 2012 Spectra Logic. All rights reserved. # Use is subject to license terms. # atf_test_case hotspare_add_001_pos cleanup hotspare_add_001_pos_head() { atf_set "descr" "'zpool add spare ...' can add devices to the pool." atf_set "timeout" 3600 } hotspare_add_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_add_001_pos.ksh || atf_fail "Testcase failed" } hotspare_add_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_add_002_pos cleanup hotspare_add_002_pos_head() { atf_set "descr" "'zpool add spare ...' can add devices to the pool while it has spare-in device." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_add_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_add_002_pos.ksh || atf_fail "Testcase failed" } hotspare_add_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_add_003_neg cleanup hotspare_add_003_neg_head() { atf_set "descr" "'zpool add [-f]' with hot spares should fail with inapplicable scenarios." atf_set "require.config" disks_are_physical atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_add_003_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_add_003_neg.ksh || atf_fail "Testcase failed" } hotspare_add_003_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_add_004_neg cleanup hotspare_add_004_neg_head() { atf_set "descr" "'zpool add [-f]' will not allow a swap device to be used as a hotspare'" atf_set "require.config" disks_are_physical atf_set "require.progs" zpool swapon swapoff swapctl } hotspare_add_004_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_add_004_neg.ksh || atf_fail "Testcase failed" } hotspare_add_004_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_clone_001_pos cleanup hotspare_clone_001_pos_head() { atf_set "descr" "'zpool detach ...' against hotspare should do no harm to clone." atf_set "require.progs" zfs zpool sum atf_set "timeout" 3600 } hotspare_clone_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_clone_001_pos.ksh || atf_fail "Testcase failed" } hotspare_clone_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_clone_002_pos cleanup hotspare_clone_002_pos_head() { atf_set "descr" "'zpool detach ...' against basic vdev should do no harm to clone." atf_set "require.progs" zfs zpool sum atf_set "timeout" 3600 } hotspare_clone_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_clone_002_pos.ksh || atf_fail "Testcase failed" } hotspare_clone_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_create_001_neg cleanup hotspare_create_001_neg_head() { atf_set "descr" "'zpool create [-f]' with hot spares should be failedwith inapplicable scenarios." atf_set "require.config" disks_are_physical atf_set "require.progs" dumpadm zpool atf_set "timeout" 3600 } hotspare_create_001_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_create_001_neg.ksh || atf_fail "Testcase failed" } hotspare_create_001_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_detach_001_pos cleanup hotspare_detach_001_pos_head() { atf_set "descr" "'zpool detach ...' should deactivate the spared-in hot spare device successfully." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_detach_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_detach_001_pos.ksh || atf_fail "Testcase failed" } hotspare_detach_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_detach_002_pos cleanup hotspare_detach_002_pos_head() { atf_set "descr" "'zpool detach ...' against a functioning device that have spared should take the hot spare permanently swapping in successfully." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_detach_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_detach_002_pos.ksh || atf_fail "Testcase failed" } hotspare_detach_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_detach_003_pos cleanup hotspare_detach_003_pos_head() { atf_set "descr" "'zpool replace ' against a functioning device that have spared should complete and the hot spare should return to available." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_detach_003_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_detach_003_pos.ksh || atf_fail "Testcase failed" } hotspare_detach_003_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_detach_004_pos cleanup hotspare_detach_004_pos_head() { atf_set "descr" "'zpool replace ' against a hot spare device that have been activated should successful while the another dev is a available hot spare." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_detach_004_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_detach_004_pos.ksh || atf_fail "Testcase failed" } hotspare_detach_004_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_detach_005_neg cleanup hotspare_detach_005_neg_head() { atf_set "descr" "'zpool detach ' against a hot spare device that NOT activated should fail and issue an error message." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_detach_005_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_detach_005_neg.ksh || atf_fail "Testcase failed" } hotspare_detach_005_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_export_001_neg cleanup hotspare_export_001_neg_head() { atf_set "descr" "export pool that using shared hotspares will fail" atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_export_001_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_export_001_neg.ksh || atf_fail "Testcase failed" } hotspare_export_001_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_import_001_pos cleanup hotspare_import_001_pos_head() { atf_set "descr" "'zpool export/import ' should runs successfully regardless the hotspare is only in list, activated, or offline." atf_set "require.progs" zpool sum atf_set "timeout" 3600 } hotspare_import_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_import_001_pos.ksh || atf_fail "Testcase failed" } hotspare_import_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_onoffline_003_neg cleanup hotspare_onoffline_003_neg_head() { atf_set "descr" "'zpool offline/online ' should fail on inactive spares" atf_set "require.progs" zpool zdb atf_set "timeout" 3600 } hotspare_onoffline_003_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_onoffline_003_neg.ksh || atf_fail "Testcase failed" } hotspare_onoffline_003_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_onoffline_004_neg cleanup hotspare_onoffline_004_neg_head() { atf_set "descr" "'zpool offline/online ' against a spared basic vdev during I/O completes." atf_set "require.progs" zfs zpool zdb atf_set "timeout" 3600 } hotspare_onoffline_004_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_onoffline_004_neg.ksh || atf_fail "Testcase failed" } hotspare_onoffline_004_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_remove_001_pos cleanup hotspare_remove_001_pos_head() { atf_set "descr" "'zpool remove ...' can remove spare device from the pool." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_remove_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_remove_001_pos.ksh || atf_fail "Testcase failed" } hotspare_remove_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_remove_002_neg cleanup hotspare_remove_002_neg_head() { atf_set "descr" "'zpool remove ...' should fail with inapplicable scenarios." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_remove_002_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_remove_002_neg.ksh || atf_fail "Testcase failed" } hotspare_remove_002_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_remove_003_neg cleanup hotspare_remove_003_neg_head() { atf_set "descr" "Executing 'zpool remove' with bad options fails" atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_remove_003_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_remove_003_neg.ksh || atf_fail "Testcase failed" } hotspare_remove_003_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_remove_004_pos cleanup hotspare_remove_004_pos_head() { atf_set "descr" "'zpool remove ...' can remove spare device from the pool." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_remove_004_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_remove_004_pos.ksh || atf_fail "Testcase failed" } hotspare_remove_004_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_replace_001_neg cleanup hotspare_replace_001_neg_head() { atf_set "descr" "'zpool replace ' should fail with inapplicable scenarios." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_replace_001_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_replace_001_neg.ksh || atf_fail "Testcase failed" } hotspare_replace_001_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_replace_002_neg cleanup hotspare_replace_002_neg_head() { atf_set "descr" "'zpool replace ' should fail while the hot spares smaller than the basic vdev." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_replace_002_neg_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_replace_002_neg.ksh || atf_fail "Testcase failed" } hotspare_replace_002_neg_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } -atf_test_case hotspare_replace_003_neg cleanup -hotspare_replace_003_neg_head() -{ - atf_set "descr" "'zpool replace' of disabled hotspares should result in ignoring them after destroy." - atf_set "require.progs" camcontrol zpool - atf_set "timeout" 3600 -} -hotspare_replace_003_neg_body() -{ - . $(atf_get_srcdir)/../../include/default.cfg - . $(atf_get_srcdir)/hotspare.kshlib - . $(atf_get_srcdir)/hotspare.cfg - - verify_disk_count "$DISKS" 5 - ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" - ksh93 $(atf_get_srcdir)/hotspare_replace_003_neg.ksh || atf_fail "Testcase failed" -} -hotspare_replace_003_neg_cleanup() -{ - . $(atf_get_srcdir)/../../include/default.cfg - . $(atf_get_srcdir)/hotspare.kshlib - . $(atf_get_srcdir)/hotspare.cfg - - ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" -} - - atf_test_case hotspare_scrub_001_pos cleanup hotspare_scrub_001_pos_head() { atf_set "descr" "'zpool scrub ' should runs successfully regardlessthe hotspare is only in list or activated." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_scrub_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_scrub_001_pos.ksh || atf_fail "Testcase failed" } hotspare_scrub_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_scrub_002_pos cleanup hotspare_scrub_002_pos_head() { atf_set "descr" "'zpool scrub' scans spare vdevs" atf_set "require.progs" zpool } hotspare_scrub_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_scrub_002_pos.ksh || atf_fail "Testcase failed" } hotspare_scrub_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_shared_001_pos cleanup hotspare_shared_001_pos_head() { atf_set "descr" "'zpool add spare ...' can add a disk as a shared spare to multiple pools." atf_set "require.progs" zpool atf_set "timeout" 3600 } hotspare_shared_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg verify_disk_count "$DISKS" 5 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_shared_001_pos.ksh || atf_fail "Testcase failed" } hotspare_shared_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_snapshot_001_pos cleanup hotspare_snapshot_001_pos_head() { atf_set "descr" "'zpool detach ...' against hotspare should do no harm to snapshot." atf_set "require.progs" zfs zpool sum atf_set "timeout" 3600 } hotspare_snapshot_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_snapshot_001_pos.ksh || atf_fail "Testcase failed" } hotspare_snapshot_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotspare_snapshot_002_pos cleanup hotspare_snapshot_002_pos_head() { atf_set "descr" "'zpool detach ...' against basic vdev do no harm to snapshot." atf_set "require.progs" zfs zpool sum atf_set "timeout" 3600 } hotspare_snapshot_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotspare_snapshot_002_pos.ksh || atf_fail "Testcase failed" } hotspare_snapshot_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotspare.kshlib . $(atf_get_srcdir)/hotspare.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_init_test_cases() { atf_add_test_case hotspare_add_001_pos atf_add_test_case hotspare_add_002_pos atf_add_test_case hotspare_add_003_neg atf_add_test_case hotspare_add_004_neg atf_add_test_case hotspare_clone_001_pos atf_add_test_case hotspare_clone_002_pos atf_add_test_case hotspare_create_001_neg atf_add_test_case hotspare_detach_001_pos atf_add_test_case hotspare_detach_002_pos atf_add_test_case hotspare_detach_003_pos atf_add_test_case hotspare_detach_004_pos atf_add_test_case hotspare_detach_005_neg atf_add_test_case hotspare_export_001_neg atf_add_test_case hotspare_import_001_pos atf_add_test_case hotspare_onoffline_003_neg atf_add_test_case hotspare_onoffline_004_neg atf_add_test_case hotspare_remove_001_pos atf_add_test_case hotspare_remove_002_neg atf_add_test_case hotspare_remove_003_neg atf_add_test_case hotspare_remove_004_pos atf_add_test_case hotspare_replace_001_neg atf_add_test_case hotspare_replace_002_neg - atf_add_test_case hotspare_replace_003_neg atf_add_test_case hotspare_scrub_001_pos atf_add_test_case hotspare_scrub_002_pos atf_add_test_case hotspare_shared_001_pos atf_add_test_case hotspare_snapshot_001_pos atf_add_test_case hotspare_snapshot_002_pos }