From 92bd4cabd615684d1fa476f56e73e0d9edf9a902 Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Mon, 24 Feb 2020 13:17:55 -0500 Subject: [PATCH] ZTS: Misc fixes for FreeBSD * Force UFS sync before snap in vol rollback tests * rw is not a valid share option on FreeBSD, use ro instead * zfs_unmount_nested: mountpoint is in the pool, rmdir *before* export * Fix some more platform checks * Fix disappearing group in delegate tests * Don't try delegating for jailed, only root can set it Reviewed-by: John Kennedy Reviewed-by: Brian Behlendorf Signed-off-by: Ryan Moeller Closes #10038 --- .../zfs_rollback/zfs_rollback_common.kshlib | 17 +++++++++++++++-- .../cli_root/zfs_set/canmount_004_pos.ksh | 2 +- .../cli_root/zfs_unmount/zfs_unmount_nested.ksh | 12 ++++++++---- .../functional/delegate/delegate_common.kshlib | 2 +- .../tests/functional/delegate/setup.ksh | 2 +- .../functional/delegate/zfs_allow_002_pos.ksh | 16 ++++++++++++++++ .../functional/delegate/zfs_allow_010_pos.ksh | 3 +-- .../zfs-tests/tests/functional/xattr/setup.ksh | 6 +++--- 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib index f9512a480d18..b2f4b2b8a3ca 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib @@ -83,8 +83,7 @@ function setup_snap_env # Make sure the ufs|ext filesystem hasn't been mounted, # then mount the new ufs|ext filesystem. if ! ismounted $TESTDIR1 $NEWFS_DEFAULT_FS; then - log_must mount \ - $ZVOL_DEVDIR/$TESTPOOL/$TESTVOL $TESTDIR1 + log_must mount $ZVOL_DEVDIR/$VOL $TESTDIR1 fi fi @@ -127,7 +126,21 @@ function setup_snap_env log_must lockfs -f $TESTDIR1 fi fi + if is_freebsd && [[ $dtst == $VOL ]]; then + # Though sync does start a fs sync on + # FreeBSD, it does not wait for it to + # finish. We can force a blocking sync + # by updating the fs mount instead. + # Otherwise, the snapshot might occur + # with the fs in an unmountable state. + log_must mount -ur \ + $ZVOL_DEVDIR/$VOL $TESTDIR1 + fi log_must zfs snapshot $snap + if is_freebsd && [[ $dtst == $VOL ]]; then + log_must mount -uw \ + $ZVOL_DEVDIR/$VOL $TESTDIR1 + fi fi if [[ $createclone == "true" ]]; then if datasetnonexists $clone; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_004_pos.ksh index 11be1af3cf22..e75114efdec0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_004_pos.ksh @@ -44,7 +44,7 @@ verify_runnable "global" # properties -set -A sharenfs_prop "off" "on" "rw" +set -A sharenfs_prop "off" "on" "ro" set -A sharesmb_prop "off" "on" function cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_nested.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_nested.ksh index 73eae6a250c0..987ecca31396 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_nested.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_nested.ksh @@ -45,20 +45,24 @@ function nesting_cleanup log_onexit nesting_cleanup set -A test_depths 30 16 3 +typeset mountpoint=/$TESTPOOL/mnt dsA32=$(printf 'a/%.0s' {1..32})"a" log_must zfs create -p $TESTPOOL/$dsA32 dsB32=$(printf 'b/%.0s' {1..32})"b" log_must zfs create -o mountpoint=none -p $TESTPOOL/$dsB32 -log_mustnot mount -t zfs $TESTPOOL/$dsB32 /mnt +# FreeBSD's mount command ignores the mountpoint property. +if ! is_freebsd; then + log_mustnot mount -t zfs $TESTPOOL/$dsB32 /mnt +fi dsC32=$(printf 'c/%.0s' {1..32})"c" log_must zfs create -o mountpoint=legacy -p $TESTPOOL/$dsC32 log_must mount -t zfs $TESTPOOL/$dsC32 /mnt dsD32=$(printf 'd/%.0s' {1..32})"d" -log_must zfs create -o mountpoint=/$TESTPOOL/mnt -p $TESTPOOL/$dsD32 +log_must zfs create -o mountpoint=$mountpoint -p $TESTPOOL/$dsD32 for d in ${test_depths[@]}; do @@ -152,7 +156,7 @@ for d in ${test_depths[@]}; do fi - # mountpoint=testpool/mnt + # mountpoint=/testpool/mnt ds_pre=$(printf 'd/%.0s' {1..$(($d-2))})"d" ds=$(printf 'd/%.0s' {1..$(($d-1))})"d" ds_post=$(printf 'd/%.0s' {1..$(($d))})"d" @@ -182,8 +186,8 @@ for d in ${test_depths[@]}; do fi done +log_must rmdir $mountpoint # remove the mountpoint we created log_must zpool export $TESTPOOL -log_must rmdir /testpool/mnt # remove the mountpoint we created log_must zpool import $TESTPOOL log_pass "Verified nested dataset are unmounted." diff --git a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib index 6643f938d7a5..073a39f835f4 100644 --- a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib +++ b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib @@ -101,7 +101,7 @@ function verify_perm log_note "Check $type $user $perm $dtst" if ((ret != 0)) ; then - log_note "Fail: $user should have $perm " \ + log_note "Fail: $user should have $perm" \ "on $dtst" return 1 fi diff --git a/tests/zfs-tests/tests/functional/delegate/setup.ksh b/tests/zfs-tests/tests/functional/delegate/setup.ksh index 13d0f3bfb2c7..2f13da750436 100755 --- a/tests/zfs-tests/tests/functional/delegate/setup.ksh +++ b/tests/zfs-tests/tests/functional/delegate/setup.ksh @@ -33,7 +33,7 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/delegate/delegate_common.kshlib -if ! is_linux; then +if is_illumos; then # check svc:/network/nis/client:default state # disable it if the state is ON # and the state will be restored during cleanup.ksh diff --git a/tests/zfs-tests/tests/functional/delegate/zfs_allow_002_pos.ksh b/tests/zfs-tests/tests/functional/delegate/zfs_allow_002_pos.ksh index 23ed806ad75d..fc603eae19dc 100755 --- a/tests/zfs-tests/tests/functional/delegate/zfs_allow_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/delegate/zfs_allow_002_pos.ksh @@ -50,6 +50,14 @@ function cleanup { if id $STAFF_GROUP > /dev/null 2>&1; then log_must del_user $STAFF_GROUP + if is_freebsd; then + # pw userdel also deletes the group with the same name + # and has no way to opt out of this behavior (yet). + # Recreate the group as a workaround. + log_must add_group $STAFF_GROUP + log_must add_user $STAFF_GROUP $STAFF1 + log_must add_user $STAFF_GROUP $STAFF2 + fi fi restore_root_datasets @@ -71,6 +79,14 @@ done log_must restore_root_datasets log_must del_user $STAFF_GROUP +if is_freebsd; then + # pw userdel also deletes the group with the same name + # and has no way to opt out of this behavior (yet). + # Recreate the group as a workaround. + log_must add_group $STAFF_GROUP + log_must add_user $STAFF_GROUP $STAFF1 + log_must add_user $STAFF_GROUP $STAFF2 +fi for dtst in $datasets ; do log_must zfs allow $STAFF_GROUP $perms $dtst log_must verify_perm $dtst $perms $STAFF1 $STAFF2 diff --git a/tests/zfs-tests/tests/functional/delegate/zfs_allow_010_pos.ksh b/tests/zfs-tests/tests/functional/delegate/zfs_allow_010_pos.ksh index 0cba911ab071..3a8ef5e6251b 100755 --- a/tests/zfs-tests/tests/functional/delegate/zfs_allow_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/delegate/zfs_allow_010_pos.ksh @@ -93,7 +93,7 @@ elif is_freebsd; then # Permission Filesystem Volume # # Removed for FreeBSD -# - zoned - spelled "jailed" +# - jailed - jailing requires superuser privileges # - sharenfs - sharing requires superuser privileges # - share - sharing requires superuser privileges # - xattr - Not supported on FreeBSD @@ -125,7 +125,6 @@ set -A perms create true false \ clone true true \ rename true true \ promote true true \ - jailed true false \ receive true false \ destroy true true diff --git a/tests/zfs-tests/tests/functional/xattr/setup.ksh b/tests/zfs-tests/tests/functional/xattr/setup.ksh index e623cd79bd55..d9228c426577 100755 --- a/tests/zfs-tests/tests/functional/xattr/setup.ksh +++ b/tests/zfs-tests/tests/functional/xattr/setup.ksh @@ -32,9 +32,7 @@ # if we're running NIS, turn it off until we clean up # (it can cause useradd to take a long time, hitting our TIMEOUT) -if is_linux; then - USED_NIS=false -else +if is_illumos; then USES_NIS=false svcs svc:/network/nis/client:default | grep online > /dev/null if [ $? -eq 0 ] @@ -42,6 +40,8 @@ else svcadm disable -t svc:/network/nis/client:default USES_NIS=true fi +else + USES_NIS=false fi # Make sure we use a brand new user for this