ZTS: Eliminate partitioning from zpool_add

Use file vdevs if we are short on $DISKS.
Also fixed vol recursion for FreeBSD in 004.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10060
This commit is contained in:
Ryan Moeller 2020-02-28 12:46:51 -05:00 committed by GitHub
parent 3f99a3abc7
commit f0410e9806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 73 additions and 219 deletions

View File

@ -32,11 +32,4 @@
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.kshlib
DISK=${DISKS%% *}
if is_mpath_device $DISK; then
delete_partitions
fi
cleanup_devices $DISKS
log_pass

View File

@ -34,28 +34,4 @@
verify_runnable "global"
if ! is_physical_device $DISKS; then
log_unsupported "This directory cannot be run on raw files."
fi
disk1=${DISKS%% *}
if is_mpath_device $disk1; then
delete_partitions
fi
if [[ -n $DISK ]]; then
#
# Use 'zpool create' to clean up the information in
# in the given disk to avoid slice overlapping.
#
cleanup_devices $DISK
partition_disk $SIZE $DISK 7
else
for disk in `echo $DISKSARRAY`; do
cleanup_devices $disk
partition_disk $SIZE $disk 7
done
fi
log_pass

View File

@ -28,57 +28,12 @@
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
#
export DISK_ARRAY_NUM=0
export DISK_ARRAY_LIMIT=4
export DISKSARRAY=""
function set_disks
{
set -A disk_array $(find_disks $DISKS)
if (( ${#disk_array[*]} <= 1 )); then
export DISK=${DISKS%% *}
else
export DISK=""
typeset -i i=0
while (( i < ${#disk_array[*]} )); do
export DISK${i}="${disk_array[$i]}"
DISKSARRAY="$DISKSARRAY ${disk_array[$i]}"
(( i = i + 1 ))
(( i>$DISK_ARRAY_LIMIT )) && break
done
export DISK_ARRAY_NUM=$i
export DISKSARRAY
fi
if (( $DISK_ARRAY_NUM == 0 )); then
export disk=$DISK
else
export disk=$DISK0
fi
}
set_disks
export SIZE="$(((MINVDEVSIZE / (1024 * 1024)) * 2))m"
if is_linux || is_freebsd; then
set_device_dir
set_slice_prefix
export SLICE0=1
export SLICE1=2
export SLICE3=4
export SLICE4=5
export SLICE5=6
export SLICE6=7
else
export SLICE0=0
export SLICE1=1
export SLICE3=3
export SLICE4=4
export SLICE5=5
export SLICE6=6
fi
export VOLSIZE=$MINVDEVSIZE
echo $DISKS | read DISK0 DISK1 DISK2
if is_linux; then
export DISK_ARRAY_NUM=3
set_device_dir
fi

View File

@ -109,20 +109,3 @@ function save_dump_dev
fi
echo $dumpdev
}
#
# Common cleanup routine for partitions used in testing
#
function partition_cleanup
{
if [[ -n $DISK ]]; then
partition_disk $SIZE $DISK 7
else
typeset disk=""
for disk in $DISK0 $DISK1; do
partition_disk $SIZE $disk 7
done
fi
}

View File

@ -47,10 +47,8 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL && \
destroy_pool $TESTPOOL
partition_cleanup
poolexists $TESTPOOL && destroy_pool $TESTPOOL
rm -f $disk0 $disk1
}
log_assert "'zpool add <pool> <vdev> ...' can add devices to the pool."
@ -59,36 +57,15 @@ log_onexit cleanup
set -A keywords "" "mirror" "raidz" "raidz1" "spare"
case $DISK_ARRAY_NUM in
0|1)
pooldevs="${disk}${SLICE_PREFIX}${SLICE0} \
${DEV_DSKDIR}/${disk}${SLICE_PREFIX}${SLICE0} \
\"${disk}${SLICE_PREFIX}${SLICE0} \
${disk}${SLICE_PREFIX}${SLICE1}\""
mirrordevs="\"${DEV_DSKDIR}/${disk}${SLICE_PREFIX}${SLICE0} \
${disk}${SLICE_PREFIX}${SLICE1}\""
raidzdevs="\"${DEV_DSKDIR}/${disk}${SLICE_PREFIX}${SLICE0} \
${disk}${SLICE_PREFIX}${SLICE1}\""
pooldevs="${DISK0} \
\"${DISK0} ${DISK1}\" \
\"${DISK0} ${DISK1} ${DISK2}\""
mirrordevs="\"${DISK0} ${DISK1}\""
raidzdevs="\"${DISK0} ${DISK1}\""
;;
2|*)
pooldevs="${DISK0}${SLICE_PREFIX}${SLICE0} \
\"${DEV_DSKDIR}/${DISK0}${SLICE_PREFIX}${SLICE0} \
${DISK1}${SLICE_PREFIX}${SLICE0}\" \
\"${DISK0}${SLICE_PREFIX}${SLICE0} \
${DISK0}${SLICE_PREFIX}${SLICE1} \
${DISK1}${SLICE_PREFIX}${SLICE1}\"\
\"${DISK0}${SLICE_PREFIX}${SLICE0} \
${DISK1}${SLICE_PREFIX}${SLICE0} \
${DISK0}${SLICE_PREFIX}${SLICE1}\
${DISK1}${SLICE_PREFIX}${SLICE1}\""
mirrordevs="\"${DEV_DSKDIR}/${DISK0}${SLICE_PREFIX}${SLICE0} \
${DISK1}${SLICE_PREFIX}${SLICE0}\""
raidzdevs="\"${DEV_DSKDIR}/${DISK0}${SLICE_PREFIX}${SLICE0} \
${DISK1}${SLICE_PREFIX}${SLICE0}\""
;;
esac
disk0=$TEST_BASE_DIR/disk0
disk1=$TEST_BASE_DIR/disk1
truncate -s $MINVDEVSIZE $disk0 $disk1
typeset -i i=0
typeset vdev
@ -101,7 +78,7 @@ while (( $i < ${#keywords[*]} )); do
case ${keywords[i]} in
""|spare)
for vdev in "${poolarray[@]}"; do
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE6}"
create_pool "$TESTPOOL" "$disk0"
log_must poolexists "$TESTPOOL"
log_must zpool add -f "$TESTPOOL" ${keywords[i]} $vdev
log_must vdevs_in_pool "$TESTPOOL" "$vdev"
@ -112,8 +89,7 @@ while (( $i < ${#keywords[*]} )); do
mirror)
for vdev in "${mirrorarray[@]}"; do
create_pool "$TESTPOOL" "${keywords[i]}" \
"${disk}${SLICE_PREFIX}${SLICE4}" \
"${disk}${SLICE_PREFIX}${SLICE5}"
"$disk0" "$disk1"
log_must poolexists "$TESTPOOL"
log_must zpool add "$TESTPOOL" ${keywords[i]} $vdev
log_must vdevs_in_pool "$TESTPOOL" "$vdev"
@ -124,8 +100,7 @@ while (( $i < ${#keywords[*]} )); do
raidz|raidz1)
for vdev in "${raidzarray[@]}"; do
create_pool "$TESTPOOL" "${keywords[i]}" \
"${disk}${SLICE_PREFIX}${SLICE4}" \
"${disk}${SLICE_PREFIX}${SLICE5}"
"$disk0" "$disk1"
log_must poolexists "$TESTPOOL"
log_must zpool add "$TESTPOOL" ${keywords[i]} $vdev
log_must vdevs_in_pool "$TESTPOOL" "$vdev"

View File

@ -48,10 +48,7 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL && \
destroy_pool $TESTPOOL
partition_cleanup
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_assert "'zpool add -f <pool> <vdev> ...' can successfully add" \
@ -59,14 +56,13 @@ log_assert "'zpool add -f <pool> <vdev> ...' can successfully add" \
log_onexit cleanup
create_pool "$TESTPOOL" mirror "${disk}${SLICE_PREFIX}${SLICE0}" \
"${disk}${SLICE_PREFIX}${SLICE1}"
log_must poolexists "$TESTPOOL"
create_pool $TESTPOOL mirror $DISK0 $DISK1
log_must poolexists $TESTPOOL
log_mustnot zpool add "$TESTPOOL" ${disk}${SLICE_PREFIX}${SLICE3}
log_mustnot vdevs_in_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE3}"
log_mustnot zpool add $TESTPOOL $DISK2
log_mustnot vdevs_in_pool $TESTPOOL $DISK2
log_must zpool add -f "$TESTPOOL" ${disk}${SLICE_PREFIX}${SLICE3}
log_must vdevs_in_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE3}"
log_must zpool add -f $TESTPOOL $DISK2
log_must vdevs_in_pool $TESTPOOL $DISK2
log_pass "'zpool add -f <pool> <vdev> ...' executes successfully."

View File

@ -47,31 +47,30 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL && \
destroy_pool "$TESTPOOL"
datasetexists $TESTPOOL1/$TESTVOL && \
log_must zfs destroy -f $TESTPOOL1/$TESTVOL
poolexists $TESTPOOL1 && \
destroy_pool "$TESTPOOL1"
partition_cleanup
poolexists $TESTPOOL && destroy_pool $TESTPOOL
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
if [ -n "$recursive" ]; then
set_tunable64 VOL_RECURSIVE $recursive
fi
}
log_assert "'zpool add <pool> <vdev> ...' can add zfs volume to the pool."
log_onexit cleanup
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must poolexists "$TESTPOOL"
create_pool $TESTPOOL $DISK0
log_must poolexists $TESTPOOL
create_pool "$TESTPOOL1" "${disk}${SLICE_PREFIX}${SLICE1}"
log_must poolexists "$TESTPOOL1"
create_pool $TESTPOOL1 $DISK1
log_must poolexists $TESTPOOL1
log_must zfs create -V $VOLSIZE $TESTPOOL1/$TESTVOL
block_device_wait
log_must zpool add "$TESTPOOL" $ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL
if is_freebsd; then
recursive=$(get_tunable VOL_RECURSIVE)
log_must set_tunable64 VOL_RECURSIVE 1
fi
log_must zpool add $TESTPOOL $ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL
log_must vdevs_in_pool "$TESTPOOL" "$ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL"

View File

@ -50,16 +50,12 @@ verify_runnable "global"
function cleanup
{
poolexists "$TESTPOOL" && \
destroy_pool "$TESTPOOL"
poolexists "$TESTPOOL1" && \
destroy_pool "$TESTPOOL1"
poolexists $TESTPOOL && destroy_pool $TESTPOOL
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
if [[ -n $saved_dump_dev ]]; then
log_must eval "dumpadm -u -d $saved_dump_dev > /dev/null"
fi
partition_cleanup
}
log_assert "'zpool add' should fail with inapplicable scenarios."
@ -69,27 +65,27 @@ log_onexit cleanup
mnttab_dev=$(find_mnttab_dev)
vfstab_dev=$(find_vfstab_dev)
saved_dump_dev=$(save_dump_dev)
dump_dev=${disk}${SLICE_PREFIX}${SLICE3}
dump_dev=$DISK2
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must poolexists "$TESTPOOL"
create_pool $TESTPOOL $DISK0
log_must poolexists $TESTPOOL
create_pool "$TESTPOOL1" "${disk}${SLICE_PREFIX}${SLICE1}"
log_must poolexists "$TESTPOOL1"
create_pool $TESTPOOL1 $DISK1
log_must poolexists $TESTPOOL1
unset NOINUSE_CHECK
log_mustnot zpool add -f "$TESTPOOL" ${disk}${SLICE_PREFIX}${SLICE1}
log_mustnot zpool add -f "$TESTPOOL" $mnttab_dev
log_mustnot zpool add -f $TESTPOOL $DISK1
log_mustnot zpool add -f $TESTPOOL $mnttab_dev
if is_linux; then
log_mustnot zpool add "$TESTPOOL" $vfstab_dev
log_mustnot zpool add $TESTPOOL $vfstab_dev
else
log_mustnot zpool add -f "$TESTPOOL" $vfstab_dev
log_mustnot zpool add -f $TESTPOOL $vfstab_dev
fi
if is_illumos; then
log_must eval "new_fs ${DEV_DSKDIR}/$dump_dev > /dev/null 2>&1"
log_must eval "dumpadm -u -d ${DEV_DSKDIR}/$dump_dev > /dev/null"
log_mustnot zpool add -f "$TESTPOOL" $dump_dev
log_mustnot zpool add -f $TESTPOOL $dump_dev
fi
log_pass "'zpool add' should fail with inapplicable scenarios."

View File

@ -46,14 +46,8 @@ verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && \
destroy_pool $TESTPOOL1
poolexists $TESTPOOL && \
destroy_pool $TESTPOOL
[[ -d $TESTDIR ]] && log_must rm -rf $TESTDIR
partition_cleanup
poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
rm -rf $TESTDIR
}
log_assert "Adding a large number of file based vdevs to a zpool works."
@ -66,12 +60,12 @@ create_pool "$TESTPOOL1" "$TESTDIR/file.00"
vdevs_list=$(echo $TESTDIR/file.{01..16})
log_must truncate -s $MINVDEVSIZE $vdevs_list
log_must zpool add -f "$TESTPOOL1" $vdevs_list
log_must vdevs_in_pool "$TESTPOOL1" "$vdevs_list"
log_must zpool add -f $TESTPOOL1 $vdevs_list
log_must vdevs_in_pool $TESTPOOL1 "$vdevs_list"
# Attempt to add a file based vdev that's too small.
log_must truncate -s 32m $TESTDIR/broken_file
log_mustnot zpool add -f "$TESTPOOL1" ${TESTDIR}/broken_file
log_mustnot vdevs_in_pool "$TESTPOOL1" "${TESTDIR}/broken_file"
log_mustnot zpool add -f $TESTPOOL1 ${TESTDIR}/broken_file
log_mustnot vdevs_in_pool $TESTPOOL1 ${TESTDIR}/broken_file
log_pass "Adding a large number of file based vdevs to a zpool works."

View File

@ -46,10 +46,7 @@ verify_runnable "global"
function cleanup
{
poolexists "$TESTPOOL" && \
destroy_pool "$TESTPOOL"
partition_cleanup
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_assert "'zpool add' should return an error with badly-formed parameters."
@ -57,10 +54,10 @@ log_assert "'zpool add' should return an error with badly-formed parameters."
log_onexit cleanup
set -A args "" "-f" "-n" "-?" "-nf" "-fn" "-f -n" "--f" "-blah" \
"-? $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE1}"
"-? $TESTPOOL $DISK1"
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must poolexists "$TESTPOOL"
create_pool $TESTPOOL $DISK0
log_must poolexists $TESTPOOL
typeset -i i=0
while (( $i < ${#args[*]} )); do

View File

@ -46,22 +46,18 @@ verify_runnable "global"
function cleanup
{
poolexists "$TESTPOOL" && \
destroy_pool "$TESTPOOL"
partition_cleanup
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_assert "'zpool add' should return an error with nonexistent pools and vdevs"
log_onexit cleanup
set -A args "" "-f nonexistent_pool ${disk}${SLICE_PREFIX}${SLICE1}" \
set -A args "" "-f nonexistent_pool $DISK1" \
"-f $TESTPOOL nonexistent_vdev"
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must poolexists "$TESTPOOL"
create_pool $TESTPOOL $DISK0
log_must poolexists $TESTPOOL
typeset -i i=0
while (( $i < ${#args[*]} )); do

View File

@ -47,12 +47,7 @@ verify_runnable "global"
function cleanup
{
poolexists "$TESTPOOL" && \
destroy_pool "$TESTPOOL"
partition_cleanup
poolexists $TESTPOOL && destroy_pool $TESTPOOL
}
log_assert "'zpool add' should fail if vdevs are the same or vdev is " \
@ -60,12 +55,11 @@ log_assert "'zpool add' should fail if vdevs are the same or vdev is " \
log_onexit cleanup
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must poolexists "$TESTPOOL"
create_pool $TESTPOOL $DISK0
log_must poolexists $TESTPOOL
log_mustnot zpool add -f "$TESTPOOL" ${disk}${SLICE_PREFIX}${SLICE1} \
${disk}${SLICE_PREFIX}${SLICE1}
log_mustnot zpool add -f "$TESTPOOL" ${disk}${SLICE_PREFIX}${SLICE0}
log_mustnot zpool add -f $TESTPOOL $DISK1 $DISK1
log_mustnot zpool add -f $TESTPOOL $DISK0
log_pass "'zpool add' get fail as expected if vdevs are the same or vdev is " \
"contained in the given pool."

View File

@ -51,7 +51,7 @@ function cleanup
typeset -i i=0
while ((i < 10)); do
log_must rm -f $TEST_BASE_DIR/vdev$i
rm -f $TEST_BASE_DIR/vdev$i
((i += 1))
done
}