Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/cddl/zfs/tests/hotspare/hotspare_create_001_neg.ksh
Show All 34 Lines | |||||
# __stc_assertion_start | # __stc_assertion_start | ||||
# | # | ||||
# ID: hotspare_create_001_neg | # ID: hotspare_create_001_neg | ||||
# | # | ||||
# DESCRIPTION: | # DESCRIPTION: | ||||
# 'zpool create [-f]' with hot spares will fail | # 'zpool create [-f]' with hot spares will fail | ||||
# while the hot spares belong to the following cases: | # while the hot spares belong to the following cases: | ||||
# - existing pool | # - existing pool | ||||
# - nonexist device, | # - nonexistent device, | ||||
# - part of an active pool, | # - part of an active pool, | ||||
# - currently mounted, | # - currently mounted, | ||||
# - devices in /etc/vfstab, | # - a swap device, | ||||
# - specified as the dedicated dump device, | # - a dump device, | ||||
# - identical with the basic vdev within the pool, | # - identical with the basic vdev within the pool, | ||||
# | # | ||||
# STRATEGY: | # STRATEGY: | ||||
# 1. Create case scenarios | # 1. Create case scenarios | ||||
# 2. For each scenario, try to create a new pool with hot spares | # 2. For each scenario, try to create a new pool with hot spares | ||||
# of the virtual devices | # of the virtual devices | ||||
# 3. Verify the creation is failed. | # 3. Verify the creation is failed. | ||||
# | # | ||||
Show All 11 Lines | |||||
function cleanup | function cleanup | ||||
{ | { | ||||
for pool in $TESTPOOL $TESTPOOL1 | for pool in $TESTPOOL $TESTPOOL1 | ||||
do | do | ||||
destroy_pool $pool | destroy_pool $pool | ||||
done | done | ||||
if [[ -n $saved_dump_dev ]]; then | log_onfail $UMOUNT $TMPDIR/mounted_dir | ||||
if [[ -n $DUMPADM ]]; then | log_onfail $SWAPOFF $swap_dev | ||||
log_must $DUMPADM -u -d $saved_dump_dev | log_onfail $DUMPON -r $dump_dev | ||||
fi | |||||
fi | |||||
partition_cleanup | partition_cleanup | ||||
} | } | ||||
log_assert "'zpool create [-f]' with hot spares should be failed " \ | log_assert "'zpool create [-f]' with hot spares should be failed " \ | ||||
"with inapplicable scenarios." | "with inapplicable scenarios." | ||||
log_onexit cleanup | log_onexit cleanup | ||||
set_devs | set_devs | ||||
mnttab_dev=$(find_mnttab_dev) | mounted_dev=${DISK0} | ||||
vfstab_dev=$(find_vfstab_dev) | swap_dev=${DISK1} | ||||
saved_dump_dev=$(save_dump_dev) | dump_dev=${DISK2} | ||||
dump_dev=${disk}s0 | |||||
nonexist_dev=${disk}sbad_slice_num | nonexist_dev=${disk}sbad_slice_num | ||||
create_pool "$TESTPOOL" ${pooldevs[0]} | create_pool "$TESTPOOL" ${pooldevs[0]} | ||||
log_must $MKDIR $TMPDIR/mounted_dir | |||||
log_must $NEWFS $mounted_dev | |||||
log_must $MOUNT $mounted_dev $TMPDIR/mounted_dir | |||||
log_must $SWAPON $swap_dev | |||||
log_must $DUMPON $dump_dev | |||||
# | # | ||||
# Set up the testing scenarios parameters | # Set up the testing scenarios parameters | ||||
# - existing pool | # - existing pool | ||||
# - nonexist device, | # - nonexistent device, | ||||
# - part of an active pool, | # - part of an active pool, | ||||
# - currently mounted, | # - currently mounted, | ||||
# - devices in /etc/vfstab, | # - a swap device, | ||||
# - identical with the basic vdev within the pool, | # - identical with the basic vdev within the pool, | ||||
set -A arg "$TESTPOOL ${pooldevs[1]} spare ${pooldevs[2]}" \ | set -A arg "$TESTPOOL ${pooldevs[1]} spare ${pooldevs[2]}" \ | ||||
"$TESTPOOL1 ${pooldevs[1]} spare $nonexist_dev" \ | "$TESTPOOL1 ${pooldevs[1]} spare $nonexist_dev" \ | ||||
"$TESTPOOL1 ${pooldevs[1]} spare ${pooldevs[0]}" \ | "$TESTPOOL1 ${pooldevs[1]} spare ${pooldevs[0]}" \ | ||||
"$TESTPOOL1 ${pooldevs[1]} spare $mnttab_dev" \ | "$TESTPOOL1 ${pooldevs[1]} spare $mounted_dev" \ | ||||
"$TESTPOOL1 ${pooldevs[1]} spare $vfstab_dev" \ | "$TESTPOOL1 ${pooldevs[1]} spare $swap_dev" \ | ||||
"$TESTPOOL1 ${pooldevs[1]} spare ${pooldevs[1]}" | "$TESTPOOL1 ${pooldevs[1]} spare ${pooldevs[1]}" | ||||
typeset -i i=0 | typeset -i i=0 | ||||
while (( i < ${#arg[*]} )); do | while (( i < ${#arg[*]} )); do | ||||
log_mustnot $ZPOOL create ${arg[i]} | log_mustnot $ZPOOL create ${arg[i]} | ||||
log_mustnot $ZPOOL create -f ${arg[i]} | log_mustnot $ZPOOL create -f ${arg[i]} | ||||
(( i = i + 1 )) | (( i = i + 1 )) | ||||
done | done | ||||
# - a dump device, | |||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241070 | |||||
# When that bug is fixed, add $dump_dev to $arg and remove this block. | |||||
log_must $ZPOOL create "$TESTPOOL1 ${pooldevs[1]} spare $dump_dev" | |||||
log_must $ZPOOL create -f "$TESTPOOL1 ${pooldevs[1]} spare $dump_dev" | |||||
# now destroy the pool to be polite | # now destroy the pool to be polite | ||||
log_must $ZPOOL destroy -f $TESTPOOL | log_must $ZPOOL destroy -f $TESTPOOL | ||||
# | |||||
# - specified as the dedicated dump device, | |||||
# This part of the test can only be run on platforms for which DUMPADM is | |||||
# defined; ie Solaris | |||||
# | |||||
if [[ -n $DUMPADM ]]; then | |||||
# create/destroy a pool as a simple way to set the partitioning | |||||
# back to something normal so we can use this $disk as a dump device | |||||
cleanup_devices $dump_dev | |||||
log_must $DUMPADM -u -d /dev/$dump_dev | |||||
log_mustnot $ZPOOL create $TESTPOOL1 ${pooldevs[1]} spare "$dump_dev" | |||||
log_mustnot $ZPOOL create -f $TESTPOOL1 ${pooldevs[1]} spare "$dump_dev" | |||||
fi | |||||
log_pass "'zpool create [-f]' with hot spare is failed as expected with inapplicable scenarios." | log_pass "'zpool create [-f]' with hot spare is failed as expected with inapplicable scenarios." |