glusterfs/tests/nfs.rc
Emmanuel Dreyfus 473f115cbf Regression test portability: mount
Address various portability-related problems related to mount
- In order to address the non-portability of NFS mount options,
  use the mount_nfs shell function everywhere, and use it to
  translate options.
- Make sure NFS mounts are unmounted before shutting down the
  daemons in order to avoid deadlock. The change is done in every
  test that did not unmounted NFS mounts at the end of the script,
  and in global cleanup function as well. The force_umount shell
  function from volume.rc was duplicated as umount_nfs in nfs.rc
  so that we do not have to add an include on volume.rc for all
  NFS tests that do not need it.
- The FUSE mount type on NetBSD is puffs|perfuse|fuse.glusterfs
  instead of just fuse.glusterfs, make the regexp configurable
  in include.rc
- Finding wether the mount is RO or RW in mount output needs
  a system-dependent command configurable in include.rc
- mount options in /proc/mounts may be limited to "rw", adjust
  the regexp for this case where there is no comma

And while there change rm into rm -f in tests/basic/mount.t
for removal opearation that should fail, since rm may ask
for confirmation

Change-Id: I1fb708486ec350b2885e2404879561c1020fa8fd
BUG: 1129939
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8494
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
2014-08-20 13:41:08 -07:00

72 lines
1.9 KiB
Bash

#!/bin/bash
# Due to portmap registration NFS takes some time to
# export all volumes. Therefore tests should start only
# after exports are visible by showmount command. This
# routine will check if showmount shows the exports or not
#
function is_nfs_export_available ()
{
local vol=$1
if [ "$vol" == "" ]; then
vol=$V0
fi
exp=$(showmount -e localhost 2> /dev/null | grep $vol | wc -l)
echo "$exp"
}
function mount_nfs ()
{
local e=$1
local m=$2
local opt=$3
if [ ! -z "$opt" ]; then opt=",$opt"; fi
opt="soft,intr,vers=3$opt"
nopt=""
for o in ${opt//,/ }; do
case $OSTYPE in
NetBSD)
test "x${nopt}" = "x" && nopt="tcp,"
case $o in
nolock|noac|actimeo=*|mountproto=udp)
continue
;;
proto=tcp)
o="tcp"
;;
vers=3)
o="nfsv3"
;;
retry=*)
o=${o/retry=/-R}
;;
timeo=*)
o=${o/timeo=/-t}
;;
retrans=*)
o=${o/retrans=/-x}
;;
*)
;;
esac
;;
*)
;;
esac
if [ ! -z "$nopt" ]; then nopt="${nopt},"; fi
nopt="${nopt}$o"
done
mount -t nfs -o $nopt $e $m
}
function umount_nfs {
umount -f $1
if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
}