Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/Makefile (revision 328572) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/Makefile (revision 328573) @@ -1,16 +1,17 @@ # $FreeBSD$ .include PACKAGE=tests TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/cli_root/zpool_replace FILESDIR=${TESTSDIR} ATF_TESTS_KSH93+= zpool_replace_test ${PACKAGE}FILES+= zpool_replace_001_neg.ksh +${PACKAGE}FILES+= zpool_replace_002_neg.ksh ${PACKAGE}FILES+= setup.ksh ${PACKAGE}FILES+= cleanup.ksh ${PACKAGE}FILES+= zpool_replace.cfg .include Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/zpool_replace_002_neg.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/zpool_replace_002_neg.ksh (nonexistent) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/zpool_replace_002_neg.ksh (revision 328573) @@ -0,0 +1,38 @@ +#!/usr/local/bin/ksh93 -p +# +# 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 2017 Spectra Logic Corp. All rights reserved. +# Use is subject to license terms. +# + +. $STF_SUITE/include/libtest.kshlib + +log_assert "'zpool replace' should fail if the new device is too small" + +log_must $TRUNCATE -s 1024m bigfile +log_must $TRUNCATE -s 512m smallfile + +log_must $ZPOOL create $TESTPOOL $PWD/bigfile +log_mustnot $ZPOOL replace $TESTPOOL $PWD/bigfile $PWD/smallfile + +log_pass "'zpool replace' should fail if the new device is too small" Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/zpool_replace_test.sh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/zpool_replace_test.sh (revision 328572) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_replace/zpool_replace_test.sh (revision 328573) @@ -1,55 +1,77 @@ # 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_replace_001_neg cleanup zpool_replace_001_neg_head() { atf_set "descr" "Executing 'zpool replace' with bad options fails" atf_set "require.progs" zpool } zpool_replace_001_neg_body() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_replace.cfg verify_disk_count "$DISKS" 2 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/zpool_replace_001_neg.ksh || atf_fail "Testcase failed" } zpool_replace_001_neg_cleanup() { . $(atf_get_srcdir)/../../../include/default.cfg . $(atf_get_srcdir)/zpool_replace.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } +atf_test_case zpool_replace_002_neg cleanup +zpool_replace_002_neg_head() +{ + atf_set "descr" "'zpool replace' should fail if the new device is too small" + atf_set "require.progs" zpool +} +zpool_replace_002_neg_body() +{ + . $(atf_get_srcdir)/../../../include/default.cfg + . $(atf_get_srcdir)/zpool_replace.cfg + ksh93 $(atf_get_srcdir)/zpool_replace_002_neg.ksh || atf_fail "Testcase failed" +} +zpool_replace_002_neg_cleanup() +{ + . $(atf_get_srcdir)/../../../include/default.cfg + . $(atf_get_srcdir)/zpool_replace.cfg + + ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" +} + + atf_init_test_cases() { atf_add_test_case zpool_replace_001_neg + atf_add_test_case zpool_replace_002_neg } Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_007_pos.ksh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_007_pos.ksh (revision 328572) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_007_pos.ksh (nonexistent) @@ -1,96 +0,0 @@ -#!/usr/local/bin/ksh93 -p -# -# 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 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "@(#)hotplug_007_pos.ksh 1.2 08/02/27 SMI" -# - -. $STF_SUITE/tests/hotplug/hotplug.kshlib - -################################################################################# -# -# __stc_assertion_start -# -# ID: hotplug_007_pos -# -# DESCRIPTION: -# When autoreplace is 'on', replacing the device with a smaller one. -# Verify the device's status is 'UNAVAIL'. FMA fault has been generated. -# -# STRATEGY: -# 1. Create mirror/raidz/raidz2 pool. -# 2. Set autoreplace = on -# 3. Synchronise with device in the background. -# 4. Offline and remove one of device, insert a new device. -# 5. Verify the device's status is 'UNAVAIL'. -# 6. Verify FMA fault has been generated. -# -# TESTABILITY: explicit -# -# TEST_AUTOMATION_LEVEL: automated -# -# CODING_STATUS: COMPLETED (2007-06-01) -# -# __stc_assertion_end -# -################################################################################ - -log_unsupported "WARNING: Disable it temporarily due to bug 6563887" - -verify_runnable "global" - -function cleanup -{ - cleanup_testenv $TESTPOOL - log_must destroy_lofi_device $SMALLFILE -} - -log_assert "When autoreplace is 'on', replacing the device with a smaller one."\ - "Verify the device's status is 'UNAVAIL'. FMA fault has been generated." -log_onexit cleanup - -for type in "mirror" "raidz" "raidz2"; do - setup_testenv $TESTPOOL $type - log_must $ZPOOL set autoreplace=on $TESTPOOL - - typeset file=$(random_get $DEV_FILES) - typeset device=$(convert_lofi $file) - log_must $ZPOOL offline $TESTPOOL $device - log_must remove_device $device - log_must $ZPOOL clear $TESTPOOL - - # Recreate SMALLFILE to avoid dirty data in SMALLFILE - log_must create_file 64M $SMALLFILE - log_must insert_device $SMALLFILE $device - - log_must verify_device_status $TESTPOOL $device 'UNAVAIL' - log_must fma_faulty 'TRUE' - - cleanup_testenv $TESTPOOL - log_must remove_device $SMALLFILE -done - -log_pass "When autoreplace is 'on', replacing the device with a smaller one."\ - "Verify the device's status is 'UNAVAIL'. FMA fault has been generated." Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/Makefile =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/Makefile (revision 328572) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/Makefile (revision 328573) @@ -1,27 +1,26 @@ # $FreeBSD$ .include PACKAGE=tests TESTSDIR=${TESTSBASE}/sys/cddl/zfs/tests/hotplug FILESDIR=${TESTSDIR} ATF_TESTS_KSH93+= hotplug_test ${PACKAGE}FILES+= hotplug.cfg ${PACKAGE}FILES+= hotplug_006_pos.ksh ${PACKAGE}FILES+= hotplug_002_pos.ksh ${PACKAGE}FILES+= cleanup.ksh -${PACKAGE}FILES+= hotplug_007_pos.ksh ${PACKAGE}FILES+= hotplug_003_pos.ksh ${PACKAGE}FILES+= setup.ksh ${PACKAGE}FILES+= hotplug_005_pos.ksh ${PACKAGE}FILES+= hotplug_001_pos.ksh ${PACKAGE}FILES+= hotplug_009_pos.ksh ${PACKAGE}FILES+= hotplug_010_pos.ksh ${PACKAGE}FILES+= hotplug.kshlib ${PACKAGE}FILES+= hotplug_011_pos.ksh ${PACKAGE}FILES+= hotplug_008_pos.ksh ${PACKAGE}FILES+= hotplug_004_pos.ksh .include Index: projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_test.sh =================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_test.sh (revision 328572) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/hotplug/hotplug_test.sh (revision 328573) @@ -1,335 +1,307 @@ # 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 hotplug_001_pos cleanup hotplug_001_pos_head() { atf_set "descr" "When removing a device from a redundant pool, the device'sstate will be indicated as 'REMOVED'." atf_set "require.progs" zpool gnop } hotplug_001_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_001_pos.ksh || atf_fail "Testcase failed" } hotplug_001_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_002_pos cleanup hotplug_002_pos_head() { atf_set "descr" "When removing and reinserting a device, the device status is ONLINE." atf_set "require.progs" zpool gnop } hotplug_002_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "redundant with zfsd_replace_001_pos" verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_002_pos.ksh || atf_fail "Testcase failed" } hotplug_002_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_003_pos cleanup hotplug_003_pos_head() { atf_set "descr" "Having removed a device from a redundant pool and inserted a newdevice, the new device state will be 'ONLINE' when autoreplace is on,\and 'UNAVAIL' when autoreplace is off" atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_003_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "redundant with zfsd_autoreplace_00[12]*" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_003_pos.ksh || atf_fail "Testcase failed" } hotplug_003_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_004_pos cleanup hotplug_004_pos_head() { atf_set "descr" "When device replacement fails, the original device's state willbe 'UNAVAIL' and an FMA fault will be generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_004_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "Does not apply to FreeBSD" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_004_pos.ksh || atf_fail "Testcase failed" } hotplug_004_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_005_pos cleanup hotplug_005_pos_head() { atf_set "descr" "Regarding of autoreplace, when removing offline device andreinserting again. This device's status is 'ONLINE'. \No FMA fault was generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_005_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "TODO: move to the zfsd directory" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_005_pos.ksh || atf_fail "Testcase failed" } hotplug_005_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_006_pos cleanup hotplug_006_pos_head() { atf_set "descr" "When unsetting/setting autoreplace, then replacing device, verifythe device's status is 'UNAVAIL/ONLINE'. No FMA fault is generated." atf_set "require.progs" zpool lofiadm atf_set "timeout" 1800 } hotplug_006_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "redundant with hotplug_050_pos" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_006_pos.ksh || atf_fail "Testcase failed" } hotplug_006_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } -atf_test_case hotplug_007_pos cleanup -hotplug_007_pos_head() -{ - atf_set "descr" "When autoreplace is 'on', replacing the device with a smaller one.Verify the device's status is 'UNAVAIL'. FMA fault has been generated." - atf_set "require.progs" zpool lofiadm - atf_set "timeout" 1800 -} -hotplug_007_pos_body() -{ - . $(atf_get_srcdir)/../../include/default.cfg - . $(atf_get_srcdir)/hotplug.kshlib - . $(atf_get_srcdir)/hotplug.cfg - - atf_skip "TODO: move to cli_root/zpool_replace" - ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" - ksh93 $(atf_get_srcdir)/hotplug_007_pos.ksh || atf_fail "Testcase failed" -} -hotplug_007_pos_cleanup() -{ - . $(atf_get_srcdir)/../../include/default.cfg - . $(atf_get_srcdir)/hotplug.kshlib - . $(atf_get_srcdir)/hotplug.cfg - - ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" -} - - atf_test_case hotplug_008_pos cleanup hotplug_008_pos_head() { atf_set "descr" "When removing hotspare device, verify device status is 'REMOVED'." atf_set "require.progs" zpool gnop } hotplug_008_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_008_pos.ksh || atf_fail "Testcase failed" } hotplug_008_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_009_pos cleanup hotplug_009_pos_head() { atf_set "descr" "Power off machine and replacing device, verify device status isONLINE when autoreplace is on and UNAVAIL when autoreplace is off" atf_set "require.progs" zpool lofiadm svcadm svcs atf_set "timeout" 1800 } hotplug_009_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "redundant with zfsd_import_001_pos" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_009_pos.ksh || atf_fail "Testcase failed" } hotplug_009_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_010_pos cleanup hotplug_010_pos_head() { atf_set "descr" "Removing device offlined and reinserting onlined,verify the device status ONLINE." atf_set "require.progs" zpool lofiadm svcadm svcs atf_set "timeout" 1800 } hotplug_010_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg atf_skip "redundant with zfsd_replace_001_pos" ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_010_pos.ksh || atf_fail "Testcase failed" } hotplug_010_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_test_case hotplug_011_pos cleanup hotplug_011_pos_head() { atf_set "descr" "Removing device offlined, verify device status is UNAVAIL,when the system is onlined." atf_set "require.progs" zpool gnop } hotplug_011_pos_body() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg verify_disk_count "$DISKS" 4 ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed" ksh93 $(atf_get_srcdir)/hotplug_011_pos.ksh || atf_fail "Testcase failed" } hotplug_011_pos_cleanup() { . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/hotplug.kshlib . $(atf_get_srcdir)/hotplug.cfg ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed" } atf_init_test_cases() { atf_add_test_case hotplug_001_pos atf_add_test_case hotplug_002_pos atf_add_test_case hotplug_003_pos atf_add_test_case hotplug_004_pos atf_add_test_case hotplug_005_pos atf_add_test_case hotplug_006_pos - atf_add_test_case hotplug_007_pos atf_add_test_case hotplug_008_pos atf_add_test_case hotplug_009_pos atf_add_test_case hotplug_010_pos atf_add_test_case hotplug_011_pos }