diff options
13 files changed, 72 insertions, 218 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/cleanup.ksh index 48a6bc301..33bd94fdc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/cleanup.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/setup.ksh index 9ede9e48f..13bd33ee4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/setup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/setup.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.cfg index e1c7d47ce..a634b8b3c 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.cfg @@ -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" +export VOLSIZE=$MINVDEVSIZE + +echo $DISKS | read DISK0 DISK1 DISK2 -if is_linux || is_freebsd; then +if is_linux; then + export DISK_ARRAY_NUM=3 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 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib index 9a7310e3a..a7a1fb330 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib @@ -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 - -} diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_001_pos.ksh index a0fc0eade..aa50de3be 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_001_pos.ksh @@ -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}\"" - - ;; -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 +pooldevs="${DISK0} \ + \"${DISK0} ${DISK1}\" \ + \"${DISK0} ${DISK1} ${DISK2}\"" +mirrordevs="\"${DISK0} ${DISK1}\"" +raidzdevs="\"${DISK0} ${DISK1}\"" + +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" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_002_pos.ksh index eb492311a..67810bbf9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_002_pos.ksh @@ -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." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_004_pos.ksh index 61ce4ec69..64e52960d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_004_pos.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_005_pos.ksh index bcb463301..c40f8db6f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_005_pos.ksh @@ -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." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_006_pos.ksh index 6d47365ed..2c3f488ea 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_006_pos.ksh @@ -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." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_007_neg.ksh index 081815bd0..4e9535c1c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_007_neg.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_008_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_008_neg.ksh index edcdd32c9..77a899f70 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_008_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_008_neg.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_009_neg.ksh index 1fc1a046a..7ffe9512a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_009_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_009_neg.ksh @@ -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." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_010_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_010_pos.ksh index 8b8eade48..771b689c9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_010_pos.ksh @@ -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 } |