]> git.proxmox.com Git - mirror_zfs.git/commitdiff
ZTS: Another round of changes for FreeBSD
authorRyan Moeller <ryan@iXsystems.com>
Fri, 6 Mar 2020 17:31:32 +0000 (12:31 -0500)
committerGitHub <noreply@github.com>
Fri, 6 Mar 2020 17:31:32 +0000 (09:31 -0800)
Highlights:
* is_linux -> is_illumos swaps
* make block_device_wait more clever when paths are given
* slightly optimize default_cleanup_noexit
* remove platform differences in user_run
* temporarily expect non-libfetch behavior for keylocation=/foo/bar
* fix sharenfs exceptions
* don't test multihost property
* fix misc broken platform checks
* clear zinjected faults in removal_resume_export callback

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10092

tests/zfs-tests/include/blkdev.shlib
tests/zfs-tests/include/libtest.shlib
tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_keylocation.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_023_neg.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh
tests/zfs-tests/tests/functional/large_files/large_files_002_pos.ksh
tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib
tests/zfs-tests/tests/functional/redacted_send/redacted_holes.ksh
tests/zfs-tests/tests/functional/removal/removal_resume_export.ksh
tests/zfs-tests/tests/functional/rsend/send_hole_birth.ksh

index e459e9e46aae13baf0fe6767b8a3459328ebf7ab..93334e4b4f861bbe8e8c765fda25f6d608a77c73 100644 (file)
@@ -74,14 +74,33 @@ function block_device_wait
 {
        if is_linux; then
                udevadm trigger $*
-               typeset local start=$SECONDS
+               typeset start=$SECONDS
                udevadm settle
-               typeset local elapsed=$((SECONDS - start))
+               typeset elapsed=$((SECONDS - start))
                [[ $elapsed > 60 ]] && \
                    log_note udevadm settle time too long: $elapsed
        elif is_freebsd; then
-               sleep 3
+               if [[ ${#@} -eq 0 ]]; then
+                       sleep 3
+                       return
+               fi
        fi
+       # Poll for the given paths to appear, but give up eventually.
+       typeset -i i
+       for (( i = 0; i < 5; ++i )); do
+               typeset missing=false
+               typeset dev
+               for dev in "${@}"; do
+                       if ! [[ -f $dev ]]; then
+                               missing=true
+                               break
+                       fi
+               done
+               if ! $missing; then
+                       break
+               fi
+               sleep ${#@}
+       done
 }
 
 #
index 76743003e465bf1d439a7a22f423b7c4bbf236bc..b5b00144ed5a6e0fc0cfd46c56e50125f05e1f59 100644 (file)
@@ -612,8 +612,8 @@ function default_cleanup_noexit
                                then
                                        destroy_pool $pool
                                fi
-                               ALL_POOLS=$(get_all_pools)
                        done
+                       ALL_POOLS=$(get_all_pools)
                done
 
                zfs mount -a
@@ -3315,13 +3315,7 @@ function user_run
        shift
 
        log_note "user:$user $@"
-       if is_freebsd; then
-               eval "su \$user -c \"$@\"" > $TEST_BASE_DIR/out 2>$TEST_BASE_DIR/err
-               return $?
-       else
-               eval su - \$user -c \"$@\" > $TEST_BASE_DIR/out 2>$TEST_BASE_DIR/err
-               return $?
-       fi
+       eval su - \$user -c \"$@\" > $TEST_BASE_DIR/out 2>$TEST_BASE_DIR/err
 }
 
 #
index 00e7ff1a96ca932ade46ca46357576c7ceb32a20..0d2e7ab8f29807ce41e01972805e6cc57af49f83 100755 (executable)
@@ -64,9 +64,10 @@ log_must zfs create -o encryption=on -o keyformat=passphrase \
        -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/$TESTFS1
 
 log_mustnot zfs set keylocation=none $TESTPOOL/$TESTFS1
-if is_linux; then
+if true; then
        log_mustnot zfs set keylocation=/$TESTPOOL/pkey $TESTPOOL/$TESTFS1
 else
+       ### SOON: ###
        # file:///$TESTPOOL/pkey and /$TESTPOOL/pkey are equivalent on FreeBSD
        # thanks to libfetch. Eventually we want to make the other platforms
        # work this way as well, either by porting libfetch or by other means.
index 0f43db45b61dd5ecb5478d89419bd7b2231005a4..f101521bd3e8840d0b02025c7e50f7a0411db3c0 100755 (executable)
@@ -84,7 +84,7 @@ while (( $i < ${#args[*]} )); do
        typeset arg=${args[i]}
        if is_freebsd; then
                # FreeBSD does not strictly validate share opts (yet).
-               if [[ $arg == "-o sharenfs="* ]]; then
+               if [[ $arg == "sharenfs="* ]]; then
                        ((i = i + 1))
                        continue
                fi
index 53d6fd3052c0410491763b9e4ad5c9795787df82..222c4aebe5bcb09745d9e162794920400a0dbe0f 100755 (executable)
@@ -138,7 +138,7 @@ for option in "" "-Df"; do
                                if ((nfs_share_bit == 1)); then
                                        log_note "Set sharenfs=on $pool"
                                        log_must zfs set sharenfs=on $pool
-                                       log_must is_shared $pool
+                                       ! is_freebsd && log_must is_shared $pool
                                        f_share="true"
                                        nfs_flag="sharenfs=on"
                                fi
@@ -181,19 +181,21 @@ for option in "" "-Df"; do
                                        for fs in $mount_fs; do
                                                log_must ismounted $pool/$fs
                                                [[ -n $f_share ]] && \
+                                                   ! is_freebsd && \
                                                    log_must is_shared $pool/$fs
                                        done
 
                                        for fs in $nomount_fs; do
                                                log_mustnot ismounted $pool/$fs
-                                               log_mustnot is_shared $pool/$fs
+                                               ! is_freebsd && \
+                                                   log_mustnot is_shared $pool/$fs
                                        done
                                        ((guid_bit = guid_bit + 1))
                                done
                                # reset nfsshare=off
                                if [[ -n $f_share ]]; then
                                        log_must zfs set sharenfs=off $pool
-                                       log_mustnot is_shared $pool
+                                       ! is_freebsd && log_mustnot is_shared $pool
                                fi
                                ((nfs_share_bit = nfs_share_bit + 1))
                        done
index 32078ad3f44ffd62ecd7fac94fabd4d3ec19aecd..1aff8d31d91c98ecc57b9923fb4a59189ad3897a 100755 (executable)
@@ -35,7 +35,7 @@ function cleanup
        destroy_pool $TESTPOOL
        destroy_pool $TESTPOOL2
        rm -f $DEVICE1 $DEVICE2
-       log_must mmp_clear_hostid
+       ! is_freebsd && log_must mmp_clear_hostid
 }
 
 function setup_mirror
@@ -48,9 +48,8 @@ function setup_mirror
 log_assert "'zpool split' can set new property values on the new pool"
 log_onexit cleanup
 
-if [ -e $HOSTID_FILE ]; then
-       log_unsupported "System has existing $HOSTID_FILE file"
-fi
+DEVICE1="$TEST_BASE_DIR/device-1"
+DEVICE2="$TEST_BASE_DIR/device-2"
 
 typeset good_props=('comment=text' 'ashift=12' 'multihost=on'
     'listsnapshots=on' 'autoexpand=on' 'autoreplace=on'
@@ -59,12 +58,15 @@ typeset bad_props=("bootfs=$TESTPOOL2/bootfs" 'version=28' 'ashift=4'
     'allocated=1234' 'capacity=5678' 'multihost=none'
     'feature@async_destroy=disabled' 'feature@xxx_fake_xxx=enabled'
     'propname=propval' 'readonly=on')
-
-DEVICE1="$TEST_BASE_DIR/device-1"
-DEVICE2="$TEST_BASE_DIR/device-2"
-
-# Needed to set multihost=on
-log_must mmp_set_hostid $HOSTID1
+if ! is_freebsd; then
+       good_props+=('multihost=on')
+       bad_props+=('multihost=none')
+       if [ -e $HOSTID_FILE ]; then
+               log_unsupported "System has existing $HOSTID_FILE file"
+       fi
+       # Needed to set multihost=on
+       log_must mmp_set_hostid $HOSTID1
+fi
 
 # Verify we can set a combination of valid property values on the new pool
 for prop in "${good_props[@]}"
index b9289ed5ea5fb17959f0fc9dd70f09ddf8971228..255a8f8b5ad616b4220e27cbea32a333021328a9 100755 (executable)
@@ -51,7 +51,7 @@ log_must ulimit -f 1024
 log_mustnot sh -c 'dd if=/dev/zero of=$TESTDIR/ulimit_write_file bs=1M count=2'
 log_must rm $TESTDIR/ulimit_write_file
 # FreeBSD allows the sparse file because space has not been allocated.
-if !is_freebsd; then
+if ! is_freebsd; then
        log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file'
        log_must rm $TESTDIR/ulimit_trunc_file
 fi
index 1a942a634c859cc8e40c01a60305829a1855331b..30101939db645f46908e67e9646d61bc22ef3dde 100644 (file)
@@ -63,11 +63,11 @@ function setup_embedded
        typeset recsize
        typeset mntpnt=$(get_prop mountpoint $sendfs)
        for recsize in 512 1024 2048 4096 8192 16384; do
-               if is_linux; then
+               if is_illumos; then
+                       log_must mkholes -d $((recsize - 8)):8 $mntpnt/$recsize
+               else
                        log_must dd if=/dev/urandom of=$mntpnt/$recsize bs=8 \
                            count=1 seek=$(((recsize / 8) - 1))
-               else
-                       log_must mkholes -d $((recsize - 8)):8 $mntpnt/$recsize
                fi
        done
 }
@@ -79,7 +79,12 @@ function setup_holes
        typeset mntpnt=$(get_prop mountpoint $sendfs)
        typeset M=$((1024 * 1024))
 
-       if is_linux; then
+       if is_illumos; then
+               log_must mkholes -d 0:$((8 * M)) $mntpnt/f1
+               log_must mkholes -d 0:$M -d $((7 * M)):$M $mntpnt/f2
+               log_must mkholes -d $M:$((6 * M)) -h $((7 * M)):$M $mntpnt/f3
+               log_must mkholes -h 0:$((8 * M)) $mntpnt/f4
+       else
                log_must dd if=/dev/urandom of=$mntpnt/f1 bs=8M count=1
 
                log_must dd if=/dev/urandom of=$mntpnt/f2 bs=1M count=1
@@ -87,14 +92,9 @@ function setup_holes
                    conv=notrunc
 
                log_must dd if=/dev/urandom of=$mntpnt/f3 bs=1M count=6 seek=1
-               log_must truncate $mntpnt/f3 --size=$((8 * M))
+               log_must truncate -s $((8 * M)) $mntpnt/f3
 
-               log_must truncate $mntpnt/f4 --size=$((8 * M))
-       else
-               log_must mkholes -d 0:$((8 * M)) $mntpnt/f1
-               log_must mkholes -d 0:$M -d $((7 * M)):$M $mntpnt/f2
-               log_must mkholes -d $M:$((6 * M)) -h $((7 * M)):$M $mntpnt/f3
-               log_must mkholes -h 0:$((8 * M)) $mntpnt/f4
+               log_must truncate -s $((8 * M)) $mntpnt/f4
        fi
 
        log_must zfs create $sendfs/manyrm
@@ -237,15 +237,11 @@ function redacted_cleanup
        typeset ds_list=$@
        typeset ds
 
-       # Verify the receiving pool can still be exported and imported.
-       log_must zpool export $POOL2
-       log_must zpool import $POOL2
-
        for ds in $ds_list; do
-               datasetexists $ds && log_must zfs destroy -R $ds
+               zfs destroy -R $ds
        done
 
-       log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 0
+       set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 0
        rm -f $(get_prop mountpoint $POOL)/tmp/*
 }
 
index 7838514947ebde3579e1ad397e17222160a7d898..d111aa0ef608fa321dc4c7337fb33b30c36d5685 100755 (executable)
@@ -46,11 +46,11 @@ typeset M=$((1024 * 1024))
 log_onexit redacted_cleanup $sendfs $recvfs
 
 # Write holes at the start and end of a non-sparse file.
-if is_linux; then
+if is_illumos; then
+       log_must mkholes -h 0:$M -h $((7 * M)):$M $clone_mnt/f1
+else
        log_must dd if=/dev/zero of=$clone_mnt/f1 bs=1M count=1 conv=notrunc
        log_must dd if=/dev/zero of=$clone_mnt/f1 bs=1M count=1 conv=notrunc seek=7
-else
-       log_must mkholes -h 0:$M -h $((7 * M)):$M $clone_mnt/f1
 fi
 log_must zfs snapshot $clone@snap1
 log_must zfs redact $sendfs@snap book1 $clone@snap1
@@ -72,11 +72,11 @@ log_must zfs rollback -R $clone@snap
 log_must zfs destroy -R $recvfs
 
 # Write data into the middle of a hole.
-if is_linux; then
+if is_illumos; then
+       log_must mkholes -d $((3 * M)):$((2 * M)) $clone_mnt/f2
+else
        log_must dd if=/dev/urandom of=$clone_mnt/f2 bs=1M count=2 seek=3 \
            conv=notrunc
-else
-       log_must mkholes -d $((3 * M)):$((2 * M)) $clone_mnt/f2
 fi
 log_must zfs snapshot $clone@snap1
 log_must zfs redact $sendfs@snap book3 $clone@snap1
index 4f1e63cd06b648c660a2c6f87b11bcfca1bab5bd..142e72754b004582dadf8643377b614fb7907613 100755 (executable)
 
 function cleanup
 {
-       log_must zinject -c all
+       zinject -c all
        default_cleanup_noexit
 }
 
 function callback
 {
+       #
+       # Inject an error so export fails after having just suspended
+       # the removal thread. [spa_inject_ref gets incremented]
+       #
+       log_must zinject -d $REMOVEDISK -D 10:1 $TESTPOOL
+
+       #
+       # Because of the above error export should fail.
+       #
        log_mustnot zpool export $TESTPOOL
+
+       #
+       # Let the removal finish.
+       #
+       log_must zinject -c all
+
        return 0
 }
 
@@ -78,13 +93,7 @@ log_must dd if=/dev/urandom of=$TESTDIR/$TESTFILE0 bs=64M count=32
 log_must zpool add -f $TESTPOOL $NOTREMOVEDISK
 
 #
-# Inject an error so export fails after having just suspended
-# the removal thread. [spa_inject_ref gets incremented]
-#
-log_must zinject -d $REMOVEDISK -D 10:1 $TESTPOOL
-
-#
-# Because of the above error export should fail.
+# Attempt the export with errors injected.
 #
 log_must attempt_during_removal $TESTPOOL $REMOVEDISK callback
 
index cb2a982b6cf060ea222d489dfc3014160ae4bbb6..1dfa97e77358b352a443c3738ca9e75ccb6cfc18 100755 (executable)
@@ -81,7 +81,7 @@ log_must truncate -s 1G /$sendfs/file1
 log_must dd if=/dev/urandom of=/$sendfs/file1 bs=4k count=11264 seek=1152
 log_must zfs snapshot $sendfs@snap1
 
-log_must truncate -s 4194304 /$sendfs/file1
+log_must truncate -s 4M /$sendfs/file1
 log_must dd if=/dev/urandom of=/$sendfs/file1 bs=4k count=152 seek=384 \
     conv=notrunc
 log_must dd if=/dev/urandom of=/$sendfs/file1 bs=4k count=10 seek=1408 \