tests: don't use share/unshare exportfs aliases, support FreeBSD NFS

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-06 01:14:12 +01:00 committed by Brian Behlendorf
parent c22c872036
commit 5b0e75caef
6 changed files with 75 additions and 100 deletions

View File

@ -303,8 +303,6 @@ constrain_path() {
ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs"
ln -fs "$STF_PATH/gzip" "$STF_PATH/compress" ln -fs "$STF_PATH/gzip" "$STF_PATH/compress"
ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress" ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/share"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare"
elif [ "$UNAME" = "FreeBSD" ] ; then elif [ "$UNAME" = "FreeBSD" ] ; then
ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh" ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh"
fi fi

View File

@ -82,11 +82,6 @@ tmpfile_reason = 'Kernel O_TMPFILE support required'
# #
statx_reason = 'Kernel statx(2) system call required on Linux' statx_reason = 'Kernel statx(2) system call required on Linux'
#
# Some tests require that the NFS client and server utilities be installed.
#
share_reason = 'NFS client and server utilities required'
# #
# Some tests require that the lsattr utility support the project id feature. # Some tests require that the lsattr utility support the project id feature.
# #
@ -219,9 +214,7 @@ maybe = {
'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'], 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'],
'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason], 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason],
'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason], 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason],
'cli_root/zfs_share/setup': ['SKIP', share_reason],
'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason], 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason],
'cli_root/zfs_unshare/setup': ['SKIP', share_reason],
'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason], 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason],
'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'], 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'],
'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'], 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'],
@ -267,7 +260,6 @@ if sys.platform.startswith('freebsd'):
maybe.update({ maybe.update({
'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason], 'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason],
'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason], 'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason],
'cli_root/zfs_share/zfs_share_011_pos': ['FAIL', known_reason],
'cli_root/zfs_share/zfs_share_concurrent_shares': 'cli_root/zfs_share/zfs_share_concurrent_shares':
['FAIL', known_reason], ['FAIL', known_reason],
'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason], 'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason],

View File

@ -52,11 +52,7 @@ fi
# #
function compare_version_gte function compare_version_gte
{ {
if [[ "$(printf "$1\n$2" | sort -V | tail -n1)" == "$1" ]]; then [ "$(printf "$1\n$2" | sort -V | tail -n1)" = "$1" ]
return 0
else
return 1
fi
} }
# Linux kernel version comparison function # Linux kernel version comparison function
@ -222,15 +218,6 @@ function unmounted
return 1 return 1
} }
# split line on ","
#
# $1 - line to split
function splitline
{
echo $1 | tr ',' ' '
}
function default_setup function default_setup
{ {
default_setup_noexit "$@" default_setup_noexit "$@"
@ -1287,7 +1274,7 @@ function is_shared_freebsd
{ {
typeset fs=$1 typeset fs=$1
pgrep -q mountd && showmount -E | grep -qx $fs pgrep -q mountd && showmount -E | grep -qx "$fs"
} }
function is_shared_illumos function is_shared_illumos
@ -1312,14 +1299,7 @@ function is_shared_illumos
function is_shared_linux function is_shared_linux
{ {
typeset fs=$1 typeset fs=$1
typeset mtpt ! exportfs -s | awk -v fs="${fs//\\/\\\\}" '/^\// && $1 == fs {exit 1}'
for mtpt in `share | awk '{print $1}'` ; do
if [[ $mtpt == $fs ]] ; then
return 0
fi
done
return 1
} }
# #
@ -1337,7 +1317,7 @@ function is_shared
return 1 return 1
else else
mtpt=$(get_prop mountpoint "$fs") mtpt=$(get_prop mountpoint "$fs")
case $mtpt in case "$mtpt" in
none|legacy|-) return 1 none|legacy|-) return 1
;; ;;
*) fs=$mtpt *) fs=$mtpt
@ -1356,13 +1336,11 @@ function is_shared
function is_exported_illumos function is_exported_illumos
{ {
typeset fs=$1 typeset fs=$1
typeset mtpt typeset mtpt _
for mtpt in `awk '{print $1}' /etc/dfs/sharetab` ; do while read -r mtpt _; do
if [[ $mtpt == $fs ]] ; then [ "$mtpt" = "$fs" ] && return
return 0 done < /etc/dfs/sharetab
fi
done
return 1 return 1
} }
@ -1370,13 +1348,11 @@ function is_exported_illumos
function is_exported_freebsd function is_exported_freebsd
{ {
typeset fs=$1 typeset fs=$1
typeset mtpt typeset mtpt _
for mtpt in `awk '{print $1}' /etc/zfs/exports` ; do while read -r mtpt _; do
if [[ $mtpt == $fs ]] ; then [ "$mtpt" = "$fs" ] && return
return 0 done < /etc/zfs/exports
fi
done
return 1 return 1
} }
@ -1384,13 +1360,11 @@ function is_exported_freebsd
function is_exported_linux function is_exported_linux
{ {
typeset fs=$1 typeset fs=$1
typeset mtpt typeset mtpt _
for mtpt in `awk '{print $1}' /etc/exports.d/zfs.exports` ; do while read -r mtpt _; do
if [[ $mtpt == $fs ]] ; then [ "$(printf "$mtpt")" = "$fs" ] && return
return 0 done < /etc/exports.d/zfs.exports
fi
done
return 1 return 1
} }
@ -1435,23 +1409,13 @@ function is_exported
function is_shared_smb function is_shared_smb
{ {
typeset fs=$1 typeset fs=$1
typeset mtpt
if datasetnonexists "$fs" ; then datasetexists "$fs" || return
return 1
else
fs=$(echo $fs | tr / _)
fi
if is_linux; then if is_linux; then
for mtpt in `net usershare list | awk '{print $1}'` ; do net usershare list | grep -xFq "${fs//\//_}"
if [[ $mtpt == $fs ]] ; then
return 0
fi
done
return 1
else else
log_note "Currently unsupported by the test framework" log_note "SMB on $(uname) currently unsupported by the test framework"
return 1 return 1
fi fi
} }
@ -1495,13 +1459,22 @@ function share_nfs #fs
{ {
typeset fs=$1 typeset fs=$1
if ! is_shared $fs; then is_shared "$fs" && return
if is_linux; then
log_must share "*:$fs" case $(uname) in
else Linux)
log_must share -F nfs $fs log_must exportfs "*:$fs"
fi ;;
fi FreeBSD)
typeset mountd
read -r mountd < /var/run/mountd.pid
log_must eval "printf '%s\t\n' \"$fs\" >> /etc/zfs/exports"
log_must kill -s HUP "$mountd"
;;
*)
log_must share -F nfs "$fs"
;;
esac
return 0 return 0
} }
@ -1513,13 +1486,23 @@ function unshare_nfs #fs
{ {
typeset fs=$1 typeset fs=$1
if is_shared $fs; then ! is_shared "$fs" && return
if is_linux; then
log_must unshare -u "*:$fs" case $(uname) in
else Linux)
log_must unshare -F nfs $fs log_must exportfs -u "*:$fs"
fi ;;
fi FreeBSD)
typeset mountd
read -r mountd < /var/run/mountd.pid
awk -v fs="${fs//\\/\\\\}" '$1 != fs' /etc/zfs/exports > /etc/zfs/exports.$$
log_must mv /etc/zfs/exports.$$ /etc/zfs/exports
log_must kill -s HUP "$mountd"
;;
*)
log_must unshare -F nfs $fs
;;
esac
return 0 return 0
} }
@ -1529,13 +1512,17 @@ function unshare_nfs #fs
# #
function showshares_nfs function showshares_nfs
{ {
if is_linux; then case $(uname) in
share -v Linux)
else exportfs -v
;;
FreeBSD)
showmount
;;
*)
share -F nfs share -F nfs
fi ;;
esac
return 0
} }
# #
@ -1554,17 +1541,17 @@ function showshares_smb
function check_nfs function check_nfs
{ {
if is_linux; then case $(uname) in
share -s Linux)
elif is_freebsd; then exportfs -s
;;
FreeBSD)
showmount -e showmount -e
else ;;
*)
log_unsupported "Unknown platform" log_unsupported "Unknown platform"
fi ;;
esac || log_unsupported "The NFS utilities are not installed"
if [[ $? -ne 0 ]]; then
log_unsupported "The NFS utilities are not installed"
fi
} }
# #
@ -1584,12 +1571,12 @@ function setup_nfs_server
# Re-synchronize /var/lib/nfs/etab with /etc/exports and # Re-synchronize /var/lib/nfs/etab with /etc/exports and
# /etc/exports.d./* to provide a clean test environment. # /etc/exports.d./* to provide a clean test environment.
# #
log_must share -r log_must exportfs -r
log_note "NFS server must be started prior to running ZTS." log_note "NFS server must be started prior to running ZTS."
return return
elif is_freebsd; then elif is_freebsd; then
kill -s HUP $(cat /var/run/mountd.pid) log_must kill -s HUP $(</var/run/mountd.pid)
log_note "NFS server must be started prior to running ZTS." log_note "NFS server must be started prior to running ZTS."
return return

View File

@ -125,7 +125,7 @@ while (( i < ${#dataset_pos[*]} )) ; do
set_n_check_prop "noauto" "canmount" "$dataset" set_n_check_prop "noauto" "canmount" "$dataset"
log_must zfs set mountpoint=$tmpmnt $dataset log_must zfs set mountpoint=$tmpmnt $dataset
log_must zfs set sharenfs=on $dataset log_must zfs set sharenfs=on $dataset
if ismounted $dataset; then if ismounted $dataset; then
zfs unmount -a > /dev/null 2>&1 zfs unmount -a > /dev/null 2>&1
log_must mounted $dataset log_must mounted $dataset
log_must zfs unmount $dataset log_must zfs unmount $dataset

View File

@ -179,4 +179,3 @@ while (( i < ${#mntp_fs[*]} )); do
done done
log_pass "'zfs unshare [-a]' succeeds to be aware of legacy share." log_pass "'zfs unshare [-a]' succeeds to be aware of legacy share."

View File

@ -57,8 +57,7 @@ log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
rm -rf $NONZFS_TESTDIR || log_unresolved Could not remove $NONZFS_TESTDIR rm -rf $NONZFS_TESTDIR || log_unresolved Could not remove $NONZFS_TESTDIR
mkdir -p $NONZFS_TESTDIR || log_unresolved Could not create $NONZFS_TESTDIR mkdir -p $NONZFS_TESTDIR || log_unresolved Could not create $NONZFS_TESTDIR
new_fs ${DEV_DSKDIR}/$NONZFS_DISK new_fs ${DEV_DSKDIR}/$NONZFS_DISK ||
(( $? != 0 )) &&
log_untested "Unable to setup a $NEWFS_DEFAULT_FS file system" log_untested "Unable to setup a $NEWFS_DEFAULT_FS file system"
log_must mount ${DEV_DSKDIR}/$NONZFS_DISK $NONZFS_TESTDIR log_must mount ${DEV_DSKDIR}/$NONZFS_DISK $NONZFS_TESTDIR