Skip to content

Commit

Permalink
ZFS: fix several of the "zpool create" tests
Browse files Browse the repository at this point in the history
* Remove zpool_create_013_neg.  FreeBSD doesn't have an equivalent of
  Solaris's metadevices.  GEOM would be the equivalent, but since all geoms
  are the same from ZFS's perspective, this test would be redundant with
  zpool_create_012_neg

* Remove zpool_create_014_neg.  FreeBSD does not support swapping to regular
  files.

* Remove zpool_create_016_pos.  This test is redundant with literally every
  other test that creates a disk-backed pool.

* s:/etc/vfstab:/etc/fstab in zpool_create_011_neg

* Delete the VTOC-related portion of zpool_create_008_pos.  FreeBSD doesn't
  use VTOC.

* Replace dumpadm with dumpon and swap with swapon in multiple tests.

* In zpool_create_015_neg, don't require "zpool create -n" to fail.  It's
  reasonable for that variant to succeed, because it doesn't actually open
  the zvol.

* Greatly simplify zpool_create_012_neg.  Make it safer, too, but not
  interfering with the system's regular swap devices.

* Expect zpool_create_011_neg to fail (PR 241070)

* Delete some redundant cleanup steps in various tests

* Remove some unneeeded ATF timeout specifications.  The default is fine.

PR:		241070
MFC after:	2 weeks
Sponsored by:	Axcient
  • Loading branch information
asomers committed Oct 5, 2019
1 parent dd4596e commit ddf6ddc
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 564 deletions.
4 changes: 4 additions & 0 deletions ObsoleteFiles.inc
Expand Up @@ -38,6 +38,10 @@
# xargs -n1 | sort | uniq -d;
# done

# 20191003: Remove useless ZFS tests
OLD_FILES+=usr/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_013_neg.ksh
OLD_FILES+=usr/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_014_neg.ksh
OLD_FILES+=usr/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_016_pos.ksh
# 20190910: mklocale(1) and colldef(1) removed
OLD_FILES+=usr/bin/mklocale
OLD_FILES+=usr/share/man/man1/mklocale.1.gz
Expand Down
1 change: 1 addition & 0 deletions tests/sys/cddl/zfs/include/commands.txt
Expand Up @@ -65,6 +65,7 @@
/usr/bin/dirname
/usr/bin/du
#%%STFSUITEDIR%%/bin/dumpadm
/sbin/dumpon
/bin/echo
/usr/bin/egrep
/usr/bin/env
Expand Down
3 changes: 0 additions & 3 deletions tests/sys/cddl/zfs/tests/cli_root/zpool_create/Makefile
Expand Up @@ -13,16 +13,13 @@ TEST_METADATA+= is_exclusive=true
${PACKAGE}FILES+= zpool_create_003_pos.ksh
${PACKAGE}FILES+= zpool_create_020_pos.ksh
${PACKAGE}FILES+= zpool_create_017_neg.ksh
${PACKAGE}FILES+= zpool_create_013_neg.ksh
${PACKAGE}FILES+= zpool_create_016_pos.ksh
${PACKAGE}FILES+= zpool_create_012_neg.ksh
${PACKAGE}FILES+= zpool_create_006_pos.ksh
${PACKAGE}FILES+= zpool_create_002_pos.ksh
${PACKAGE}FILES+= zpool_create_021_pos.ksh
${PACKAGE}FILES+= zpool_create_007_neg.ksh
${PACKAGE}FILES+= setup.ksh
${PACKAGE}FILES+= cleanup.ksh
${PACKAGE}FILES+= zpool_create_014_neg.ksh
${PACKAGE}FILES+= zpool_create_010_neg.ksh
${PACKAGE}FILES+= zpool_create_019_pos.ksh
${PACKAGE}FILES+= zpool_create_008_pos.ksh
Expand Down
34 changes: 10 additions & 24 deletions tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create.kshlib
Expand Up @@ -96,36 +96,22 @@ function clean_blockfile
#
# Find the storage device in /etc/vfstab
#
function find_vfstab_dev
function find_fstab_dev
{
typeset vfstab="/etc/vfstab"
typeset tmpfile="$TMPDIR/vfstab.tmp"
typeset vfstabdev
typeset vfstabdevs=""
typeset fstab="/etc/fstab"
typeset tmpfile="$TMPDIR/fstab.tmp"
typeset fstabdev
typeset fstabdevs=""
typeset line

$CAT $vfstab | $GREP "^/dev" >$tmpfile
$CAT $fstab | $GREP "^/dev" >$tmpfile
while read -r line
do
vfstabdev=`$ECHO "$line" | $AWK '{print $1}'`
vfstabdev=${vfstabdev%%:}
vfstabdevs="$vfstabdev $vfstabdevs"
fstabdev=`$ECHO "$line" | $AWK '{print $1}'`
fstabdev=${fstabdev%%:}
fstabdevs="$fstabdev $fstabdevs"
done <$tmpfile

$RM -f $tmpfile
$ECHO $vfstabdevs
$ECHO $fstabdevs
}

#
# Save the systme current dump device configuration
#
function save_dump_dev
{

typeset dumpdev
typeset fnd="Dump device"

dumpdev=`$DUMPADM | $GREP "$fnd" | $CUT -f2 -d : | \
$AWK '{print $1}'`
$ECHO $dumpdev
}
Expand Up @@ -57,102 +57,24 @@

verify_runnable "global"

function cleanup
{
if [[ $exported_pool == true ]]; then
if [[ $force_pool == true ]]; then
log_must $ZPOOL create -f $TESTPOOL ${disk}p1
else
log_must $ZPOOL import $TESTPOOL
fi
fi

if poolexists $TESTPOOL ; then
destroy_pool $TESTPOOL
fi

if poolexists $TESTPOOL1 ; then
destroy_pool $TESTPOOL1
fi

#
# recover it back to EFI label
#
wipe_partition_table $disk
}

#
# create overlap slice 0 and 1 on $disk
#
function create_overlap_slice
{
typeset format_file=$TMPDIR/format_overlap.${TESTCASE_ID}
typeset disk=$1

$ECHO "partition" >$format_file
$ECHO "0" >> $format_file
$ECHO "" >> $format_file
$ECHO "" >> $format_file
$ECHO "0" >> $format_file
$ECHO "200m" >> $format_file
$ECHO "1" >> $format_file
$ECHO "" >> $format_file
$ECHO "" >> $format_file
$ECHO "0" >> $format_file
$ECHO "400m" >> $format_file
$ECHO "label" >> $format_file
$ECHO "" >> $format_file
$ECHO "q" >> $format_file
$ECHO "q" >> $format_file

$FORMAT -e -s -d $disk -f $format_file
typeset -i ret=$?
$RM -fr $format_file

if (( ret != 0 )); then
log_fail "unable to create overlap slice."
fi

return 0
}

log_assert "'zpool create' have to use '-f' scenarios"
log_onexit cleanup

typeset exported_pool=false
typeset force_pool=false

if [[ -n $DISK ]]; then
disk=$DISK
else
disk=$DISK0
fi

# overlapped slices as vdev need -f to create pool

# Make the disk is EFI labeled first via pool creation
create_pool $TESTPOOL $disk
destroy_pool $TESTPOOL

# Make the disk is VTOC labeled since only VTOC label supports overlap
log_must labelvtoc $disk
log_must create_overlap_slice $disk

log_mustnot $ZPOOL create $TESTPOOL ${disk}p1
log_must $ZPOOL create -f $TESTPOOL ${disk}p1
destroy_pool $TESTPOOL

# exported device to be as spare vdev need -f to create pool

log_must $ZPOOL create -f $TESTPOOL $disk
destroy_pool $TESTPOOL
log_must partition_disk $SIZE $disk 6
create_pool $TESTPOOL ${disk}p1 ${disk}p2
log_must $ZPOOL export $TESTPOOL
exported_pool=true
log_mustnot $ZPOOL create $TESTPOOL1 ${disk}p3 spare ${disk}p2
create_pool $TESTPOOL1 ${disk}p3 spare ${disk}p2
force_pool=true
destroy_pool $TESTPOOL1

log_pass "'zpool create' have to use '-f' scenarios"
Expand Up @@ -41,7 +41,7 @@
# 'zpool create' will fail in the following cases:
# existent pool; device is part of an active pool; nested virtual devices;
# differently sized devices without -f option; device being currently
# mounted; devices in /etc/vfstab; specified as the dedicated dump device.
# mounted; devices in /etc/fstab; specified as the dedicated dump device.
#
# STRATEGY:
# 1. Create case scenarios
Expand All @@ -67,8 +67,8 @@ function cleanup
destroy_pool $pool
done

if [[ -n $saved_dump_dev ]]; then
log_must $DUMPADM -u -d $saved_dump_dev
if [[ -n $specified_dump_dev ]]; then
$DUMPON -r $specified_dump_dev
fi
}

Expand All @@ -87,11 +87,11 @@ mirror2="${disk}p4 ${disk}p5"
raidz1=$mirror1
raidz2=$mirror2
diff_size_dev="${disk}p6 ${disk}p7"
vfstab_dev=$(find_vfstab_dev)
specified_dump_dev=${disk}p1
saved_dump_dev=$(save_dump_dev)
fstab_dev=$(find_fstab_dev)
specified_dump_dev=${disk}

lba=$(get_partition_end $disk 6)
$GPART delete -i 7 $disk
set_partition 7 "$lba" $SIZE1 $disk
create_pool "$TESTPOOL" "$pooldev1"

Expand All @@ -112,7 +112,7 @@ set -A arg "$TESTPOOL $pooldev2" \
"$TESTPOOL1 raidz $diff_size_dev" \
"$TESTPOOL1 raidz1 $diff_size_dev" \
"$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \
"$TESTPOOL1 $vfstab_dev" \
"$TESTPOOL1 $fstab_dev" \
"$TESTPOOL1 ${disk}s10" \
"$TESTPOOL1 spare $pooldev2"

Expand All @@ -130,7 +130,7 @@ log_must $ZPOOL destroy -f $TESTPOOL
log_must $ZPOOL create -f $TESTPOOL3 $disk
log_must $ZPOOL destroy -f $TESTPOOL3

log_must $DUMPADM -d /dev/$specified_dump_dev
log_must dumpon $specified_dump_dev
log_mustnot $ZPOOL create -f $TESTPOOL1 "$specified_dump_dev"

# Also check to see that in-use checking prevents us from creating
Expand Down
Expand Up @@ -38,13 +38,12 @@
#
#
# DESCRIPTION:
# 'zpool create' will fail with formal disk slice in swap
# 'zpool create' will fail with disk in swap
#
#
# STRATEGY:
# 1. Get all the disk devices in swap
# 2. For each device, try to create a new pool with this device
# 3. Verify the creation is failed.
# 1. Add a disk to swap
# 2. Try to create a pool on that disk. It should fail.
#
# TESTABILITY: explicit
#
Expand All @@ -60,21 +59,14 @@ verify_runnable "global"

function cleanup
{
if poolexists $TESTPOOL; then
destroy_pool $TESTPOOL
fi
$SWAPOFF $DISK0

}
typeset swap_disks=`$SWAP -l | $GREP "c[0-9].*d[0-9].*s[0-9]" | \
$AWK '{print $1}'`

log_assert "'zpool create' should fail with disk slice in swap."
log_assert "'zpool create' should fail with disk in swap."
log_onexit cleanup

for sdisk in $swap_disks; do
for opt in "-n" "" "-f"; do
log_mustnot $ZPOOL create $opt $TESTPOOL $sdisk
done
done
log_must $SWAPON $DISK0
log_mustnot $ZPOOL create $TESTPOOL $DISK0

log_pass "'zpool create' passed as expected with inapplicable scenario."
log_pass "'zpool create' cannot use a swap disk"

This file was deleted.

0 comments on commit ddf6ddc

Please sign in to comment.