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:
parent
c22c872036
commit
5b0e75caef
@ -303,8 +303,6 @@ constrain_path() {
|
||||
ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs"
|
||||
ln -fs "$STF_PATH/gzip" "$STF_PATH/compress"
|
||||
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
|
||||
ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh"
|
||||
fi
|
||||
|
@ -82,11 +82,6 @@ tmpfile_reason = 'Kernel O_TMPFILE support required'
|
||||
#
|
||||
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.
|
||||
#
|
||||
@ -219,9 +214,7 @@ maybe = {
|
||||
'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_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_unshare/setup': ['SKIP', share_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_import/zpool_import_missing_003_pos': ['SKIP', '6839'],
|
||||
@ -267,7 +260,6 @@ if sys.platform.startswith('freebsd'):
|
||||
maybe.update({
|
||||
'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_share/zfs_share_011_pos': ['FAIL', known_reason],
|
||||
'cli_root/zfs_share/zfs_share_concurrent_shares':
|
||||
['FAIL', known_reason],
|
||||
'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason],
|
||||
|
@ -52,11 +52,7 @@ fi
|
||||
#
|
||||
function compare_version_gte
|
||||
{
|
||||
if [[ "$(printf "$1\n$2" | sort -V | tail -n1)" == "$1" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
[ "$(printf "$1\n$2" | sort -V | tail -n1)" = "$1" ]
|
||||
}
|
||||
|
||||
# Linux kernel version comparison function
|
||||
@ -222,15 +218,6 @@ function unmounted
|
||||
return 1
|
||||
}
|
||||
|
||||
# split line on ","
|
||||
#
|
||||
# $1 - line to split
|
||||
|
||||
function splitline
|
||||
{
|
||||
echo $1 | tr ',' ' '
|
||||
}
|
||||
|
||||
function default_setup
|
||||
{
|
||||
default_setup_noexit "$@"
|
||||
@ -1287,7 +1274,7 @@ function is_shared_freebsd
|
||||
{
|
||||
typeset fs=$1
|
||||
|
||||
pgrep -q mountd && showmount -E | grep -qx $fs
|
||||
pgrep -q mountd && showmount -E | grep -qx "$fs"
|
||||
}
|
||||
|
||||
function is_shared_illumos
|
||||
@ -1312,14 +1299,7 @@ function is_shared_illumos
|
||||
function is_shared_linux
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
|
||||
for mtpt in `share | awk '{print $1}'` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
! exportfs -s | awk -v fs="${fs//\\/\\\\}" '/^\// && $1 == fs {exit 1}'
|
||||
}
|
||||
|
||||
#
|
||||
@ -1337,7 +1317,7 @@ function is_shared
|
||||
return 1
|
||||
else
|
||||
mtpt=$(get_prop mountpoint "$fs")
|
||||
case $mtpt in
|
||||
case "$mtpt" in
|
||||
none|legacy|-) return 1
|
||||
;;
|
||||
*) fs=$mtpt
|
||||
@ -1356,13 +1336,11 @@ function is_shared
|
||||
function is_exported_illumos
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
typeset mtpt _
|
||||
|
||||
for mtpt in `awk '{print $1}' /etc/dfs/sharetab` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
while read -r mtpt _; do
|
||||
[ "$mtpt" = "$fs" ] && return
|
||||
done < /etc/dfs/sharetab
|
||||
|
||||
return 1
|
||||
}
|
||||
@ -1370,13 +1348,11 @@ function is_exported_illumos
|
||||
function is_exported_freebsd
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
typeset mtpt _
|
||||
|
||||
for mtpt in `awk '{print $1}' /etc/zfs/exports` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
while read -r mtpt _; do
|
||||
[ "$mtpt" = "$fs" ] && return
|
||||
done < /etc/zfs/exports
|
||||
|
||||
return 1
|
||||
}
|
||||
@ -1384,13 +1360,11 @@ function is_exported_freebsd
|
||||
function is_exported_linux
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
typeset mtpt _
|
||||
|
||||
for mtpt in `awk '{print $1}' /etc/exports.d/zfs.exports` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
while read -r mtpt _; do
|
||||
[ "$(printf "$mtpt")" = "$fs" ] && return
|
||||
done < /etc/exports.d/zfs.exports
|
||||
|
||||
return 1
|
||||
}
|
||||
@ -1435,23 +1409,13 @@ function is_exported
|
||||
function is_shared_smb
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
|
||||
if datasetnonexists "$fs" ; then
|
||||
return 1
|
||||
else
|
||||
fs=$(echo $fs | tr / _)
|
||||
fi
|
||||
datasetexists "$fs" || return
|
||||
|
||||
if is_linux; then
|
||||
for mtpt in `net usershare list | awk '{print $1}'` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
net usershare list | grep -xFq "${fs//\//_}"
|
||||
else
|
||||
log_note "Currently unsupported by the test framework"
|
||||
log_note "SMB on $(uname) currently unsupported by the test framework"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@ -1495,13 +1459,22 @@ function share_nfs #fs
|
||||
{
|
||||
typeset fs=$1
|
||||
|
||||
if ! is_shared $fs; then
|
||||
if is_linux; then
|
||||
log_must share "*:$fs"
|
||||
else
|
||||
log_must share -F nfs $fs
|
||||
fi
|
||||
fi
|
||||
is_shared "$fs" && return
|
||||
|
||||
case $(uname) in
|
||||
Linux)
|
||||
log_must exportfs "*:$fs"
|
||||
;;
|
||||
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
|
||||
}
|
||||
@ -1513,13 +1486,23 @@ function unshare_nfs #fs
|
||||
{
|
||||
typeset fs=$1
|
||||
|
||||
if is_shared $fs; then
|
||||
if is_linux; then
|
||||
log_must unshare -u "*:$fs"
|
||||
else
|
||||
log_must unshare -F nfs $fs
|
||||
fi
|
||||
fi
|
||||
! is_shared "$fs" && return
|
||||
|
||||
case $(uname) in
|
||||
Linux)
|
||||
log_must exportfs -u "*:$fs"
|
||||
;;
|
||||
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
|
||||
}
|
||||
@ -1529,13 +1512,17 @@ function unshare_nfs #fs
|
||||
#
|
||||
function showshares_nfs
|
||||
{
|
||||
if is_linux; then
|
||||
share -v
|
||||
else
|
||||
case $(uname) in
|
||||
Linux)
|
||||
exportfs -v
|
||||
;;
|
||||
FreeBSD)
|
||||
showmount
|
||||
;;
|
||||
*)
|
||||
share -F nfs
|
||||
fi
|
||||
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
@ -1554,17 +1541,17 @@ function showshares_smb
|
||||
|
||||
function check_nfs
|
||||
{
|
||||
if is_linux; then
|
||||
share -s
|
||||
elif is_freebsd; then
|
||||
case $(uname) in
|
||||
Linux)
|
||||
exportfs -s
|
||||
;;
|
||||
FreeBSD)
|
||||
showmount -e
|
||||
else
|
||||
;;
|
||||
*)
|
||||
log_unsupported "Unknown platform"
|
||||
fi
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
log_unsupported "The NFS utilities are not installed"
|
||||
fi
|
||||
;;
|
||||
esac || log_unsupported "The NFS utilities are not installed"
|
||||
}
|
||||
|
||||
#
|
||||
@ -1584,12 +1571,12 @@ function setup_nfs_server
|
||||
# Re-synchronize /var/lib/nfs/etab with /etc/exports and
|
||||
# /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."
|
||||
return
|
||||
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."
|
||||
return
|
||||
|
@ -125,7 +125,7 @@ while (( i < ${#dataset_pos[*]} )) ; do
|
||||
set_n_check_prop "noauto" "canmount" "$dataset"
|
||||
log_must zfs set mountpoint=$tmpmnt $dataset
|
||||
log_must zfs set sharenfs=on $dataset
|
||||
if ismounted $dataset; then
|
||||
if ismounted $dataset; then
|
||||
zfs unmount -a > /dev/null 2>&1
|
||||
log_must mounted $dataset
|
||||
log_must zfs unmount $dataset
|
||||
|
@ -179,4 +179,3 @@ while (( i < ${#mntp_fs[*]} )); do
|
||||
done
|
||||
|
||||
log_pass "'zfs unshare [-a]' succeeds to be aware of legacy share."
|
||||
|
||||
|
@ -57,8 +57,7 @@ log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
|
||||
rm -rf $NONZFS_TESTDIR || log_unresolved Could not remove $NONZFS_TESTDIR
|
||||
mkdir -p $NONZFS_TESTDIR || log_unresolved Could not create $NONZFS_TESTDIR
|
||||
|
||||
new_fs ${DEV_DSKDIR}/$NONZFS_DISK
|
||||
(( $? != 0 )) &&
|
||||
new_fs ${DEV_DSKDIR}/$NONZFS_DISK ||
|
||||
log_untested "Unable to setup a $NEWFS_DEFAULT_FS file system"
|
||||
|
||||
log_must mount ${DEV_DSKDIR}/$NONZFS_DISK $NONZFS_TESTDIR
|
||||
|
Loading…
Reference in New Issue
Block a user