nfs-utils/SOURCES/nfs-utils-2.3.3-gating-tests.patch

3814 lines
158 KiB
Diff
Raw Normal View History

2019-08-02 15:31:48 +00:00
From 26dfa0f7846f14aa86048d504913d3a3be7196d0 Mon Sep 17 00:00:00 2001
From: Bruno Goncalves <bgoncalv@redhat.com>
Date: Jan 17 2019 10:02:50 +0000
Subject: [PATCH 1/6] Add CI tests
Related: rhbz#1653927
---
diff --git a/tests/export-mount-local/PURPOSE b/tests/export-mount-local/PURPOSE
new file mode 100644
index 0000000..556df42
--- /dev/null
+++ b/tests/export-mount-local/PURPOSE
@@ -0,0 +1 @@
+# nothing
diff --git a/tests/export-mount-local/_env b/tests/export-mount-local/_env
new file mode 100644
index 0000000..90b8e90
--- /dev/null
+++ b/tests/export-mount-local/_env
@@ -0,0 +1,7 @@
+export TOPLEVEL_NAMESPACE=nfs-utils
+export PKG_NAMESPACE=nfs-utils
+export RELATIVE_PATH=export-mount-local
+export PACKAGE=nfs-utils
+export PACKAGE_NAME=nfs-utils
+export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
+export TEST=/nfs-utils/export-mount-local
diff --git a/tests/export-mount-local/runtest.sh b/tests/export-mount-local/runtest.sh
new file mode 100755
index 0000000..e72e0f4
--- /dev/null
+++ b/tests/export-mount-local/runtest.sh
@@ -0,0 +1,304 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: test for: export-mount
+# Author: Jianhong Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2014 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+#===============================================================================
+
+#signal trap
+trap "cleanup" SIGINT SIGTERM SIGHUP SIGQUIT
+cleanup() {
+ rlFileRestore
+ rm -rf $expdir $nfsmp
+}
+
+#global var define
+BZ=exp-mount-local
+expdir=/exportDir-$BZ
+nfsmp=/mnt/nfsmp-$BZ
+subexpdir=/exportDir-$BZ/sub
+tmpnfsmp=/tmp/nfsmp-$BZ
+
+host="$HOSTNAME"
+# in case "localhost.localdomain"
+echo "$host" | grep -q "localhost" && host="localhost"
+
+rlJournalStart
+ rlPhaseStartSetup do-Setup-
+ # Load beakerlib you needed
+ rlImport kernel/base
+ read ipv4 _nil <<<$(getDefaultIp)
+ read ipv6s _nil <<<$(getDefaultIp 6 global)
+ ipv6="[$ipv6s]"
+ envinfo
+ rlFileBackup /etc/exports /etc/sysconfig/nfs /etc/nfs.conf /etc/hosts
+ if [ "$host" = "localhost" ]; then
+ run "echo '$ipv4 $host' >> /etc/hosts"
+ if [ -n "$ipv6s" ]; then
+ run "echo '$ipv6s $host' >> /etc/hosts"
+ fi
+ run "cat /etc/hosts" -
+ fi
+ run 'rm -rf $expdir $nfsmp && mkdir -p $expdir $nfsmp'
+ run 'rm -rf $subexpdir $tmpnfsmp && mkdir -p $subexpdir $tmpnfsmp'
+ run 'echo "/tmp *(ro,sync)" >/etc/exports'
+ run 'service_nfs restart'
+ #avoid issues restarting the server too quickly
+ sleep 10
+ run 'ls_nfsvers'
+ rlPhaseEnd
+
+for V in $(ls_nfsvers); do
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv4
+ run "exportfs -au && exportfs -iv $ipv4:$expdir -o ro,sync,no_root_squash"
+ run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+ if [ -n "$ipv6s" ]; then
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv6-x
+ run 'mount -o vers=$V $ipv6:$expdir $nfsmp' 1-255
+ [ $? = 0 ] && run "umount $nfsmp"
+ rlPhaseEnd
+ fi
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-host
+ run 'mount -o vers=$V $host:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+
+ if [ -n "$ipv6s" ]; then
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv6
+ run "exportfs -au && exportfs -iv $ipv6:$expdir -o ro,sync,no_root_squash"
+ run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv4-x
+ run 'mount -o vers=$V $ipv4:$expdir $nfsmp' 1-255
+ [ $? = 0 ] && run "umount $nfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-host
+ if [ -n "$(dig -t aaaa $HOSTNAME +short)" ]; then
+ run 'mount -o vers=$V $host:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ fi
+ rlPhaseEnd
+ fi
+
+ rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-host
+ run "exportfs -au && exportfs -iv $host:$expdir -o ro,sync,no_root_squash"
+ run 'mount -o vers=$V $host:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv4
+ run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+ if [ -n "$ipv6s" ]; then
+ rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv6
+ if [ -n "$(dig -t aaaa $HOSTNAME +short)" ]; then
+ run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
+ run 'umount $nfsmp'
+ fi
+ rlPhaseEnd
+ fi
+
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv4
+ run 'echo "$expdir *(ro,sync,no_root_squash)" >/etc/exports'
+ run 'echo "$subexpdir $ipv4(ro,sync,no_root_squash)" >>/etc/exports'
+ run 'service_nfs restart'
+ #avoid issues restarting the server too quickly
+ sleep 10
+ run 'showmount -e' -
+ run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
+ run 'mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+ if [ -n "$ipv6s" ]; then
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv6-x
+ run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
+ run 'mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp' 1-255 "should not mount sub-directory with different ip"
+ [ $? = 0 ] && run "umount $tmpnfsmp"
+ run "umount $nfsmp"
+ rlPhaseEnd
+ fi
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-host
+ run 'mount -o vers=$V $host:$expdir $nfsmp'
+ run 'mount -o vers=$V $host:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+
+ if [ -n "$ipv6s" ]; then
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv4-x
+ run 'echo "$expdir *(ro,sync,no_root_squash)" >/etc/exports'
+ run 'echo "$subexpdir $ipv6s(ro,sync,no_root_squash)" >>/etc/exports'
+ run 'service_nfs restart'
+ #avoid issues restarting the server too quickly
+ sleep 10
+ run 'showmount -e' -
+ run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
+ run 'mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp' 1-255 "should not mount sub-directory with different ip"
+ [ $? = 0 ] && run "umount $tmpnfsmp"
+ run "umount $nfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv6
+ run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
+ run 'mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-host
+ run 'mount -o vers=$V $host:$expdir $nfsmp'
+ run 'mount -o vers=$V $host:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+ fi
+
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv4
+ run 'echo "$expdir *(ro,sync,no_root_squash)" >/etc/exports'
+ run 'echo "$subexpdir $host(ro,sync,no_root_squash)" >>/etc/exports'
+ run 'service_nfs restart'
+ #avoid issues restarting the server too quickly
+ sleep 10
+ run 'showmount -e' -
+ run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
+ run 'mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+ if [ -n "$ipv6s" ]; then
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv6
+ run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
+ run 'mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+ fi
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-host
+ run 'mount -o vers=$V $host:$expdir $nfsmp'
+ run 'mount -o vers=$V $host:$subexpdir $tmpnfsmp'
+ run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-nfsV$V-default-option-overridden-by-client-specific-option
+ run "echo '$expdir -ro,sync *(rw,no_root_squash)' >/etc/exports"
+ run "service_nfs restart"
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "exports option should be overridden by client specific."
+ run "rm -rf $nfsmp/test*"
+ run "umount $nfsmp"
+ run "echo '$expdir -ro,sec=sys,sync *(rw,no_root_squash)' >/etc/exports" 0 "sec=sys may cause it to be failed."
+ run "exportfs -rv"
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "exports option should be overridden by client specific."
+ run "rm -rf $nfsmp/test*"
+ run "umount $nfsmp"
+ rlPhaseEnd
+done
+
+ rlPhaseStartTest do-Test-exports-options-twice
+ run 'echo "/ *(sync,hide,no_wdelay)" > /etc/exports'
+ run "service_nfs restart"
+ #avoid issues restarting the server too quickly
+ sleep 10
+
+ # Count all options from list printed by exportfs -s(rhel-7) or exportfs -v(rhel-6)
+ allOptions=$( (exportfs -s 2>/dev/null || exportfs -v) | sed 's/^.*(//;s/)$//;s/,/\n/g' | wc -l)
+ # Count unique options from list printed by exportfs -s(rhel-7) or exportfs -v(rhel-6)
+ uniqOptions=$( (exportfs -s 2>/dev/null || exportfs -v) | sed 's/^.*(//;s/)$//;s/,/\n/g' | sort | uniq | wc -l)
+
+ log "{Info} exportfs -s(rhel-7) or exportfs -v(rhel-6) will print option list for each export path"
+ log "{Info} All options printed by exportfs -s(rhel-7) or exportfs -v(rhel-6) (sorted):"
+ run "(exportfs -s 2>/dev/null || exportfs -v) | sed 's/^.*(//;s/)$//;s/,/\n/g' | sort"
+ log "{Info} For exported path '/', there are $allOptions options printed in all options list and $uniqOptions of them are unique"
+ run 'test $uniqOptions -eq $allOptions' 0 "Should not output any options twice, quantity of all options should be equal to quantity of unique options"
+ for opt in sync hide no_wdelay; do
+ run "(exportfs -s 2>/dev/null || exportfs -v) | grep -q $opt" 0 "Option list should contain option $opt specified in /etc/exports"
+ done
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-server-side-using-bind-mount
+ run "dd if=/dev/zero of=workspace.image bs=3M count=500"
+ run "mkfs -t ext3 -F workspace.image"
+ run "mkdir -p /workspace"
+ run "mount -o loop workspace.image /workspace"
+ run "mkdir -p /workspace/vmcore /srv/nfs/vmcore"
+ run "touch /workspace/work_dir /workspace/vmcore/vmcore_dir"
+ run "mount --bind /workspace/vmcore /srv/nfs/vmcore"
+ run "echo '/srv/nfs/vmcore *(rw,no_root_squash)' > /etc/exports"
+ run "echo '/workspace *(rw,no_root_squash)' >> /etc/exports"
+ run "service_nfs restart"
+ #avoid issues restarting the server too quickly
+ sleep 10
+ run "mount $host:/workspace $nfsmp"
+ run "ls $nfsmp/work_dir"
+ run "umount $nfsmp"
+ run "exportfs -au" && run "service_nfs stop"
+ run "umount /srv/nfs/vmcore"
+ run "umount /workspace"
+ run "rm -rf /workspace /srv/nfs/vmcore"
+ run "rm workspace.image"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-mount-nfsv4-show-wrong-port
+ run "echo '$expdir *(rw,no_root_squash)' >>/etc/exports"
+ run "service_nfs restart"
+ #avoid issues restarting the server too quickly
+ sleep 10
+ run "exportfs -v"
+ run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp"
+ run "mount -t nfs4 | grep $nfsmp" -
+ run "mount -t nfs4 | grep $nfsmp | grep -q port=2049" 0 "Should show port=2049"
+ run "umount $nfsmp"
+ run "echo '[nfsd]' > /etc/nfs.conf"
+ run "echo 'port=20050' >> /etc/nfs.conf"
+ run "service_nfs restart"
+ run "sleep 10"
+ run "rpcinfo -p | grep -w nfs | grep 20050"
+ run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp" -
+ if [ $? -eq 0 ]; then
+ run "mount -t nfs4" -
+ run "mount -t nfs4 | grep -q port=20050" 0 "Should show port=20050"
+ run "umount $nfsmp"
+ fi
+ run "mount -t nfs -o vers=4,port=0 localhost:$expdir $nfsmp" -
+ if [ $? -eq 0 ]; then
+ run "mount -t nfs4" -
+ run "mount -t nfs4 | grep -q port=20050" 0 "Should show port=20050"
+ run "umount $nfsmp"
+ fi
+ run "mount -t nfs -o vers=4,port=20050 localhost:$expdir $nfsmp"
+ run "mount -t nfs4 | grep $nfsmp" -
+ run "mount -t nfs4 | grep $nfsmp | grep -q port=20050" 0 "Should show port=20050"
+ run "umount $nfsmp"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup do-Cleanup-
+ run 'rm -rf $expdir $nfsmp $subexpdir $tmpnfsmp'
+ rlFileRestore
+ run "service_nfs restart"
+ #avoid issues restarting the server too quickly
+ sleep 10
+ rlPhaseEnd
+rlJournalEnd
+#rlJournalPrintText
+#enable_avc_check
diff --git a/tests/export-mount-local/subtest.yml b/tests/export-mount-local/subtest.yml
new file mode 100644
index 0000000..1a77920
--- /dev/null
+++ b/tests/export-mount-local/subtest.yml
@@ -0,0 +1 @@
+attr: {ssched: yes}
diff --git a/tests/exportfs/PURPOSE b/tests/exportfs/PURPOSE
new file mode 100644
index 0000000..3299ed8
--- /dev/null
+++ b/tests/exportfs/PURPOSE
@@ -0,0 +1,2 @@
+Description: test for command exportfs
+Author: Stevens Yin <jiyin@redhat.com>
diff --git a/tests/exportfs/_env b/tests/exportfs/_env
new file mode 100644
index 0000000..b57092a
--- /dev/null
+++ b/tests/exportfs/_env
@@ -0,0 +1,7 @@
+export TOPLEVEL_NAMESPACE=nfs-utils
+export PKG_NAMESPACE=nfs-utils
+export RELATIVE_PATH=exportfs
+export PACKAGE=nfs-utils
+export PACKAGE_NAME=nfs-utils
+export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
+export TEST=/nfs-utils/exportfs
diff --git a/tests/exportfs/runtest.sh b/tests/exportfs/runtest.sh
new file mode 100755
index 0000000..8e34a8c
--- /dev/null
+++ b/tests/exportfs/runtest.sh
@@ -0,0 +1,313 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: test for command exportfs
+# Author: Stevens Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+#===============================================================================
+
+#setting locale as test check infomration on man pages
+export LC_ALL=en_US.utf8
+
+BZ=exportfs
+nfsmp=/mnt/nfsmp-$BZ
+expdir=/expdir-$BZ
+prog=exportfs
+
+rlJournalStart
+ rlPhaseStartSetup do-Setup
+ # Load beakerlib you needed
+ rlImport kernel/base
+ envinfo
+ read IP4 _nil <<<$(getDefaultIp)
+ read IP6 _nil <<<$(getDefaultIp 6)
+ if echo "$HOSTNAME" | grep -q "localhost"; then
+ hostnamectl set-hostname exportfs.test
+ fi
+ #clean nfs garbage, avoid affect from pre case
+ { exportfs -ua; service nfs stop &>/dev/null; }
+ rlFileBackup /etc/sysconfig/nfs /etc/exports
+ rlFileBackup --clean /etc/exports.d/
+ run 'rm -f /etc/exports.d/*'
+ run 'mkdir -p $nfsmp $expdir'
+ run 'echo "$expdir *(rw,no_root_squash,fsid=0)" > /etc/exports'
+ service_nfs start
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test"-$prog-with-wrong-option"
+ run 'exportfs -xxxx 2>&1' 1-255 "should exit with an error code"
+ run 'exportfs -xxxx 2>&1 | egrep -i "(usage:|try.*for more info)"' 0 "should output usage to user"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test"-$prog-IpV6"
+ run 'echo "[$IP6]:$expdir"' -
+ run 'exportfs -vi "[$IP6]:$expdir"'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-exportfs-a-and-o-check
+ run 'cp /etc/exports /etc/exports.bak'
+ run 'mkdir ${expdir}2'
+ run 'echo "${expdir}2 *(ro)" >>/etc/exports'
+ run 'exportfs -a' 0 "exportfs -a to export all directories"
+ run 'showmount -e'
+ run 'test $(showmount -e | grep $expdir | wc -l) = 2' 0 "there should be two expdir entries"
+ run 'exportfs -v'
+ run 'exportfs -v | sed -n -e "/\t/! {N; s/[\n\t]/ /g;p}" -e "/\t/p" |
+ grep "${expdir}2" | grep ro | grep -w root_squash' 0 "check the the export options"
+
+ run 'exportfs -i -o rw,no_root_squash *:${expdir}2' 0 "exportfs -i -o override default export options"
+ run 'exportfs -v'
+ run 'exportfs -v | sed -n -e "/\t/! {N; s/[\n\t]/ /g;p}" -e "/\t/p" |
+ grep "${expdir}2" | grep rw | grep -w no_root_squash' 0 "check if the options be override"
+ run 'mv /etc/exports.bak /etc/exports' 0 "Restore /etc/exports"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-reexport-check
+ run 'exportfs -rv' 0 "exportfs -rv to reexport all directories"
+ run 'exportfs -v | grep "${expdir}2"' 1 "${expdir}2 removed from /etc/exports so no entry about it exported"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-exportfs-u-check
+ run 'exportfs -u' 0 "exportfs -u unexport one or more directories"
+ run 'showmount -e | grep "$expdir"' 0 "$expdir unexport"
+ run 'exportfs *:${expdir}2'
+ run 'exportfs' -
+ run "exportfs -v -u *:$expdir" 0 "unexport one directory only"
+ run 'exportfs' -
+ run "exportfs | grep '${expdir}2'" 0 "${expdir}2 should not be unexported"
+ run 'exportfs -ua'
+ run 'exportfs -f' 0 "exportfs -f flush everything out of the kernel?s export table"
+ run 'rm -rf ${expdir}2'
+ rlPhaseEnd
+
+ # test NFS_MAXPATHLEN(1024) boundary value test
+ dname=$(echo {1..88}|sed 's/ /_/g') #dname with 254 chars
+ fpath=/$dname/$dname/$dname/$dname #fpath with 1020 chars
+ fpath2=/$dname/$dname/$dname/$dname/abc #fpath with 1024 chars
+ fpath3=/$dname/$dname/$dname/$dname/abckkkk #fpath with 1028 chars
+ rlPhaseStartTest do-Test-exportfs-pathlenth-${#fpath}-${#fpath2}-${#fpath3}
+ run "mkdir -p $fpath" 0 "create a long export path(${#fpath})"
+ run "mkdir -p $fpath2" 0 "create a long export path(${#fpath2})"
+ run "mkdir -p $fpath3" 0 "create a long export path(${#fpath3})"
+ run "exportfs -vi $IP4:$fpath &>std.log" 0 "exportfs long path(${#fpath}) should success"
+ run 'cat std.log' -
+ run 'grep "does not support NFS export" std.log' 1
+
+ run "exportfs -vi $IP4:$fpath2 &>std2.log" 0 "exportfs long path(${#fpath2}) should success"
+ run 'cat std2.log' -
+ run 'grep "does not support NFS export" std2.log' 1
+
+ run "exportfs -vi $IP4:$fpath3 &>std3.log" 1 "exportfs long path(${#fpath3}) should fail"
+ run 'cat std3.log' -
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-exportfs-dir-with-white-space
+ run 'mkdir -p "/dir with white spaces"'
+ run 'exportfs -vi $IP4:"/dir with white spaces"'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-exportfs-dir-invalid-arg-not-exist
+ run 'exportfs -ua; exportfs -i *:/not.exist &> stdout.log' 1-255
+ run 'cat stdout.log' -
+ run 'test -n stdout.log' 0 "Path not exist, should output error info to user."
+ run 'cat stdout.log | grep -i usage' 0,1 "should output the usage for invalid argument"
+ run 'exportfs' -
+ run 'test -z "$(exportfs)"' 0,1 "should not exported the invalid path"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-exportfs-dir-without-uuid-and-fsid
+ run 'exportfs -ua; exportfs -i *:/dev/shm &> stdout.log' 1-255
+ run 'cat stdout.log' -
+ run 'test -n stdout.log' 0 "Path no uuid and fsid, should output error info to user"
+ run 'exportfs' -
+ run 'test -z "$(exportfs)"' 0,1 "should not exported the invalid path"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-exportfs-when-/proc/fs/nfsd-not-mount
+ run 'mkdir -p ${expdir}_tmp'
+ run 'service nfs start'
+ run 'pkill rpc.mountd && umount /proc/fs/nfsd'
+ run 'exportfs -iv *:${expdir}_tmp'
+ run 'mount -t nfsd nfsd /proc/fs/nfsd' 0-255 "restore env: mount nfsd"
+ run 'rm -rf ${expdir}_tmp'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-option-nordirplus
+ #nfsv3 export option nordirplus support test
+ run 'service nfs start'
+ run 'exportfs -i -o nordirplus "*:$expdir"'
+ run 'mount -o vers=3 localhost:$expdir $nfsmp'
+ run 'grep $nfsmp /proc/mounts'
+ run 'grep nfs /proc/mounts | grep nordirplus' -
+ run 'man 5 exports | col -b | grep nordirplus'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-extra-export.d-files-base
+ # test files under /etc/exports.d
+ run 'rm -rf /etc/exports.d'
+ run 'exportfs -r 2>&1 | grep "No such file or directory"' 1 "should not output garbage log"
+ run 'mkdir -p /etc/exports.d'
+ run 'echo "$expdir *(rw,no_root_squash)" > /etc/exports.d/test.exports'
+ run 'cp /etc/exports /etc/exports.bak'
+ run 'echo "" > /etc/exports'
+ run 'cat /etc/exports.d/test.exports' -
+ run 'exportfs -ua; exportfs -a' 0 "export all directories"
+ run 'showmount -e | grep $expdir'
+ run 'mount localhost:$expdir $nfsmp'
+ run 'grep $nfsmp /proc/mounts'
+ run 'umount $nfsmp'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-extra-export.d-files-max-filelen
+ name_max=$(getconf NAME_MAX $expdir)
+ min_export_sz=$(expr length ".exports")
+ max_export_len=$(($name_max-$min_export_sz))
+ run 'mkdir ${expdir}.max_length'
+ run 'echo "${expdir}.max_length *(ro)" > /etc/exports.d/$(printf "%0${max_export_len}d").exports'
+ run 'ls -la /etc/exports.d/' -
+ run 'exportfs -rv' 0 "exportfs -rv to reexport all directories"
+ run 'showmount -e | grep "max_length"'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-extra-export.d-files-filename-format
+ run 'mkdir ${expdir}.should_ignored'
+ run 'echo "${expdir}.should_ignored *(rw)" > /etc/exports.d/.ignored.exports'
+ run 'echo "${expdir}.should_ignored *(rw)" > /etc/exports.d/ignored.export'
+ run 'echo "${expdir}.should_ignored *(rw)" > /etc/exports.d/exports'
+ run 'ls -la /etc/exports.d/' -
+ run 'exportfs -rv' 0 "exportfs -rv to reexport all directories"
+ run 'showmount -e | grep "should_ignored"' 1
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-extra-export.d-files-filetype-link
+ run 'ln -s /etc/exports.d/ignored.export /etc/exports.d/linked.exports'
+ run 'ls -la /etc/exports.d/' -
+ run 'exportfs -rv' 0 "exportfs -rv to reexport all directories"
+ run 'showmount -e | grep "should_ignored"' 0 "should consider the link file"
+ run 'test $(showmount -e | grep $expdir | wc -l) = 3' 0 "there should be two expdir entries"
+ run 'rm -rf ${expdir}.*'
+ run 'rm -rf /etc/exports.d'
+ run 'mv /etc/exports.bak /etc/exports' 0 "Restore /etc/exports"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-option-mountpoint
+ run "service_nfs start"
+ run "exportfs -ua"
+ run "mkdir -p ${expdir}_share"
+ run "exportfs -i *:${expdir}_share -o mp"
+ run "exportfs -v" -
+ run "mountpoint ${expdir}_share" 1-255 "It is not mounted yet"
+ # The mount point will still show... but when trying to
+ # mount the directory the client mount should be failed
+ run "showmount -e | grep share" -
+ run "timeout 60 mount localhost:${expdir}_share $nfsmp" 1-123,125-255 "Should be failed without hang"
+ [ $? -eq 0 ] && run "umount $nfsmp"
+ log "{Info} Creating a small fs on loopback device and mount it."
+ run "dd if=/dev/zero of=fs_tmp.img bs=1M count=100" -
+ run "losetup /dev/loop0 fs_tmp.img" -
+ run "mkfs /dev/loop0" -
+ run "mount /dev/loop0 ${expdir}_share"
+ run "mountpoint ${expdir}_share" 0 "It should be mounted now"
+ run "showmount -e | grep share" 0 "Should be listed in output of showmount -e now"
+ run "mount localhost:${expdir}_share $nfsmp" 0 "Should success now"
+ [ $? -eq 0 ] && run "umount $nfsmp"
+ log "{Info} Recovering it."
+ run "service_nfs stop"
+ run "umount ${expdir}_share"
+ run "losetup -d /dev/loop0" -
+ run "rm -f fs_tmp.img" -
+ run "rm -rf ${expdir}_share"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"exportfs -u incorrectly exits with a 1 whenever the exportlist has multiple FQDN exports"
+ run "exportfs -ua"
+ run "exportfs -v" -
+ run "exportfs -o rw,sync localhost:$expdir"
+ run "exportfs -o rw,sync $IP4:$expdir"
+ run "exportfs -v" -
+ run 'test $(exportfs -v | grep $expdir | wc -l) = 2'
+ run "exportfs -u $IP4:$expdir" 0 "should not exit with 1 when the exportlist has multiple FQDN exports"
+ run "exportfs -v" -
+ run 'test $(exportfs -v | grep $expdir | wc -l) = 1'
+ run "exportfs -u localhost:$expdir"
+ run "exportfs -v" -
+ run 'test $(exportfs -v | grep $expdir | wc -l) = 0'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"exportfs -u cannot unexport when the specified path involves a trailing /"
+ run "exportfs -ua"
+ run "exportfs -o rw,sync localhost:$expdir"
+ run "exportfs -u not.exist:$expdir" 1-255 "should be failed and return error code"
+ run "exportfs -v" -
+ run "test $(exportfs | wc -l) -ne 0" 0 "Should not be cleared as previous cmd failed"
+ run "exportfs -u localhost:$expdir/" 0 "Should unexport even if path involves trailing /"
+ run "exportfs -v" -
+ run "test $(exportfs | wc -l) -eq 0" 0 "Should have nothing to export"
+ run "exportfs -ua"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"exportfs -u can exit with status 1 if there are multiple ip exports that cannot be resolved to hostnames"
+ # Should test with un-used ip address
+ run "ping -c 1 192.168.1.100 >/dev/null || ping -c 1 192.168.1.101 >/dev/null" 1
+ [ "$?" = "0" ] && {
+ log "{WARN} Should test with un-used ip address, skip the test."
+ report_result $TEST FAIL
+ exit 0
+ }
+ run "exportfs -ua && exportfs -v" -
+ log "{INFO} Test with ip that cannot be resolved to a hostname."
+ run "exportfs -o rw,sync 192.168.1.100:$expdir"
+ run "exportfs -o rw,sync 192.168.1.101:$expdir"
+ run "exportfs -v" -
+ run 'test $(exportfs -v | grep $expdir | wc -l) = 2'
+ run "exportfs -u 192.168.1.101:$expdir" 0 "Should not exit with 1 if unexports successfully."
+ run "exportfs -v" -
+ run 'test $(exportfs -v | grep $expdir | wc -l) = 1'
+ run "exportfs -u 192.168.1.100:$expdir" 0 "Should not exit with 1 if unexports successfully."
+ run "exportfs -v" -
+ run 'test $(exportfs -v | grep $expdir | wc -l) = 0'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-'exportfs: support "security_label" export option'
+ run "exportfs -ua && exportfs -v" -
+ run "exportfs -o security_label localhost:$expdir"
+ run "exportfs -v" -
+ run "exportfs -v | grep -q security_label"
+ run "exportfs -ua"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup do-Cleanup
+ rlFileRestore
+ if echo "$HOSTNAME" | grep -q "localhost"; then
+ hostnamectl set-hostname $HOSTNAME
+ fi
+ rm -rf $nfsmp $expdir
+ run "service_nfs restart"
+ rlPhaseEnd
+rlJournalEnd
+#rlJournalPrintText
+
diff --git a/tests/mount/PURPOSE b/tests/mount/PURPOSE
new file mode 100644
index 0000000..3c215eb
--- /dev/null
+++ b/tests/mount/PURPOSE
@@ -0,0 +1,2 @@
+Description: Test for command mount.nfs{,4}
+Author: Stevens Yin <jiyin@redhat.com>
diff --git a/tests/mount/_env b/tests/mount/_env
new file mode 100644
index 0000000..d016f7c
--- /dev/null
+++ b/tests/mount/_env
@@ -0,0 +1,7 @@
+export TOPLEVEL_NAMESPACE=nfs-utils
+export PKG_NAMESPACE=nfs-utils
+export RELATIVE_PATH=mount
+export PACKAGE=nfs-utils
+export PACKAGE_NAME=nfs-utils
+export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
+export TEST=/nfs-utils//mount
diff --git a/tests/mount/runtest.sh b/tests/mount/runtest.sh
new file mode 100755
index 0000000..fb2f585
--- /dev/null
+++ b/tests/mount/runtest.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: Test for command mount.nfs{,4}
+# Author: Stevens Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+#===============================================================================
+
+mnt=/nfs-mount
+expdir=/expdir
+expdir_with_more_slash=$expdir///expdir-mount
+prog=mount.nfs
+
+rlJournalStart
+ rlPhaseStartSetup do-Setup
+ # Load beakerlib you needed
+ rlImport kernel/base
+ envinfo
+ read IP4 _nil <<<$(getDefaultIp)
+ rlFileBackup /etc/sysconfig/nfs /etc/exports
+ run "mkdir -p $mnt $expdir $expdir_with_more_slash"
+ run "echo '$expdir *(rw,no_root_squash)' > /etc/exports"
+ run "echo '$expdir_with_more_slash *(rw,no_root_squash)' >> /etc/exports"
+ run 'service_nfs restart'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog-with-wrong-option
+ run "$prog -xxxx" 1-255 "should exit with an error code"
+ run "$prog -xxxx 2>&1 | egrep -i '(usage:|try.*for more info)'" 0 "should output usage to user"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog-without-args
+ run "$prog" 1-255 "should exit with an error code"
+ run "$prog 2>&1 | egrep -i '(usage:|try.*for more info)'" 0 "should output usage to user"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog--h
+ run "$prog -h" -
+ std=$($prog -h 2>&1)
+ run "$prog -h 2>&1 | egrep -i usage:" 0 "should output usage to user"
+ [ $? = 0 ] && {
+ options=$(echo "$std"|grep -o '\[-[a-z]\+\]')
+ [ ${#options} -gt 3 ] && {
+ optionNuma=$((${#options} - 3))
+ optionNumb=$(echo "$std" | sed -n "/\t-$options/p" | wc -l)
+ optionNumc=$(echo "$std" | sed -n "/\t-[a-zA-Z]/p" | wc -l)
+ run "test $optionNuma = $optionNumb"
+ run "test $optionNuma = $optionNumc"
+ run 'echo "$std" | sed -n "/\t-$options/p" | grep " "' 1
+ }
+ }
+ rlPhaseEnd
+
+if rpcinfo -p | awk '$2=="2"' | grep -q -w nfs; then
+ rlPhaseStartTest do-Test-$prog--o-vers=2
+ run "$prog localhost:$expdir $mnt -o vers=2"
+ run "umount -vvv $mnt &> >(tee verbose.log)"
+ run 'test $(wc -l <verbose.log) -gt 0'
+ rlPhaseEnd
+fi
+
+ rlPhaseStartTest do-Test-$prog-o-vers=3
+ run "$prog localhost:$expdir $mnt -o vers=3"
+ run "umount -vvv $mnt &> >(tee verbose.log)"
+ run 'test $(wc -l <verbose.log) -gt 0'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog-default-option
+ run "$prog localhost:$expdir $mnt"
+ run "umount -vvv $mnt &> >(tee verbose.log)"
+ run 'test $(wc -l <verbose.log) -gt 0'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog-with-more-slash-after-:
+ run "$prog localhost://$expdir $mnt"
+ run "umount -vvv $mnt"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-$prog-with-more-slash-in-export-path
+ run "$prog localhost:$expdir_with_more_slash $mnt"
+ run "umount -vvv $mnt"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup do-Cleanup
+ rlFileRestore
+ run "service_nfs restart"
+ rm -rf $mnt $expdir $expdir_with_more_slash
+ rlPhaseEnd
+rlJournalEnd
+#rlJournalPrintText
+
diff --git a/tests/nfs-mount-options-all/PURPOSE b/tests/nfs-mount-options-all/PURPOSE
new file mode 100644
index 0000000..191d93c
--- /dev/null
+++ b/tests/nfs-mount-options-all/PURPOSE
@@ -0,0 +1,3 @@
+Description:
+ Test nfs general mount options supported by all nfs versions.
+ Especially test it within specific scenarioes.
diff --git a/tests/nfs-mount-options-all/_env b/tests/nfs-mount-options-all/_env
new file mode 100644
index 0000000..bfd8320
--- /dev/null
+++ b/tests/nfs-mount-options-all/_env
@@ -0,0 +1,7 @@
+export TOPLEVEL_NAMESPACE=nfs-utils
+export PKG_NAMESPACE=nfs-utils
+export RELATIVE_PATH=nfs-mount-options-all
+export PACKAGE=nfs-utils
+export PACKAGE_NAME=nfs-utils
+export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
+export TEST=/nfs-utils/nfs-mount-options-all
diff --git a/tests/nfs-mount-options-all/runtest.sh b/tests/nfs-mount-options-all/runtest.sh
new file mode 100644
index 0000000..3ac4857
--- /dev/null
+++ b/tests/nfs-mount-options-all/runtest.sh
@@ -0,0 +1,347 @@
+#!/bin/bash
+# set -x # uncomment for debugging
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: Test for nfs mount options
+# Author: Bill Peck <bpeck@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2006 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+#===============================================================================
+
+TESTNAME=${TEST/*\//}
+expdir=/exportdir/home
+nfsmp=/mnt/$TESTNAME
+
+ORIGINAL_HOSTNAME=$HOSTNAME
+
+rlJournalStart
+ rlPhaseStartSetup do-$role-Setup-
+ # Load beakerlib you needed
+ rlImport kernel/base
+ envinfo
+ rlFileBackup /etc/sysconfig/nfs /etc/exports
+ if echo "$HOSTNAME" | grep -q "localhost"; then
+ # In case "localhost.localdomain"
+ hostnamectl set-hostname nfs-mount-options-all.test
+ HOSTNAME=nfs-mount-options-all.test
+ fi
+ run 'rm -rf $expdir $nfsmp && mkdir -p $expdir $nfsmp'
+ run 'chmod 777 $expdir'
+ run 'echo "$expdir *(rw,sync,no_root_squash)" >/etc/exports'
+ run 'service_nfs restart'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-$role-Test-fg_bg_retry_devil
+ read IP4 _nil <<<$(getDefaultIp)
+ run 'iptables -F' -
+ MNT_OPTS="vers=3,soft,fg,retry=1"
+ log "{Info} Retry 1 minute (60s) NFS mount in *foreground* before giving up."
+ run 'iptables -A INPUT -s $IP4 -j DROP' -
+ run 'iptables -L' -
+ run 'sleep 10'
+ start_time=$(date +%s)
+ run "mount ${IP4}:$expdir $nfsmp -o ${MNT_OPTS}" 1-255
+ retry_time=$((`date +%s` - start_time))
+ log "{Info} Actually the nfs.mount hang $retry_time seconds."
+ run 'ps aux | grep -v grep | grep ${MNT_OPTS}' 1
+ run 'iptables -F' -
+ run 'ip6tables -F' -
+ run 'mountpoint $nfsmp && umount $nfsmp' 1
+
+ MNT_OPTS="vers=3,soft,bg,retry=1"
+ log "{Info} Retry 1 minute (60s) NFS mount in *background* before giving up."
+ run 'iptables -A INPUT -s $IP4 -j DROP' -
+ run 'iptables -L' -
+ run 'sleep 10'
+ # When background exit and fork an childprocess, still, returns 0
+ run "mount ${IP4}:$expdir $nfsmp -o ${MNT_OPTS}" 0 "should return ok"
+ if [ $? -eq 0 ]; then
+ # bg ground, the mount fork an child process
+ run 'ps aux | grep -v grep | grep ${MNT_OPTS}' 0 "works in bg.. show background process"
+ [ $? = 0 ] && {
+ log "{Info} We are sleeping a little longer than 60 seconds (retry=1)."
+ run "sleep $((retry_time + 10))" 0 "Actually a little more than $retry_time seconds."
+ # demo mounting process should exit after 60s as retry=1 (minute)
+ run 'ps aux | grep -v grep | grep ${MNT_OPTS}' 1 "retry=1 for 60s should works file after sleep 70s"
+ }
+ fi
+ run 'iptables -F' -
+ # should not mount successfully as it expired
+ run 'mountpoint $nfsmp && umount $nfsmp' 1
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-retry-option-should-not-be-ignored
+ # test retry of the default value (2 minutes) for foreground - NFS(5)
+ run "service_nfs stop"
+ run "mount ${HOSTNAME}:$expdir $nfsmp &"
+ run "sleep 100 ; service_nfs start ; sleep 10"
+ run "nfsstat -m | grep $nfsmp" 0
+ [ $? = 0 ] && run "umount $nfsmp"
+
+ # test retry of 10 minutes for foreground
+ MNT_OPTS="retry=10"
+ log "\n{Info} ${MNT_OPTS}"
+ run "service_nfs stop"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS} &"
+ run "sleep 10 ; service_nfs start ; sleep 10"
+ run "nfsstat -m | grep $nfsmp" 0
+ [ $? = 0 ] && run "umount $nfsmp"
+
+ # test retry of 100 minutes for background
+ MNT_OPTS="bg,retry=100"
+ log "\n{Info} ${MNT_OPTS}"
+ run "service_nfs stop"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run "sleep 10 ; service_nfs start ; sleep 10"
+ run "nfsstat -m | grep $nfsmp"
+ [ $? = 0 ] && run "umount $nfsmp"
+
+ # test retry of the default value (10000 minutes) for background - NFS(5)
+ MNT_OPTS="bg"
+ log "\n{Info} ${MNT_OPTS}"
+ run "service_nfs stop"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run "sleep 10 ; service_nfs start ; sleep 10"
+ run "nfsstat -m | grep $nfsmp"
+ [ $? = 0 ] && run "umount $nfsmp"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-$role-Test-resvport_noresvport_test
+ run 'service_nfs restart'
+ MNT_OPTS="resvport"
+ log "{Info} ${MNT_OPTS}"
+ run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}' 0
+ run 'mountpoint $nfsmp && umount $nfsmp'
+
+ MNT_OPTS="noresvport"
+ log "{Info} ${MNT_OPTS}"
+ run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}' 1-255 "should got permission denied"
+ run 'mountpoint $nfsmp && umount $nfsmp' 1
+ rlPhaseEnd
+
+ rlPhaseStartTest do-$role-Test-cache_nocache_test
+ MNT_OPTS="noac"
+ log "\n{Info} ${MNT_OPTS}"
+ run 'chmod 777 $expdir'
+ run 'touch $expdir/foo.txt && chmod 777 $expdir/foo.txt'
+ run 'service_nfs restart'
+ run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}' 0
+ [ $? -eq 0 ] && {
+ ATTR_TMP1=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
+ chmod 666 $expdir/foo.txt
+ sleep 1
+ ATTR_TMP2=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
+ log "{Info} $ATTR_TMP1 ~ $ATTR_TMP2"
+ run "[ x"$ATTR_TMP1" != x"$ATTR_TMP2" ]" 0 "with noac, attribution should not cached"
+ }
+ run 'mountpoint $nfsmp && umount $nfsmp'
+ run 'rm -f $expdir/foo.txt'
+
+ MNT_OPTS="ac,acregmin=20,acregmax=40,acdirmin=30,acdirmax=60"
+ log "\n{Info} ${MNT_OPTS}"
+ run 'touch $expdir/foo.txt && chmod 777 $expdir/foo.txt'
+ run 'mkdir $expdir/foo.dir && chmod 777 $expdir/foo.dir'
+ run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}'
+ [ $? -eq 0 ] && {
+ ATTR_TMPREG1=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
+ ATTR_TMPDIR1=$(ls -al $nfsmp | grep foo.dir | awk '{ print $1 }')
+ chmod 666 $expdir/foo.txt
+ chmod 555 $expdir/foo.dir
+ sleep 7
+ ATTR_TMPREG2=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
+ sleep 7 #7+7
+ ATTR_TMPDIR2=$(ls -al $nfsmp | grep foo.dir | awk '{ print $1 }')
+ sleep 30 #7+7+30
+ ATTR_TMPREG3=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
+ sleep 20 #7+7+30+20
+ ATTR_TMPDIR3=$(ls -al $nfsmp | grep foo.dir | awk '{ print $1 }')
+
+ log "{Info} Regfile Attribution: $ATTR_TMPREG1 ~ $ATTR_TMPREG2 ~ $ATTR_TMPREG3"
+ run '[ x"$ATTR_TMPREG1" == x"$ATTR_TMPREG2" -a x"$ATTR_TMPREG1" != x"$ATTR_TMPREG3" ]'
+
+ log "{Info} Directory Attribution: $ATTR_TMPDIR1 ~ $ATTR_TMPDIR2 ~ $ATTR_TMPDIR3"
+ run '[ x"$ATTR_TMPDIR1" == x"$ATTR_TMPDIR2" -a x"$ATTR_TMPDIR1" != x"$ATTR_TMPDIR3" ]'
+ }
+ run 'mountpoint $nfsmp && umount $nfsmp'
+ run 'rm -f $expdir/foo.txt'
+ run 'rm -rf $expdir/foo.dir'
+
+ MNT_OPTS="ac,actimeo=20"
+ log "\n{Info} ${MNT_OPTS}"
+ run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}'
+ [ $? -eq 0 ] && {
+ run 'grep ${TESTNAME} /proc/mounts | grep "acregmin=20" | grep "acregmax=20" | grep "acdirmin=20" | grep "acdirmax=20"'
+ }
+ run 'mountpoint $nfsmp && umount $nfsmp'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-$role-Test-sharecache_nosharecache_test
+ MNT_OPTS="vers=3,nosharecache"
+ MNT_OPTS="nosharecache,ac,acregmin=30,acregmax=60"
+ log "\n{Info} ${MNT_OPTS}"
+ run 'chmod 777 $expdir'
+ run 'touch $expdir/foo.txt && chmod 777 $expdir/foo.txt'
+ run 'mkdir -p $nfsmp-{1,2}'
+ run 'service_nfs restart'
+
+ run 'mount ${HOSTNAME}:$expdir $nfsmp-1 -o ${MNT_OPTS} &&
+ mount ${HOSTNAME}:$expdir $nfsmp-2 -o ${MNT_OPTS}'
+ [ $? = 0 ] && {
+ chmod 555 $nfsmp-1/foo.txt
+ sleep 1
+ chmod 444 $nfsmp-2/foo.txt
+
+ ATTR_TMPREG1=$(ls -al $nfsmp-1 | grep foo.txt | awk '{ print $1 }')
+ ATTR_TMPREG2=$(ls -al $nfsmp-2 | grep foo.txt | awk '{ print $1 }')
+ ATTR_TMPREG3=$(ls -al $expdir/ | grep foo.txt | awk '{ print $1 }')
+
+ log "{Info} $ATTR_TMPREG1 ~ $ATTR_TMPREG2 ~ $ATTR_TMPREG3"
+ run '[ x"$ATTR_TMPREG1" == x"$ATTR_TMPREG2" -a x"$ATTR_TMPREG1" == x"$ATTR_TMPREG3" ]'
+ }
+ run 'mountpoint $nfsmp-1 && umount $nfsmp-1'
+ run 'mountpoint $nfsmp-2 && umount $nfsmp-2'
+ run 'rm -f $expdir/foo.txt'
+ run 'rm -rf $nfsmp-{1,2}'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-$role-Test-lookupcache_test
+ MNT_OPTS="ac,acdirmin=30,acdirmax=60,lookupcache=pos"
+ log "\n{Info} ${MNT_OPTS}"
+ run 'chmod 777 $expdir'
+ run 'mkdir -p $expdir/foodir && touch $expdir/foodir/foo-1.txt'
+ run 'service_nfs restart'
+ run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}'
+ [ $? = 0 ] && {
+ run 'ls -l $nfsmp/foodir/ | grep foo-1.txt'
+ run 'rm -f $expdir/foodir/foo-1.txt'
+ run 'sleep 1' -
+ log "{Info} Checking again..."
+ run 'ls -l $nfsmp/foodir/ | grep foo-1.txt' 1
+ run 'umount $nfsmp'
+ }
+ run 'rm -fr $expdir'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-$role-Test-rsize-wsize
+ minSize=1024
+ minFixSize=4096
+ #maxSize=1048576
+ run "cat /proc/fs/nfsd/max_block_size" 0 "The default max block size varies depending on RAM size, with a maximum of 1M."
+ maxSize=$(cat /proc/fs/nfsd/max_block_size)
+ run 'mkdir -p $expdir'
+ run 'echo "$expdir *(rw,sync,no_root_squash)" > /etc/exports'
+ run 'service_nfs restart'
+ MNT_OPTS="rsize=1024,wsize=1024"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run 'grep $nfsmp /proc/mounts' -
+ run "cat /proc/mounts | grep -q $MNT_OPTS"
+ run 'umount $nfsmp'
+ MNT_OPTS="rsize=8192,wsize=8192"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run 'grep $nfsmp /proc/mounts' -
+ run "cat /proc/mounts | grep -q $MNT_OPTS"
+ run 'umount $nfsmp'
+ MNT_OPTS="rsize=1,wsize=255" # less than min_size($minSize)
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run 'grep $nfsmp /proc/mounts' -
+ run "cat /proc/mounts | grep -q rsize=$minFixSize,wsize=$minFixSize" 0 "Specified values lower than $minSize are replaced with $minFixSize"
+ run 'umount $nfsmp'
+ MNT_OPTS="rsize=1048577,wsize=2048576" # great than max_size($maxSize)
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run 'grep $nfsmp /proc/mounts' -
+ run "cat /proc/mounts | grep -q rsize=$maxSize,wsize=$maxSize" 0 "Specified values more than $maxSize are replaced with $maxSize"
+ run 'umount $nfsmp'
+ MNT_OPTS="rsize=0,wsize=0"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
+ run 'grep $nfsmp /proc/mounts' -
+ run "cat /proc/mounts | grep -q rsize=$maxSize,wsize=$maxSize" 0 "Specified values more than $maxSize are replaced with $maxSize"
+ run 'umount $nfsmp'
+ MNT_OPTS="rsize=-1,wsize=-3"
+ run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}" 1-255
+ rlPhaseEnd
+
+for V in $(ls_nfsvers); do
+ rlPhaseStartTest do-$role-NFS-mount-options-can-be-lost-when-using-bg-option-vers${V}
+ run 'service_nfs stop'
+ run 'mount -v -t nfs -o rw,bg,hard,nointr,tcp,vers=$V,timeo=600,rsize=32768,wsize=32768,actimeo=0,noac localhost:$expdir $nfsmp'
+ run 'service_nfs start'
+ run 'while ! grep -q $nfsmp /proc/mounts; do sleep 15; done' -
+ run 'grep $nfsmp /proc/mounts'
+ run 'grep $nfsmp /proc/mounts | grep -q "rw,sync"'
+ if [ "$V" = "2" ]; then
+ run 'grep $nfsmp /proc/mounts | grep -q "vers=$V,rsize=8192,wsize=8192"'
+ else
+ run 'grep $nfsmp /proc/mounts | grep -q "vers=$V,rsize=32768,wsize=32768"'
+ fi
+ run 'grep $nfsmp /proc/mounts | grep -q "acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noac,proto=tcp"'
+ run 'grep $nfsmp /proc/mounts | grep -q "timeo=600,retrans=2,sec=sys"'
+ run "umount $nfsmp"
+ rlPhaseEnd
+done
+
+ rlPhaseStartTest do-$role-Test-"mount-nfs-needs-descriptive-error-when-nfsvers-specified-incorrectly"
+ run "log=`mktemp -q`" 0 "Creating temporary log file"
+ log "{Info} Specify the invalid value."
+ for vers in {"v3","vers","+","*",""}; do
+ run "mount -t nfs -o vers=$vers localhost:$expdir $nfsmp 2>$log" 32 \
+ "should be failed as expected using invalid value"
+ run "mount -t nfs -o nfsvers=$vers localhost:$expdir $nfsmp 2>>$log" 32 \
+ "should be failed as expected using invalid value"
+ run "cat $log" -
+ run "egrep -q 'Bad nfs mount parameter|parsing error|invalid value' $log"
+ run ">$log" 0 "clear $log content"
+ done
+ log "{Info} Specify the valid number (maybe not supported)."
+ run "ls_nfsvers" -
+ for vers in {1,2,3,4,5,23}; do
+ if ls_nfsvers | grep -q "^$vers"; then
+ run "mount -t nfs -o vers=$vers localhost:$expdir $nfsmp"
+ run "umount $nfsmp"
+ run "mount -t nfs -o nfsvers=$vers localhost:$expdir $nfsmp"
+ run "umount $nfsmp"
+ else
+ run "mount -t nfs -o vers=$vers localhost:$expdir $nfsmp 2>$log" 32 \
+ "should be failed as expected using unsupported version"
+ [ $? = 0 ] && run "umount $nfsmp"
+ run "mount -t nfs -o nfsvers=$vers localhost:$expdir $nfsmp 2>>$log" 32 \
+ "should be failed as expected using unsupported version"
+ [ $? = 0 ] && run "umount $nfsmp"
+ run "cat $log" -
+ run "egrep -q 'not supported|parsing error|invalid value|call failed' $log"
+ run ">$log" 0 "clear $log content"
+ fi
+ done
+ run "rm -f $log" 0 "Remove temporary log file"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup do-$role-Cleanup-
+ run 'mountpoint $nfsmp && umount $nfsmp' 1
+ hostnamectl set-hostname $ORIGINAL_HOSTNAME
+ run 'rm -rf $expdir $nfsmp'
+ rlFileRestore
+ run 'service_nfs restart'
+ rlPhaseEnd
+rlJournalEnd
+#rlJournalPrintText
+
diff --git a/tests/systemd-nfs/PURPOSE b/tests/systemd-nfs/PURPOSE
new file mode 100644
index 0000000..556df42
--- /dev/null
+++ b/tests/systemd-nfs/PURPOSE
@@ -0,0 +1 @@
+# nothing
diff --git a/tests/systemd-nfs/_env b/tests/systemd-nfs/_env
new file mode 100644
index 0000000..d90f45d
--- /dev/null
+++ b/tests/systemd-nfs/_env
@@ -0,0 +1,7 @@
+export TOPLEVEL_NAMESPACE=nfs-utils
+export PKG_NAMESPACE=nfs-utils
+export RELATIVE_PATH=systemd-nfs
+export PACKAGE=nfs-utils
+export PACKAGE_NAME=nfs-utils
+export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
+export TEST=/nfs-utils/systemd-nfs
diff --git a/tests/systemd-nfs/runtest.sh b/tests/systemd-nfs/runtest.sh
new file mode 100755
index 0000000..227ec36
--- /dev/null
+++ b/tests/systemd-nfs/runtest.sh
@@ -0,0 +1,287 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: test for: nfs
+# Author: Jianhong Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2014 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+#===============================================================================
+
+#signal trap
+trap "cleanup" SIGINT SIGTERM SIGHUP SIGQUIT
+cleanup() {
+ rlFileRestore
+ run 'service_nfsconfig restart'
+ #rm -rf $expdir $nfsmp
+}
+
+#global var define
+serv=nfs
+rpm -q systemd || {
+ echo "{Warn} no systemd installed, skip the test"
+ report_result $TEST PASS
+ exit 0
+}
+
+rlJournalStart
+ rlPhaseStartSetup do-Setup-
+ # Load beakerlib you needed
+ rlImport kernel/base
+ envinfo
+ rlFileBackup /etc/exports /etc/sysconfig/nfs
+ run 'echo "/usr/share *(ro)" >/etc/exports'
+ run 'echo "RPCNFSDARGS=8" >/etc/sysconfig/nfs' 0 "avoid invalid config file"
+ run 'service_nfsconfig restart' 0 "RHEL-7.1 or later need restart nfs-config to reload /etc/sysconfig/nfs"
+ run "useradd testuserqa" -
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-start
+ run "service_$serv start" 0 "Service must start without problem"
+ run "service_$serv status" 0 "Then Status command"
+ run "service_$serv start" 0 "Already started service"
+ run "service_$serv status" 0 "Again status command"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-restart
+ run "service_$serv restart" 0 "Restarting of service"
+ run "service_$serv status" 0 "Status command"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-stop
+ run "service_$serv stop" 0 "Stopping service"
+ run "service_$serv status" 3 "Status of stopped service"
+ run "service_$serv stop" 0 "Stopping service again"
+ run "service_$serv status" 3 "Status of stopped service"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"insufficient-rights"
+ run "service_$serv restart " 0 "Starting service for restarting under nonpriv user"
+ run "su testuserqa -c 'service_$serv stop'" 1,4 "Insufficient rights, stopping service under nonprivileged user must fail"
+ run "su testuserqa -c 'service_$serv start'" 0,1,4 "Insufficient rights, starting service under nonprivileged user must fail or pass as already started"
+ run "su testuserqa -c 'service_$serv status'" 0 "Sufficient rights, service status should be accessible to nonprivileged users"
+ run "service_$serv stop" 0 "Stopping service for starting under nonpriv user"
+ run "su testuserqa -c 'service_$serv start'" 1,4 "Insufficient rights, starting of stopped service under nonprivileged user must fail"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"operations"
+ run "service_$serv start" 0 "Service have to implement start function"
+ run 'sleep 5' 0 "sleep a while avoid the start rate limit"
+ run "service_$serv restart" 0 "Service have to implement restart function"
+ run "service_$serv status" 0 "Service have to implement status function"
+ run 'sleep 5' 0 "sleep a while avoid the start rate limit"
+ run "service_$serv condrestart" 0 "Service have to implement condrestart function"
+ [ $? != 0 ] && run "journalctl -xn" -
+ run 'sleep 5' 0 "sleep a while avoid the start rate limit"
+ run "service_$serv try-restart" 0 "Service have to implement try-restart function"
+ [ $? != 0 ] && run "journalctl -xn" -
+ run "service_$serv reload" 0 "Service have to implement reload function"
+ [ $? != 0 ] && run "journalctl -xn" -
+ run "service_$serv force-reload" 0 "Service have to implement force-reload function"
+ [ $? != 0 ] && run "journalctl -xn" -
+ run "service_$serv noexistop" 2 "Testing proper return code when nonexisting function"
+ rlPhaseEnd
+
+ # Should do nothing if a service is already stopped or not running (according to manpage of systemctl)
+ # http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT
+ rlPhaseStartTest do-Test-"operations-stopped"
+ run "service_$serv stop" 0 "Service have to implement stop function"
+ run "service_$serv condrestart" 0 "Service have to implement condrestart function"
+ run "service_$serv try-restart" 0 "Service have to implement try-restart function"
+ run "service_$serv force-reload" 0 "Service have to implement force-reload function"
+ run "service_$serv status" 3 "Above oprations should do nothing if service are not running"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-enable-disable-$serv
+ if systemctl --quiet is-enabled $serv; then
+ run "systemctl disable $serv" 0 "Disable service on boot"
+ run "systemctl is-enabled $serv" 1 "Check whether service is disabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "systemctl enable $serv" 0 "Enable service on boot"
+ run "systemctl is-enabled $serv" 0 "Check whether service is enabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ else
+ run "systemctl enable $serv" 0 "Enable service on boot"
+ run "systemctl is-enabled $serv" 0 "Check whether service is enabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "systemctl disable $serv" 0 "Disable service on boot"
+ run "systemctl is-enabled $serv" 1 "Check whether service is disabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ fi
+ rlPhaseEnd
+
+ # ystemctl enable fails for symlinks in /usr/lib/systemd/system
+ # Use a workaround to test enable/disable with nfs-server.service
+ rlPhaseStartTest do-Test-enable-disable-nfs-server
+ if systemctl --quiet is-enabled nfs-server; then
+ run "systemctl disable nfs-server" 0 "Disable nfs-serverice on boot"
+ run "systemctl is-enabled nfs-server" 1 "Check whether nfs-serverice is disabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "systemctl enable nfs-server" 0 "Enable nfs-serverice on boot"
+ run "systemctl is-enabled nfs-server" 0 "Check whether nfs-serverice is enabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ else
+ run "systemctl enable nfs-server" 0 "Enable nfs-serverice on boot"
+ run "systemctl is-enabled nfs-server" 0 "Check whether nfs-serverice is enabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "systemctl disable nfs-server" 0 "Disable nfs-serverice on boot"
+ run "systemctl is-enabled nfs-server" 1 "Check whether nfs-serverice is disabled"
+ run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ fi
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-nfsv4-only
+ run 'service nfs stop'
+ # MOUNTD_NFS_V2 MOUNTD_NFS_V3 was not supported in RHEL-7.x
+ run 'echo -e "RPCMOUNTDOPTS=\"-N 2 -N 3\"" >>/etc/sysconfig/nfs' 0 "enabling nfsv4 only"
+ # If in RHEL-7.1 or later need restart nfs-config service to flush /etc/sysconfig/nfs to /run/sysconfig/nfs-utils
+ # But since RHEL-7.3, nfs-config change to be ru-run during the dependent service starting
+ run 'service_nfsconfig status &>/dev/null && service_nfsconfig restart' -
+ run 'cat /run/sysconfig/nfs-utils | grep RPCMOUNTDARGS | grep "\""' 0 "quote variable in /run/sysconfig/nfs-utils"
+ run 'sleep 5' 0 "sleep a while avoid service script bug"
+ run 'service_nfs start'
+ run 'rpcinfo -s | grep -w mountd' 1 "if nfsv4 only, no mountd info in rpcinfo"
+ rlFileRestore /etc/sysconfig/nfs
+ run 'service_nfsconfig restart'
+ rlPhaseEnd
+
+ # Since nfs-service no longer starts the daemons in question. They are now split
+ # into their own services (nfs-mountd.service, rpc-statd.service, nfs-idmapd.service).
+ # Then `systemctl status nfs-server.service` cannot accurately reflect the
+ # state of the combination of daemons that are needed for a working NFS server.
+ rlPhaseStartTest do-Test-"nfs-server-is-active-even-processes-terminated"
+ run 'service_nfs restart'
+ run 'pkill rpc.mountd' -
+ run 'killall -9 nfsd' -
+ run 'ps axf | grep -e "rpc.mountd" -e "nfsd"' -
+ run 'service nfs-mountd status' 1-255
+ run 'rpcinfo -t localhost 100005' 1 "pings mountd"
+ log '{Info} nfsserver resource agent has been updated to monitor all its daemons'
+ run 'service_nfs status' 1-255,0
+ run 'service_nfs status 2>&1 | grep "active"' -
+ run 'service_nfs stop'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"should-auto-mount-/proc/fs/nfsd"
+ run 'service_nfs restart'
+ run 'service_nfs stop'
+ run 'umount /proc/fs/nfsd'
+ run 'service_nfs start 2>&1 | grep "mount -t nfsd"' 1 "should auto mount nfsd"
+ run 'mount -t nfsd nfsd /proc/fs/nfsd' -
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"use-rpcbind.service-in-nfs-server.service"
+ run "systemctl reset-failed" 0 "workaround for failure of starting too often"
+ log "{Info} Starting nfs while rpcbind is stopped"
+ run "service rpcbind stop; service rpcbind stop" 0 "stop twice as workaround"
+ run "service rpcbind status" 3 "rpcbind.service should be stopped"
+ run "service nfs restart"
+ run "service nfs status" 0 "should start nfs successfully"
+ run "service rpcbind status" 0 "starting nfs should bring rpcbind up"
+
+ log "{Info} Starting nfs while rpcbind is active"
+ run "service rpcbind start"
+ run "service rpcbind status" 0 "rpcbind should be active"
+ run "service nfs restart"
+ run "service nfs status" 0 "should start nfs successfully"
+ run "service rpcbind status" 0 "starting nfs should keep rpcbind up"
+
+ log "{Info} Stopping nfs while rpcbind is active"
+ run "service rpcbind start"
+ run "service rpcbind status" 0 "rpcbind should be active"
+ run "service nfs start; service nfs status"
+ run "service nfs stop; service nfs status" 3
+ run "service rpcbind status" 0 "stopping nfs should keep rpcbind up"
+
+ log "{Info} Stopping nfs while rpcbind is stopped"
+ run "service nfs start" 0 "firstly start nfs since it can bring rpcbind up"
+ run "service nfs status" 0 "should start nfs successfully"
+ run "service rpcbind stop; service rpcbind stop" 0 "stop twice as workaround"
+ run "service rpcbind status" 3 "rpcbind should be stopped"
+ run "service nfs stop"
+ # If a daemon tries to connect to port 111 systemd will start rpcbind automaticly
+ run "service rpcbind status" 0 "stopping nfs should bring rpcbind up"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"restarting rpbind also restart the the nfs server"
+ run "systemctl reset-failed" 0 "workaround for failure of starting too often"
+ log "{Info} Starting rpcbind while nfs is stopped"
+ run "service nfs stop"
+ run "service nfs status" 3 "nfs should be stopped"
+ run "service rpcbind restart"
+ run "service nfs status" 3 "starting rpcbind should NOT bring nfs up"
+
+ log "{Info} Starting rpcbind while nfs is active"
+ run "service nfs start"
+ run "service nfs status" 0 "nfs should be active"
+ run "service rpcbind restart"
+ run "service nfs status" 0 "starting rpcbind should NOT interfere nfs"
+
+ log "{Info} Stopping rpcbind while nfs is active"
+ run "service nfs start"
+ run "service nfs status" 0 "nfs should be active"
+ run "service rpcbind start; service rpcbind stop"
+ run "service nfs status" 0 "stopping rpcbind should NOT bring nfs down"
+
+ log "{Info} Stopping rpcbind while nfs is stopped"
+ run "service nfs stop"
+ run "service nfs status" 3 "nfs should be stopped"
+ run "service rpcbind start; service rpcbind stop"
+ run "service nfs status" 3 "stopping rpcbind should NOT interfere nfs"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-fix-long-nfsd-startup-delay-in-absence-of-rpcbind
+ run "systemctl stop rpcbind"
+ run "systemctl stop nfs-server"
+ run "systemctl mask rpcbind" 0 "Mask systemd service rpcbind.service"
+ run "timeLimitRun 10 systemctl start nfs-server" 1-255 "Start service nfs-server without rpcbind will be failed due to systemd unit dependency"
+ run "systemctl unmask rpcbind"
+ run "timeLimitRun 10 systemctl stop nfs-server" -
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"nfs-utils need to cause gssproxy reload"
+ run "cp /etc/gssproxy/gssproxy.conf /etc/gssproxy/gssproxy.conf.backup" 0 "backuping"
+ run "echo '[gssproxy]' > /etc/gssproxy/gssproxy.conf"
+ run "echo 'debug = true' >> /etc/gssproxy/gssproxy.conf"
+ run "systemctl restart gssproxy"
+#FIXME when BZ#1535424 is fixed. Should not use /var/log/messages as it is not used on Fedora any more.
+ run "echo '' > /var/log/messages"
+ run "systemctl restart nfs"
+ run "systemctl status nfs"
+ run "systemctl status gssproxy"
+ run "cat /var/log/messages | grep 'gssproxy:'" -
+ run "cat /var/log/messages | grep -q 'gssproxy:.*loaded'" 0 "should re-reading config"
+ run "mv /etc/gssproxy/gssproxy.conf.backup /etc/gssproxy/gssproxy.conf" 0 "recovering"
+ run "systemctl restart gssproxy"
+ rlPhaseEnd
+
+ rlPhaseStartCleanup do-Cleanup-
+ run "userdel -rf testuserqa" -
+ rlFileRestore
+ run 'timeLimitRun 10 service_nfsconfig restart'
+ rlPhaseEnd
+
+rlJournalEnd
+#rlJournalPrintText
+#enable_avc_check
diff --git a/tests/systemd-nfs/subtest.yml b/tests/systemd-nfs/subtest.yml
new file mode 100644
index 0000000..705c8b0
--- /dev/null
+++ b/tests/systemd-nfs/subtest.yml
@@ -0,0 +1,2 @@
+attr: {ssched: yes.dangerous}
+attr: {ssched: yes.dangerous}, setup: [--kernel-options=ipv6.disable=1]
diff --git a/tests/tests.yml b/tests/tests.yml
new file mode 100644
index 0000000..8b5bd0d
--- /dev/null
+++ b/tests/tests.yml
@@ -0,0 +1,20 @@
+---
+# Tests that run in classic context
+- hosts: localhost
+ roles:
+ - role: standard-test-rhts
+ use_beakerlib_libraries: yes
+ tags:
+ - classic
+ tests:
+ - exportfs
+ - export-mount-local
+ - mount
+ - nfs-mount-options-all
+ - systemd-nfs
+ - umount
+ required_packages:
+ - bind-utils # export-mount-local needs this package
+ - findutils # beakerlib needs find command
+ - nfs-utils
+ - redhat-lsb-core # lsb_release is needed by tests
diff --git a/tests/umount/PURPOSE b/tests/umount/PURPOSE
new file mode 100644
index 0000000..9f896d5
--- /dev/null
+++ b/tests/umount/PURPOSE
@@ -0,0 +1,2 @@
+Description: Test for command umount.nfs{,4}
+Author: Stevens Yin <jiyin@redhat.com>
diff --git a/tests/umount/_env b/tests/umount/_env
new file mode 100644
index 0000000..dd7d64f
--- /dev/null
+++ b/tests/umount/_env
@@ -0,0 +1,7 @@
+export TOPLEVEL_NAMESPACE=nfs-utils
+export PKG_NAMESPACE=nfs-utils
+export RELATIVE_PATH=umount
+export PACKAGE=nfs-utils
+export PACKAGE_NAME=nfs-utils
+export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
+export TEST=/nfs-utils/umount
diff --git a/tests/umount/runtest.sh b/tests/umount/runtest.sh
new file mode 100644
index 0000000..8dee5c7
--- /dev/null
+++ b/tests/umount/runtest.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: Test for command umount.nfs{,4}
+# Author: Stevens Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+#===============================================================================
+
+mnt=/nfs-mount
+expDir=/expDir
+prog=umount.nfs
+
+rlJournalStart
+ rlPhaseStartSetup do-Setup
+ # Load beakerlib you needed
+ rlImport kernel/base
+ envinfo
+ read IP4 _nil <<<$(getDefaultIp)
+ rlFileBackup /etc/sysconfig/nfs /etc/exports
+ run "mkdir -p $mnt $expDir"
+ run "echo '$expDir *(rw,no_root_squash,fsid=0)' > /etc/exports"
+ run 'service_nfs restart'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog-with-wrong-option
+ run "$prog -xxxx" 1-255 "should exit with an error code"
+ run "$prog -xxxx 2>&1 | egrep -i '(usage:|try.*for more info)'" 0 "should output usage to user"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog-without-args
+ run "$prog" 1-255 "should exit with an error code"
+ run "$prog 2>&1 | egrep -i '(usage:|try.*for more info)'" 0 "should output usage to user"
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-$prog--h
+ run "$prog -h" -
+ std=$($prog -h 2>&1)
+ run "$prog -h 2>&1 | egrep -i usage:"
+ [ $? = 0 ] && {
+ options=$(echo "$std"|grep -o '\[-[a-z]\+\]')
+ [ ${#options} -gt 3 ] && {
+ optionNuma=$((${#options} - 3))
+ optionNumb=$(echo "$std" | sed -n "/\t-$options/p" | wc -l)
+ optionNumc=$(echo "$std" | sed -n "/\t-[a-zA-Z]/p" | wc -l)
+ run "test $optionNuma = $optionNumb"
+ run "test $optionNuma = $optionNumc"
+ run 'echo "$std" | sed -n "/\t-$options/p" | grep " "' 1
+ }
+ }
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-Cannot-umount-NFS-mp-with-spaces
+ serv=localhost
+ expdirWithSpaces="/expdir with spaces"
+ nfsmpWithSpaces="/mnt/nfsmp with spaces"
+ run 'mkdir -p "$expdirWithSpaces" "$nfsmpWithSpaces"'
+ run 'echo "\"$expdirWithSpaces\" *(rw,no_root_squash,fsid=0)" > /etc/exports'
+ run 'service_nfs restart'
+ run 'service_nfs restart 2>&1 | grep "expdir with spaces does not support"' 1 \
+ "exportfs give incorrect message for mount dir containing spaces"
+ run 'mount -t nfs "$serv:$expdirWithSpaces" "$nfsmpWithSpaces"' 0 "mount dir with spaces"
+ run 'grep "$nfsmpWithSpaces" /proc/mounts' -
+ run 'umount "$nfsmpWithSpaces"' 0 "umount dir with spaces"
+ run 'grep "$nfsmpWithSpaces" /proc/mounts' 1 "cat /proc/mounts and umount successfully"
+ run 'rm -rf "$expdirWithSpaces" "$nfsmpWithSpaces"'
+ rlPhaseEnd
+
+ rlPhaseStartTest do-Test-"[nfsv3] umount.nfs: Failed to find '' protocol"
+ log "{Info} Creating a small (separate) fs on a loopback device."
+ run "dd if=/dev/zero of=fs.img bs=1M count=1000" -
+ run "losetup /dev/loop0 fs.img" -
+ run "mkfs.ext4 /dev/loop0" -
+ run "mkdir $expDir/foo"
+ run "mount /dev/loop0 $expDir/foo"
+ log "{Info} Listing the contents of the directory to trigger a submount."
+ run "echo '$expDir *(crossmnt)' > /etc/exports"
+ run "service_nfs restart"
+ run "mount localhost:$expDir $mnt -o vers=3"
+ run "ls $mnt/foo"
+ run "cat /proc/mounts | grep $mnt" -
+ run "umount $mnt/foo &>stdout.log"
+ run "cat stdout.log" -
+ run "cat stdout.log | grep -q 'Failed'" 1 "should not output error msg"
+ run "umount $mnt"
+ log "{Info} Recovering it."
+ run "service_nfs stop"
+ run "umount $expDir/foo"
+ run "rm -rf $expDir/foo"
+ run "losetup -d /dev/loop0" -
+ run "rm -f fs.img" -
+ rlPhaseEnd
+
+ rlPhaseStartCleanup do-Cleanup
+ rlFileRestore
+ rm -rf $mnt $expDir
+ rlPhaseEnd
+rlJournalEnd
+#rlJournalPrintText
+
From 5218121ee7e9c9ed75f3d1b91bae0b2a15f154b2 Mon Sep 17 00:00:00 2001
From: Bruno Goncalves <bgoncalv@redhat.com>
Date: Jan 17 2019 20:02:54 +0000
Subject: [PATCH 2/6] fixed some test issues
---
diff --git a/tests/exportfs/runtest.sh b/tests/exportfs/runtest.sh
index 8e34a8c..69d9532 100755
--- a/tests/exportfs/runtest.sh
+++ b/tests/exportfs/runtest.sh
@@ -48,7 +48,7 @@ rlJournalStart
hostnamectl set-hostname exportfs.test
fi
#clean nfs garbage, avoid affect from pre case
- { exportfs -ua; service nfs stop &>/dev/null; }
+ { exportfs -ua; service_nfs stop &>/dev/null; }
rlFileBackup /etc/sysconfig/nfs /etc/exports
rlFileBackup --clean /etc/exports.d/
run 'rm -f /etc/exports.d/*'
@@ -148,7 +148,7 @@ rlJournalStart
rlPhaseStartTest do-Test-exportfs-when-/proc/fs/nfsd-not-mount
run 'mkdir -p ${expdir}_tmp'
- run 'service nfs start'
+ run 'service_nfs start'
run 'pkill rpc.mountd && umount /proc/fs/nfsd'
run 'exportfs -iv *:${expdir}_tmp'
run 'mount -t nfsd nfsd /proc/fs/nfsd' 0-255 "restore env: mount nfsd"
@@ -157,7 +157,7 @@ rlJournalStart
rlPhaseStartTest do-Test-option-nordirplus
#nfsv3 export option nordirplus support test
- run 'service nfs start'
+ run 'service_nfs start'
run 'exportfs -i -o nordirplus "*:$expdir"'
run 'mount -o vers=3 localhost:$expdir $nfsmp'
run 'grep $nfsmp /proc/mounts'
diff --git a/tests/systemd-nfs/runtest.sh b/tests/systemd-nfs/runtest.sh
index 227ec36..63d8593 100755
--- a/tests/systemd-nfs/runtest.sh
+++ b/tests/systemd-nfs/runtest.sh
@@ -38,7 +38,7 @@ cleanup() {
}
#global var define
-serv=nfs
+serv=nfs-server
rpm -q systemd || {
echo "{Warn} no systemd installed, skip the test"
report_result $TEST PASS
diff --git a/tests/tests.yml b/tests/tests.yml
index 8b5bd0d..865464b 100644
--- a/tests/tests.yml
+++ b/tests/tests.yml
@@ -2,7 +2,7 @@
# Tests that run in classic context
- hosts: localhost
roles:
- - role: standard-test-rhts
+ - role: standard-test-beakerlib
use_beakerlib_libraries: yes
tags:
- classic
@@ -16,5 +16,6 @@
required_packages:
- bind-utils # export-mount-local needs this package
- findutils # beakerlib needs find command
+ - iptables # nfs-mount-options-all needs this package
- nfs-utils
- redhat-lsb-core # lsb_release is needed by tests
From 69a4cec52d5d1803bfa88670501b4f8d1dcd9481 Mon Sep 17 00:00:00 2001
From: Bruno Goncalves <bgoncalv@redhat.com>
Date: Jan 18 2019 17:24:32 +0000
Subject: [PATCH 3/6] sync export-mount-local and systemd-nfs with tests from QE
---
diff --git a/tests/export-mount-local/Makefile b/tests/export-mount-local/Makefile
new file mode 100644
index 0000000..6ddfa94
--- /dev/null
+++ b/tests/export-mount-local/Makefile
@@ -0,0 +1,76 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: test for: export-mount
+# Author: Jianhong Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2014 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#Generate and export TEST= PACKAGE=
+TENV=_env
+ifeq ($(PKG_TOP_DIR),)
+ export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ export _TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ -include $(PKG_TOP_DIR)/env.mk
+endif
+include $(TENV)
+ifeq ($(_TOP_DIR),)
+ _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
+endif
+#===============================================================================
+export TESTVERSION=1.0
+
+BUILT_FILES=
+FILES=$(TENV) $(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
+. /usr/share/beakerlib/beakerlib.sh || exit 1; \
+. runtest.sh )
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+-include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Jianhong Yin <jiyin@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: test for: export-mount" >> $(METADATA)
+ @echo "Type: function" >> $(METADATA)
+ @echo "Type: $(PACKAGE)-level-tier1" >> $(METADATA)
+ @echo "TestTime: 30m" >> $(METADATA)
+ @echo "RunFor: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: $(PACKAGE)" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Requires: library(kernel/base)" >> $(METADATA)
+ @echo "Requires: nfs-utils" >> $(METADATA)
+ @echo "Requires: bind-utils" >> $(METADATA)
+ @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
+ rhts-lint $(METADATA)
diff --git a/tests/export-mount-local/runtest.sh b/tests/export-mount-local/runtest.sh
index e72e0f4..60d0c90 100755
--- a/tests/export-mount-local/runtest.sh
+++ b/tests/export-mount-local/runtest.sh
@@ -1,39 +1,43 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-# Description: test for: export-mount
+# Description: test for: export-mount-local
# Author: Jianhong Yin <jiyin@redhat.com>
-#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc.
#
-# This program is free software: you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 2 of
-# the License, or (at your option) any later version.
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
+# PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see http://www.gnu.org/licenses/.
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh || exit 1
+# Load beakerlib you needed
+rlImport kernel/base
+envinfo
+#disable_avc_check
+
#===============================================================================
#signal trap
trap "cleanup" SIGINT SIGTERM SIGHUP SIGQUIT
cleanup() {
- rlFileRestore
- rm -rf $expdir $nfsmp
+ rlFileRestore
+ rm -rf $expdir $nfsmp
}
#global var define
@@ -41,202 +45,180 @@ BZ=exp-mount-local
expdir=/exportDir-$BZ
nfsmp=/mnt/nfsmp-$BZ
subexpdir=/exportDir-$BZ/sub
-tmpnfsmp=/tmp/nfsmp-$BZ
+tmpnfsmp=${nfsmp}-tmp
-host="$HOSTNAME"
+read ipv4 _nil <<<$(getDefaultIp)
+read ipv6s _nil <<<$(getDefaultIp 6)
+ipv6="[$ipv6s]"
# in case "localhost.localdomain"
-echo "$host" | grep -q "localhost" && host="localhost"
+if echo "$HOSTNAME" | grep -q "localhost"; then
+ ORIGINAL_HOSTNAME="$HOSTNAME"
+ HOSTNAME="$BZ"
+ hostnamectl set-hostname "$HOSTNAME"
+fi
+host="$HOSTNAME"
rlJournalStart
rlPhaseStartSetup do-Setup-
- # Load beakerlib you needed
- rlImport kernel/base
- read ipv4 _nil <<<$(getDefaultIp)
- read ipv6s _nil <<<$(getDefaultIp 6 global)
- ipv6="[$ipv6s]"
- envinfo
- rlFileBackup /etc/exports /etc/sysconfig/nfs /etc/nfs.conf /etc/hosts
- if [ "$host" = "localhost" ]; then
+ rlFileBackup /etc/{exports,auto.master} /etc/sysconfig/{nfs,autofs} /etc/nfs.conf /etc/hosts
+ if [ -n "ORIGINAL_HOSTNAME" ]; then
run "echo '$ipv4 $host' >> /etc/hosts"
- if [ -n "$ipv6s" ]; then
- run "echo '$ipv6s $host' >> /etc/hosts"
- fi
+ run "echo '$ipv6s $host' >> /etc/hosts"
run "cat /etc/hosts" -
fi
- run 'rm -rf $expdir $nfsmp && mkdir -p $expdir $nfsmp'
- run 'rm -rf $subexpdir $tmpnfsmp && mkdir -p $subexpdir $tmpnfsmp'
- run 'echo "/tmp *(ro,sync)" >/etc/exports'
- run 'service_nfs restart'
- #avoid issues restarting the server too quickly
- sleep 10
- run 'ls_nfsvers'
+ run "rm -rf $expdir $nfsmp && mkdir -p $expdir $nfsmp"
+ run "rm -rf $subexpdir $tmpnfsmp && mkdir -p $subexpdir $tmpnfsmp"
+ run "service_nfs restart"
+ run "ls_nfsvers"
rlPhaseEnd
-for V in $(ls_nfsvers); do
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv4
- run "exportfs -au && exportfs -iv $ipv4:$expdir -o ro,sync,no_root_squash"
- run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
- run 'umount $nfsmp'
- rlPhaseEnd
- if [ -n "$ipv6s" ]; then
+ for V in $(ls_nfsvers); do
+ # export by IPv4 and try to mount it
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv4
+ run "exportfs -au && exportfs -iv $ipv4:$expdir -o ro,sync,no_root_squash"
+ run "mount -o vers=$V $ipv4:$expdir $nfsmp"
+ run "umount $nfsmp"
+ rlPhaseEnd
rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv6-x
- run 'mount -o vers=$V $ipv6:$expdir $nfsmp' 1-255
- [ $? = 0 ] && run "umount $nfsmp"
+ if [ -n "$ipv6s" ]; then
+ run "mount -o vers=$V $ipv6:$expdir $nfsmp" 1-255
+ [ $? = 0 ] && run "umount $nfsmp"
+ fi
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-host-bz876847
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "umount $nfsmp"
rlPhaseEnd
- fi
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-host
- run 'mount -o vers=$V $host:$expdir $nfsmp'
- run 'umount $nfsmp'
- rlPhaseEnd
- if [ -n "$ipv6s" ]; then
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv6
- run "exportfs -au && exportfs -iv $ipv6:$expdir -o ro,sync,no_root_squash"
- run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
- run 'umount $nfsmp'
+ if [ -n "$ipv6s" ]; then
+ # export by IPv6 and try to mount it
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv6
+ run "exportfs -au && exportfs -iv $ipv6:$expdir -o ro,sync,no_root_squash"
+ run "mount -o vers=$V $ipv6:$expdir $nfsmp"
+ run "umount $nfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv4-x
+ run "mount -o vers=$V $ipv4:$expdir $nfsmp" 1-255
+ [ $? = 0 ] && run "umount $nfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-host
+ run "dig -t aaaa $HOSTNAME +short" 0 "To get the IPv6 address"
+ if [ -n "$ipv6s" ]; then
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "umount $nfsmp"
+ fi
+ rlPhaseEnd
+ fi
+
+ # export by hostname and try to mount it
+ rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-host
+ run "exportfs -au && exportfs -iv $host:$expdir -o ro,sync,no_root_squash"
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "umount $nfsmp"
rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv4-x
- run 'mount -o vers=$V $ipv4:$expdir $nfsmp' 1-255
- [ $? = 0 ] && run "umount $nfsmp"
+ rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv4
+ run "mount -o vers=$V $ipv4:$expdir $nfsmp"
+ run "umount $nfsmp"
rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-host
- if [ -n "$(dig -t aaaa $HOSTNAME +short)" ]; then
- run 'mount -o vers=$V $host:$expdir $nfsmp'
- run 'umount $nfsmp'
+ rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv6
+ run "dig -t aaaa $HOSTNAME +short" 0 "To get the IPv6 address"
+ if [ -n "$ipv6s" ]; then
+ run "mount -o vers=$V $ipv6:$expdir $nfsmp"
+ run "umount $nfsmp"
fi
rlPhaseEnd
- fi
- rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-host
- run "exportfs -au && exportfs -iv $host:$expdir -o ro,sync,no_root_squash"
- run 'mount -o vers=$V $host:$expdir $nfsmp'
- run 'umount $nfsmp'
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv4
- run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
- run 'umount $nfsmp'
- rlPhaseEnd
- if [ -n "$ipv6s" ]; then
- rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv6
- if [ -n "$(dig -t aaaa $HOSTNAME +short)" ]; then
- run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
- run 'umount $nfsmp'
+ # export sub-directory by IPv4 and try to mount it
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv4
+ run "echo '$expdir *(ro,sync,no_root_squash)' >/etc/exports"
+ run "echo '$subexpdir $ipv4(ro,sync,no_root_squash)' >>/etc/exports"
+ which systemctl >/dev/null 2>&1 && run "systemctl reset-failed"
+ run "service_nfs restart"
+ run "showmount -e" -
+ run "mount -o vers=$V $ipv4:$expdir $nfsmp"
+ run "mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv6-x-bz1198900
+ if [ -n "$ipv6s" ]; then
+ run "mount -o vers=$V $ipv6:$expdir $nfsmp"
+ run "mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp" 1-255 "bz1198900 should not mount sub-directory with different ip"
+ [ $? = 0 ] && run "umount $tmpnfsmp"
+ run "umount $nfsmp"
fi
rlPhaseEnd
- fi
-
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv4
- run 'echo "$expdir *(ro,sync,no_root_squash)" >/etc/exports'
- run 'echo "$subexpdir $ipv4(ro,sync,no_root_squash)" >>/etc/exports'
- run 'service_nfs restart'
- #avoid issues restarting the server too quickly
- sleep 10
- run 'showmount -e' -
- run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
- run 'mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
- rlPhaseEnd
- if [ -n "$ipv6s" ]; then
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv6-x
- run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
- run 'mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp' 1-255 "should not mount sub-directory with different ip"
- [ $? = 0 ] && run "umount $tmpnfsmp"
- run "umount $nfsmp"
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-host
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "mount -o vers=$V $host:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
rlPhaseEnd
- fi
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-host
- run 'mount -o vers=$V $host:$expdir $nfsmp'
- run 'mount -o vers=$V $host:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
- rlPhaseEnd
- if [ -n "$ipv6s" ]; then
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv4-x
- run 'echo "$expdir *(ro,sync,no_root_squash)" >/etc/exports'
- run 'echo "$subexpdir $ipv6s(ro,sync,no_root_squash)" >>/etc/exports'
- run 'service_nfs restart'
- #avoid issues restarting the server too quickly
- sleep 10
- run 'showmount -e' -
- run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
- run 'mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp' 1-255 "should not mount sub-directory with different ip"
- [ $? = 0 ] && run "umount $tmpnfsmp"
- run "umount $nfsmp"
+ if [ -n "$ipv6s" ]; then
+ # export sub-directory by IPv6 and try to mount it
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv4-x-bz1198900
+ run "echo '$expdir *(ro,sync,no_root_squash)' >/etc/exports"
+ run "echo '$subexpdir $ipv6s(ro,sync,no_root_squash)' >>/etc/exports"
+ which systemctl >/dev/null 2>&1 && run "systemctl reset-failed"
+ run "service_nfs restart"
+ run "showmount -e" -
+ run "mount -o vers=$V $ipv4:$expdir $nfsmp"
+ run "mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp" 1-255 "bz1198900 should not mount sub-directory with different ip"
+ [ $? = 0 ] && run "umount $tmpnfsmp"
+ run "umount $nfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv6
+ run "mount -o vers=$V $ipv6:$expdir $nfsmp"
+ run "mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
+ rlPhaseEnd
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-host
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "mount -o vers=$V $host:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
+ rlPhaseEnd
+ fi
+
+ # export sub-directory by hostname and try to mount it
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv4
+ run "echo '$expdir *(ro,sync,no_root_squash)' >/etc/exports"
+ run "echo '$subexpdir $host(ro,sync,no_root_squash)' >>/etc/exports"
+ which systemctl >/dev/null 2>&1 && run "systemctl reset-failed"
+ run "service_nfs restart"
+ run "showmount -e" -
+ run "mount -o vers=$V $ipv4:$expdir $nfsmp"
+ run "mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv6
- run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
- run 'mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv6
+ if [ -n "$ipv6s" ]; then
+ run "mount -o vers=$V $ipv6:$expdir $nfsmp"
+ run "mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
+ fi
rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-host
- run 'mount -o vers=$V $host:$expdir $nfsmp'
- run 'mount -o vers=$V $host:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-host
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "mount -o vers=$V $host:$subexpdir $tmpnfsmp"
+ run "umount $nfsmp $tmpnfsmp"
rlPhaseEnd
- fi
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv4
- run 'echo "$expdir *(ro,sync,no_root_squash)" >/etc/exports'
- run 'echo "$subexpdir $host(ro,sync,no_root_squash)" >>/etc/exports'
- run 'service_nfs restart'
- #avoid issues restarting the server too quickly
- sleep 10
- run 'showmount -e' -
- run 'mount -o vers=$V $ipv4:$expdir $nfsmp'
- run 'mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
- rlPhaseEnd
- if [ -n "$ipv6s" ]; then
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv6
- run 'mount -o vers=$V $ipv6:$expdir $nfsmp'
- run 'mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
+ rlPhaseStartTest do-Test-nfsV$V-default-option-overridden-by-client-specific-option
+ run "echo '$expdir -ro,sync *(rw,no_root_squash)' >/etc/exports"
+ run "service_nfs restart"
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "exports option should be overridden by client specific."
+ run "rm -rf $nfsmp/test*"
+ run "umount $nfsmp"
+ run "echo '$expdir -ro,sec=sys,sync *(rw,no_root_squash)' >/etc/exports" 0 "sec=sys may cause it to be failed."
+ run "exportfs -rv"
+ run "mount -o vers=$V $host:$expdir $nfsmp"
+ run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "bz1359042 exports option should be overridden by client specific."
+ run "rm -rf $nfsmp/test*"
+ run "umount $nfsmp"
rlPhaseEnd
- fi
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-host
- run 'mount -o vers=$V $host:$expdir $nfsmp'
- run 'mount -o vers=$V $host:$subexpdir $tmpnfsmp'
- run 'umount $nfsmp $tmpnfsmp'
- rlPhaseEnd
-
- rlPhaseStartTest do-Test-nfsV$V-default-option-overridden-by-client-specific-option
- run "echo '$expdir -ro,sync *(rw,no_root_squash)' >/etc/exports"
- run "service_nfs restart"
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "exports option should be overridden by client specific."
- run "rm -rf $nfsmp/test*"
- run "umount $nfsmp"
- run "echo '$expdir -ro,sec=sys,sync *(rw,no_root_squash)' >/etc/exports" 0 "sec=sys may cause it to be failed."
- run "exportfs -rv"
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "exports option should be overridden by client specific."
- run "rm -rf $nfsmp/test*"
- run "umount $nfsmp"
- rlPhaseEnd
-done
+ done
- rlPhaseStartTest do-Test-exports-options-twice
- run 'echo "/ *(sync,hide,no_wdelay)" > /etc/exports'
- run "service_nfs restart"
- #avoid issues restarting the server too quickly
- sleep 10
-
- # Count all options from list printed by exportfs -s(rhel-7) or exportfs -v(rhel-6)
- allOptions=$( (exportfs -s 2>/dev/null || exportfs -v) | sed 's/^.*(//;s/)$//;s/,/\n/g' | wc -l)
- # Count unique options from list printed by exportfs -s(rhel-7) or exportfs -v(rhel-6)
- uniqOptions=$( (exportfs -s 2>/dev/null || exportfs -v) | sed 's/^.*(//;s/)$//;s/,/\n/g' | sort | uniq | wc -l)
-
- log "{Info} exportfs -s(rhel-7) or exportfs -v(rhel-6) will print option list for each export path"
- log "{Info} All options printed by exportfs -s(rhel-7) or exportfs -v(rhel-6) (sorted):"
- run "(exportfs -s 2>/dev/null || exportfs -v) | sed 's/^.*(//;s/)$//;s/,/\n/g' | sort"
- log "{Info} For exported path '/', there are $allOptions options printed in all options list and $uniqOptions of them are unique"
- run 'test $uniqOptions -eq $allOptions' 0 "Should not output any options twice, quantity of all options should be equal to quantity of unique options"
- for opt in sync hide no_wdelay; do
- run "(exportfs -s 2>/dev/null || exportfs -v) | grep -q $opt" 0 "Option list should contain option $opt specified in /etc/exports"
- done
- rlPhaseEnd
-
- rlPhaseStartTest do-Test-server-side-using-bind-mount
+ rlPhaseStartTest do-Test-bz1479135-server-side-using-bind-mount
run "dd if=/dev/zero of=workspace.image bs=3M count=500"
run "mkfs -t ext3 -F workspace.image"
run "mkdir -p /workspace"
@@ -247,8 +229,6 @@ done
run "echo '/srv/nfs/vmcore *(rw,no_root_squash)' > /etc/exports"
run "echo '/workspace *(rw,no_root_squash)' >> /etc/exports"
run "service_nfs restart"
- #avoid issues restarting the server too quickly
- sleep 10
run "mount $host:/workspace $nfsmp"
run "ls $nfsmp/work_dir"
run "umount $nfsmp"
@@ -259,45 +239,103 @@ done
run "rm workspace.image"
rlPhaseEnd
- rlPhaseStartTest do-Test-mount-nfsv4-show-wrong-port
- run "echo '$expdir *(rw,no_root_squash)' >>/etc/exports"
- run "service_nfs restart"
- #avoid issues restarting the server too quickly
- sleep 10
- run "exportfs -v"
- run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp"
- run "mount -t nfs4 | grep $nfsmp" -
- run "mount -t nfs4 | grep $nfsmp | grep -q port=2049" 0 "Should show port=2049"
- run "umount $nfsmp"
- run "echo '[nfsd]' > /etc/nfs.conf"
- run "echo 'port=20050' >> /etc/nfs.conf"
- run "service_nfs restart"
- run "sleep 10"
- run "rpcinfo -p | grep -w nfs | grep 20050"
- run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp" -
- if [ $? -eq 0 ]; then
- run "mount -t nfs4" -
- run "mount -t nfs4 | grep -q port=20050" 0 "Should show port=20050"
- run "umount $nfsmp"
- fi
- run "mount -t nfs -o vers=4,port=0 localhost:$expdir $nfsmp" -
- if [ $? -eq 0 ]; then
- run "mount -t nfs4" -
- run "mount -t nfs4 | grep -q port=20050" 0 "Should show port=20050"
- run "umount $nfsmp"
- fi
- run "mount -t nfs -o vers=4,port=20050 localhost:$expdir $nfsmp"
- run "mount -t nfs4 | grep $nfsmp" -
- run "mount -t nfs4 | grep $nfsmp | grep -q port=20050" 0 "Should show port=20050"
- run "umount $nfsmp"
+ rlPhaseStartTest do-Test-bz1465259-mount-nfsv4-show-wrong-port
+ run "echo '$expdir *(rw,no_root_squash)' > /etc/exports"
+ run "service_nfs restart"
+ run "exportfs -v"
+ run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp"
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "cat /proc/mounts | grep $nfsmp | grep -q 'port='" 1 "Omit displaying 'port=' by default"
+ run "mount -o remount,ro $nfsmp"
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "cat /proc/mounts | grep $nfsmp | grep -q 'port='" 1 "Omit displaying 'port=' by default"
+ run "umount $nfsmp"
+ if [ -e "/etc/nfs.conf" ]; then
+ echo "[nfsd]" > /etc/nfs.conf
+ echo "port=20050" >> /etc/nfs.conf
+ run "cat /etc/nfs.conf" -
+ run "service_nfs restart"
+ run "sleep 10"
+ run "rpcinfo -p | grep -w nfs | grep 20050"
+ run "mount -t nfs4 -o port=20050 localhost:$expdir $nfsmp"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "cat /proc/mounts | grep $nfsmp | grep -q port=20050" 0 "Should show port=20050"
+ run "mount -o remount,ro $nfsmp"
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "cat /proc/mounts | grep $nfsmp | grep -q port=20050" 0 "Should show port=20050"
+ run "umount $nfsmp"
+ fi
+ log "{Info} If NFS service is not available on the specified port"
+ run "mount -t nfs4 -o port=2049 localhost:$expdir $nfsmp" 1-255
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ log "{Info} If port value is not specified"
+ if ls_nfsvers | grep -q -w 3; then
+ run "mount -t nfs -o vers=3 localhost:$expdir $nfsmp" 0 "for v2/v3 client uses port advertised by server's rpcbind service"
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp" 1-255 "for v4 client uses the standard NFS port (2049) without checking"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ log "{Info} If the specified port value is 0"
+ run "mount -t nfs -o vers=4,port=0 localhost:$expdir $nfsmp"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "cat /proc/mounts | grep $nfsmp | grep -q port=0" 0 "Should show port=0"
+ run "umount $nfsmp"
+ fi
+ run "echo '' > /etc/nfs.conf" 0 "Recovering"
+ fi
rlPhaseEnd
+ if ls_nfsvers | grep -q -w "4.0"; then
+ rlPhaseStartTest do-Test-bz1592915-sanity-check-clientaddr-during-mount
+ run "echo '$expdir *(rw,no_root_squash)' > /etc/exports"
+ run "service_nfs restart"
+ run "exportfs -v"
+ log "{Info} Mounting v4.0 by default"
+ run "mount -o vers=4,minorversion=0 localhost:$expdir $nfsmp -v"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ log "{Info} Setting 'clientaddr=' not match any local address"
+ # use normal mode (no verbose) to check the emitted warning
+ run "mount -o vers=4,minorversion=0,clientaddr=1.2.3.4 localhost:$expdir $nfsmp &> >(tee stdout.log)"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ run "cat stdout.log | grep -q '[warning].*not match any existing network addresses'" 0 "Should warn the administrators"
+ log "{Info} Specifying IPv4_ANY (0.0.0.0) signifying client does not want delegations"
+ run "mount -o vers=4,minorversion=0,clientaddr=0.0.0.0 localhost:$expdir $nfsmp -v"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ log "{Info} Specifying IPv6_ANY (::0) signifying client does not want delegations"
+ run "mount -o vers=4,minorversion=0,clientaddr=::0 localhost:$expdir $nfsmp -v"
+ if [ $? -eq 0 ]; then
+ run "cat /proc/mounts | grep $nfsmp" -
+ run "umount $nfsmp"
+ fi
+ rlPhaseEnd
+ fi
+
rlPhaseStartCleanup do-Cleanup-
- run 'rm -rf $expdir $nfsmp $subexpdir $tmpnfsmp'
+ run "rm -rf $expdir $nfsmp $subexpdir $tmpnfsmp"
rlFileRestore
run "service_nfs restart"
- #avoid issues restarting the server too quickly
- sleep 10
+ if [ -n "ORIGINAL_HOSTNAME" ]; then
+ HOSTNAME="$ORIGINAL_HOSTNAME"
+ hostnamectl set-hostname "$HOSTNAME"
+ fi
rlPhaseEnd
rlJournalEnd
#rlJournalPrintText
diff --git a/tests/exportfs/Makefile b/tests/exportfs/Makefile
new file mode 100644
index 0000000..d367651
--- /dev/null
+++ b/tests/exportfs/Makefile
@@ -0,0 +1,79 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: test for command exportfs
+# Author: Stevens Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+TENV=_env
+ifeq ($(PKG_TOP_DIR),)
+ export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ export _TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ -include $(PKG_TOP_DIR)/env.mk
+endif
+include $(TENV)
+ifeq ($(_TOP_DIR),)
+ _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
+endif
+#===============================================================================
+
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(TENV) $(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
+. /usr/share/beakerlib/beakerlib.sh; \
+. runtest.sh )
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+-include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Stevens Yin <jiyin@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: test for command exportfs" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 30m" >> $(METADATA)
+ @echo "RunFor: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: library(kernel/base)" >> $(METADATA)
+ @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+
+ rhts-lint $(METADATA)
+
diff --git a/tests/mount/Makefile b/tests/mount/Makefile
new file mode 100644
index 0000000..412b640
--- /dev/null
+++ b/tests/mount/Makefile
@@ -0,0 +1,79 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: Test for command mount.nfs{,4}
+# Author: Stevens Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+TENV=_env
+ifeq ($(PKG_TOP_DIR),)
+ export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ export _TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ -include $(PKG_TOP_DIR)/env.mk
+endif
+include $(TENV)
+ifeq ($(_TOP_DIR),)
+ _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
+endif
+#===============================================================================
+
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(TENV) $(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
+. /usr/share/beakerlib/beakerlib.sh; \
+. runtest.sh )
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+-include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Stevens Yin <jiyin@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: Test for command mount.nfs{,4}" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 30m" >> $(METADATA)
+ @echo "RunFor: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: library(kernel/base)" >> $(METADATA)
+ @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+
+ rhts-lint $(METADATA)
+
diff --git a/tests/nfs-mount-options-all/Makefile b/tests/nfs-mount-options-all/Makefile
new file mode 100644
index 0000000..afc24cc
--- /dev/null
+++ b/tests/nfs-mount-options-all/Makefile
@@ -0,0 +1,77 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: Test for nfs mount options
+# Author: Bill Peck <bpeck@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2006 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+TENV=_env
+ifeq ($(PKG_TOP_DIR),)
+ export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ export _TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ -include $(PKG_TOP_DIR)/env.mk
+endif
+include $(TENV)
+ifeq ($(_TOP_DIR),)
+ _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
+endif
+#===============================================================================
+
+
+export TESTVERSION=0.1
+
+.PHONY: all install download clean
+
+METADATA=testinfo.desc
+BUILT_FILES= # built executables should be added here
+FILES=$(TENV) $(METADATA) runtest.sh Makefile
+
+build: $(BUILT_FILES)
+ chmod a+x ./runtest.sh
+
+clean:
+ rm -f .*.swp *~ $(BUILT_FILES)
+
+run: $(FILES) build
+ ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
+. /usr/share/beakerlib/beakerlib.sh; \
+. runtest.sh )
+
+-include /usr/share/rhts/lib/rhts-make.include
+# Generate the testinfo.desc here:
+$(METADATA): Makefile
+ @touch $(METADATA)
+ @echo "Owner: Nicol TAO<ztao@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Description: nfs general mount options supported by all nfs versions" >> $(METADATA)
+ @echo "TestTime: 45m" >> $(METADATA)
+ @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
+ @echo "RunFor: nfs-utils" >> $(METADATA)
+ @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
+ @echo "Requires: library(kernel/base)" >> $(METADATA)
+ @echo "Requires: nfs-utils" >> $(METADATA)
+ @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
+ @echo "Priority: Medium" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "License: GPL" >> $(METADATA)
diff --git a/tests/systemd-nfs/Makefile b/tests/systemd-nfs/Makefile
new file mode 100644
index 0000000..111c1fc
--- /dev/null
+++ b/tests/systemd-nfs/Makefile
@@ -0,0 +1,74 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: test for: nfs
+# Author: Jianhong Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2014 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#Generate and export TEST= PACKAGE=
+TENV=_env
+ifeq ($(PKG_TOP_DIR),)
+ export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ export _TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ -include $(PKG_TOP_DIR)/env.mk
+endif
+include $(TENV)
+ifeq ($(_TOP_DIR),)
+ _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
+endif
+#===============================================================================
+export TESTVERSION=1.0
+
+BUILT_FILES=
+FILES=$(TENV) $(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
+. /usr/share/beakerlib/beakerlib.sh || exit 1; \
+. runtest.sh )
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+-include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Jianhong Yin <jiyin@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: test for: nfs" >> $(METADATA)
+ @echo "Type: regression" >> $(METADATA)
+ @echo "Type: $(PACKAGE)-level-tier1" >> $(METADATA)
+ @echo "TestTime: 30m" >> $(METADATA)
+ @echo "RunFor: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: $(PACKAGE)" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Requires: nfs-utils" >> $(METADATA)
+ @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
+ rhts-lint $(METADATA)
diff --git a/tests/systemd-nfs/runtest.sh b/tests/systemd-nfs/runtest.sh
old mode 100755
new mode 100644
index 63d8593..ec2d219
--- a/tests/systemd-nfs/runtest.sh
+++ b/tests/systemd-nfs/runtest.sh
@@ -1,40 +1,44 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
# Description: test for: nfs
# Author: Jianhong Yin <jiyin@redhat.com>
-#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc.
#
-# This program is free software: you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 2 of
-# the License, or (at your option) any later version.
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
+# PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see http://www.gnu.org/licenses/.
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh || exit 1
+# Load beakerlib you needed
+rlImport kernel/base
+envinfo
+#disable_avc_check
#===============================================================================
#signal trap
trap "cleanup" SIGINT SIGTERM SIGHUP SIGQUIT
cleanup() {
rlFileRestore
- run 'service_nfsconfig restart'
- #rm -rf $expdir $nfsmp
+ run 'service_nfs restart'
+ run 'service_nfsconfig status &>/dev/null && service_nfsconfig restart' -
+ run 'userdel -rf testuserqa' -
}
#global var define
@@ -47,135 +51,152 @@ rpm -q systemd || {
rlJournalStart
rlPhaseStartSetup do-Setup-
- # Load beakerlib you needed
- rlImport kernel/base
- envinfo
rlFileBackup /etc/exports /etc/sysconfig/nfs
run 'echo "/usr/share *(ro)" >/etc/exports'
- run 'echo "RPCNFSDARGS=8" >/etc/sysconfig/nfs' 0 "avoid invalid config file"
- run 'service_nfsconfig restart' 0 "RHEL-7.1 or later need restart nfs-config to reload /etc/sysconfig/nfs"
+ run 'echo "" > /etc/sysconfig/nfs' 0 "avoid invalid config file"
+ # If in RHEL-7.1 or later need restart nfs-config service to flush /etc/sysconfig/nfs to /run/sysconfig/nfs-utils
+ # But since RHEL-7.3, nfs-config change to be ru-run during the dependent service starting
+ run 'service_nfsconfig status &>/dev/null && service_nfsconfig restart' -
run "useradd testuserqa" -
rlPhaseEnd
rlPhaseStartTest do-Test-start
- run "service_$serv start" 0 "Service must start without problem"
- run "service_$serv status" 0 "Then Status command"
- run "service_$serv start" 0 "Already started service"
- run "service_$serv status" 0 "Again status command"
+ run "service_nfs start" 0 "Service must start without problem"
+ run "service_nfs status" 0 "Then Status command"
+ run "service_nfs start" 0 "Already started service"
+ run "service_nfs status" 0 "Again status command"
rlPhaseEnd
rlPhaseStartTest do-Test-restart
- run "service_$serv restart" 0 "Restarting of service"
- run "service_$serv status" 0 "Status command"
+ run "service_nfs restart" 0 "Restarting of service"
+ run "service_nfs status" 0 "Status command"
rlPhaseEnd
rlPhaseStartTest do-Test-stop
- run "service_$serv stop" 0 "Stopping service"
- run "service_$serv status" 3 "Status of stopped service"
- run "service_$serv stop" 0 "Stopping service again"
- run "service_$serv status" 3 "Status of stopped service"
+ run "service_nfs stop" 0 "Stopping service"
+ run "service_nfs status" 3 "Status of stopped service"
+ run "service_nfs stop" 0 "Stopping service again"
+ run "service_nfs status" 3 "Status of stopped service"
rlPhaseEnd
rlPhaseStartTest do-Test-"insufficient-rights"
- run "service_$serv restart " 0 "Starting service for restarting under nonpriv user"
- run "su testuserqa -c 'service_$serv stop'" 1,4 "Insufficient rights, stopping service under nonprivileged user must fail"
- run "su testuserqa -c 'service_$serv start'" 0,1,4 "Insufficient rights, starting service under nonprivileged user must fail or pass as already started"
- run "su testuserqa -c 'service_$serv status'" 0 "Sufficient rights, service status should be accessible to nonprivileged users"
- run "service_$serv stop" 0 "Stopping service for starting under nonpriv user"
- run "su testuserqa -c 'service_$serv start'" 1,4 "Insufficient rights, starting of stopped service under nonprivileged user must fail"
+ run "service_nfs restart " 0 "Starting service for restarting under nonpriv user"
+ run "su testuserqa -c 'service_nfs stop'" 1,4 "Insufficient rights, stopping service under nonprivileged user must fail"
+ run "su testuserqa -c 'service_nfs start'" 0,1,4 "Insufficient rights, starting service under nonprivileged user must fail or pass as already started"
+ run "su testuserqa -c 'service_nfs status'" 0 "Sufficient rights, service status should be accessible to nonprivileged users"
+ run "service_nfs stop" 0 "Stopping service for starting under nonpriv user"
+ run "su testuserqa -c 'service_nfs start'" 1,4 "Insufficient rights, starting of stopped service under nonprivileged user must fail"
rlPhaseEnd
rlPhaseStartTest do-Test-"operations"
- run "service_$serv start" 0 "Service have to implement start function"
- run 'sleep 5' 0 "sleep a while avoid the start rate limit"
- run "service_$serv restart" 0 "Service have to implement restart function"
- run "service_$serv status" 0 "Service have to implement status function"
- run 'sleep 5' 0 "sleep a while avoid the start rate limit"
- run "service_$serv condrestart" 0 "Service have to implement condrestart function"
+ run "service_nfs start" 0 "Service have to implement start function"
+ run 'sleep 5' 0 "sleep a while avoid the start rate limit, bz1160506"
+ run "service_nfs restart" 0 "Service have to implement restart function"
+ run "service_nfs status" 0 "Service have to implement status function"
+ run 'sleep 5' 0 "sleep a while avoid the start rate limit, bz1160506"
+ run "service_nfs condrestart" 0 "Service have to implement condrestart function"
[ $? != 0 ] && run "journalctl -xn" -
- run 'sleep 5' 0 "sleep a while avoid the start rate limit"
- run "service_$serv try-restart" 0 "Service have to implement try-restart function"
+ run 'sleep 5' 0 "sleep a while avoid the start rate limit, bz1160506"
+ run "service_nfs try-restart" 0 "Service have to implement try-restart function"
[ $? != 0 ] && run "journalctl -xn" -
- run "service_$serv reload" 0 "Service have to implement reload function"
+ run "service_nfs reload" 0 "Service have to implement reload function"
[ $? != 0 ] && run "journalctl -xn" -
- run "service_$serv force-reload" 0 "Service have to implement force-reload function"
+ run "service_nfs force-reload" 0 "Service have to implement force-reload function"
[ $? != 0 ] && run "journalctl -xn" -
- run "service_$serv noexistop" 2 "Testing proper return code when nonexisting function"
+ run "service_nfs noexistop" 2 "Testing proper return code when nonexisting function"
rlPhaseEnd
# Should do nothing if a service is already stopped or not running (according to manpage of systemctl)
# http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT
rlPhaseStartTest do-Test-"operations-stopped"
- run "service_$serv stop" 0 "Service have to implement stop function"
- run "service_$serv condrestart" 0 "Service have to implement condrestart function"
- run "service_$serv try-restart" 0 "Service have to implement try-restart function"
- run "service_$serv force-reload" 0 "Service have to implement force-reload function"
- run "service_$serv status" 3 "Above oprations should do nothing if service are not running"
+ run "service_nfs stop" 0 "Service have to implement stop function"
+ run "service_nfs condrestart" 0 "Service have to implement condrestart function"
+ run "service_nfs try-restart" 0 "Service have to implement try-restart function"
+ run "service_nfs force-reload" 0 "Service have to implement force-reload function"
+ run "service_nfs status" 3 "Above oprations should do nothing if service are not running"
rlPhaseEnd
rlPhaseStartTest do-Test-enable-disable-$serv
if systemctl --quiet is-enabled $serv; then
run "systemctl disable $serv" 0 "Disable service on boot"
run "systemctl is-enabled $serv" 1 "Check whether service is disabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "test `systemctl is-enabled nfs-server` = disabled"
run "systemctl enable $serv" 0 "Enable service on boot"
run "systemctl is-enabled $serv" 0 "Check whether service is enabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "test `systemctl is-enabled nfs-server` = enabled"
else
run "systemctl enable $serv" 0 "Enable service on boot"
run "systemctl is-enabled $serv" 0 "Check whether service is enabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "test `systemctl is-enabled nfs-server` = enabled"
run "systemctl disable $serv" 0 "Disable service on boot"
run "systemctl is-enabled $serv" 1 "Check whether service is disabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "test `systemctl is-enabled nfs-server` = disabled"
fi
rlPhaseEnd
- # ystemctl enable fails for symlinks in /usr/lib/systemd/system
+ # As Bug 1159308 - systemctl enable fails for symlinks in /usr/lib/systemd/system
# Use a workaround to test enable/disable with nfs-server.service
- rlPhaseStartTest do-Test-enable-disable-nfs-server
+ if [ -f /usr/lib/systemd/system/nfs.service ]; then
+ rlPhaseStartTest do-Test-enable-disable-nfs-symlinks
if systemctl --quiet is-enabled nfs-server; then
- run "systemctl disable nfs-server" 0 "Disable nfs-serverice on boot"
- run "systemctl is-enabled nfs-server" 1 "Check whether nfs-serverice is disabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
- run "systemctl enable nfs-server" 0 "Enable nfs-serverice on boot"
- run "systemctl is-enabled nfs-server" 0 "Check whether nfs-serverice is enabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "systemctl disable nfs" 0 "Disable nfs on boot"
+ run "systemctl is-enabled nfs" 1 "Check whether nfs is disabled"
+ run "test `systemctl is-enabled nfs` = `systemctl is-enabled nfs-server`"
+ run "systemctl enable nfs" 0 "Enable nfs on boot"
+ run "systemctl is-enabled nfs" 0 "Check whether nfs is enabled"
+ run "test `systemctl is-enabled nfs` = `systemctl is-enabled nfs-server`"
else
- run "systemctl enable nfs-server" 0 "Enable nfs-serverice on boot"
- run "systemctl is-enabled nfs-server" 0 "Check whether nfs-serverice is enabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
- run "systemctl disable nfs-server" 0 "Disable nfs-serverice on boot"
- run "systemctl is-enabled nfs-server" 1 "Check whether nfs-serverice is disabled"
- run "test `systemctl is-enabled nfs-server` = `systemctl is-enabled nfs`"
+ run "systemctl enable nfs" 0 "Enable nfs on boot"
+ run "systemctl is-enabled nfs" 0 "Check whether nfs is enabled"
+ run "test `systemctl is-enabled nfs` = `systemctl is-enabled nfs-server`"
+ run "systemctl disable nfs" 0 "Disable nfs on boot"
+ run "systemctl is-enabled nfs" 1 "Check whether nfs is disabled"
+ run "test `systemctl is-enabled nfs` = `systemctl is-enabled nfs-server`"
fi
rlPhaseEnd
+ fi
- rlPhaseStartTest do-Test-nfsv4-only
- run 'service nfs stop'
+ rlPhaseStartTest do-Test-bz641291-nfsv4-only
+ run 'service_nfs stop'
+ run 'cp /etc/sysconfig/nfs /etc/sysconfig/nfs.backup'
# MOUNTD_NFS_V2 MOUNTD_NFS_V3 was not supported in RHEL-7.x
- run 'echo -e "RPCMOUNTDOPTS=\"-N 2 -N 3\"" >>/etc/sysconfig/nfs' 0 "enabling nfsv4 only"
- # If in RHEL-7.1 or later need restart nfs-config service to flush /etc/sysconfig/nfs to /run/sysconfig/nfs-utils
- # But since RHEL-7.3, nfs-config change to be ru-run during the dependent service starting
+ run 'echo "RPCMOUNTDOPTS=\"-N 2 -N 3\"" > /etc/sysconfig/nfs' 0 "disabling mountd v2/v3"
run 'service_nfsconfig status &>/dev/null && service_nfsconfig restart' -
- run 'cat /run/sysconfig/nfs-utils | grep RPCMOUNTDARGS | grep "\""' 0 "quote variable in /run/sysconfig/nfs-utils"
run 'sleep 5' 0 "sleep a while avoid service script bug"
run 'service_nfs start'
+ [ -f /run/sysconfig/nfs-utils ] && \
+ run 'cat /run/sysconfig/nfs-utils | grep RPCMOUNTDARGS | grep "\""' 0 "bz1175160 quote variable in /run/sysconfig/nfs-utils"
run 'rpcinfo -s | grep -w mountd' 1 "if nfsv4 only, no mountd info in rpcinfo"
- rlFileRestore /etc/sysconfig/nfs
- run 'service_nfsconfig restart'
+ # we allow running V4-only nfsd without rpcbind
+ log "{Info} bz1433390 nfsd startup won't delay in absence of rpcbind"
+ run 'echo "RPCNFSDARGS=\"-N 2 -N 3\"" >>/etc/sysconfig/nfs' 0 "disabling nfsd v2/v3"
+ run 'service_nfsconfig status &>/dev/null && service_nfsconfig restart' -
+ run 'service_nfs restart'
+ [ -f /run/sysconfig/nfs-utils ] && \
+ run 'cat /run/sysconfig/nfs-utils | grep RPCNFSDARGS' -
+ run 'rpcinfo -s | grep -w nfs'
+ run 'service_nfs stop'
+ run 'service rpcbind stop'
+ run 'systemctl mask rpcbind' 0 "Mask systemd service rpcbind.service"
+ run 'timeLimitRun 10 service_nfs start' 0 "nfs should come up successfully without rpcbind"
+ run 'service_nfs status'
+ run 'systemctl unmask rpcbind'
+ run 'timeLimitRun 10 service_nfs stop'
+ run 'mv /etc/sysconfig/nfs.backup /etc/sysconfig/nfs'
+ run 'service_nfsconfig status &>/dev/null && service_nfsconfig restart' -
rlPhaseEnd
+ # Accoring to https://bugzilla.redhat.com/show_bug.cgi?id=1126073#c29
# Since nfs-service no longer starts the daemons in question. They are now split
# into their own services (nfs-mountd.service, rpc-statd.service, nfs-idmapd.service).
# Then `systemctl status nfs-server.service` cannot accurately reflect the
# state of the combination of daemons that are needed for a working NFS server.
- rlPhaseStartTest do-Test-"nfs-server-is-active-even-processes-terminated"
+ rlPhaseStartTest do-Test-"bz1126073-nfs-server-is-active-even-processes-terminated"
run 'service_nfs restart'
run 'pkill rpc.mountd' -
run 'killall -9 nfsd' -
run 'ps axf | grep -e "rpc.mountd" -e "nfsd"' -
- run 'service nfs-mountd status' 1-255
+ run 'service_nfs-mountd status' 1-255
run 'rpcinfo -t localhost 100005' 1 "pings mountd"
log '{Info} nfsserver resource agent has been updated to monitor all its daemons'
run 'service_nfs status' 1-255,0
@@ -183,7 +204,7 @@ rlJournalStart
run 'service_nfs stop'
rlPhaseEnd
- rlPhaseStartTest do-Test-"should-auto-mount-/proc/fs/nfsd"
+ rlPhaseStartTest do-Test-"bz1010634-should-auto-mount-/proc/fs/nfsd"
run 'service_nfs restart'
run 'service_nfs stop'
run 'umount /proc/fs/nfsd'
@@ -191,95 +212,90 @@ rlJournalStart
run 'mount -t nfsd nfsd /proc/fs/nfsd' -
rlPhaseEnd
- rlPhaseStartTest do-Test-"use-rpcbind.service-in-nfs-server.service"
+ rlPhaseStartTest do-Test-"bz1171603-use-rpcbind.service-in-nfs-server.service"
run "systemctl reset-failed" 0 "workaround for failure of starting too often"
log "{Info} Starting nfs while rpcbind is stopped"
- run "service rpcbind stop; service rpcbind stop" 0 "stop twice as workaround"
+ run "service rpcbind stop; service rpcbind stop" 0 "stop twice as workaround for bug 1257129"
run "service rpcbind status" 3 "rpcbind.service should be stopped"
- run "service nfs restart"
- run "service nfs status" 0 "should start nfs successfully"
+ run "service_nfs restart"
+ run "service_nfs status" 0 "should start nfs successfully"
run "service rpcbind status" 0 "starting nfs should bring rpcbind up"
log "{Info} Starting nfs while rpcbind is active"
run "service rpcbind start"
run "service rpcbind status" 0 "rpcbind should be active"
- run "service nfs restart"
- run "service nfs status" 0 "should start nfs successfully"
+ run "service_nfs restart"
+ run "service_nfs status" 0 "should start nfs successfully"
run "service rpcbind status" 0 "starting nfs should keep rpcbind up"
log "{Info} Stopping nfs while rpcbind is active"
run "service rpcbind start"
run "service rpcbind status" 0 "rpcbind should be active"
- run "service nfs start; service nfs status"
- run "service nfs stop; service nfs status" 3
+ run "service_nfs start; service_nfs status"
+ run "service_nfs stop; service_nfs status" 3
run "service rpcbind status" 0 "stopping nfs should keep rpcbind up"
log "{Info} Stopping nfs while rpcbind is stopped"
- run "service nfs start" 0 "firstly start nfs since it can bring rpcbind up"
- run "service nfs status" 0 "should start nfs successfully"
- run "service rpcbind stop; service rpcbind stop" 0 "stop twice as workaround"
+ run "service_nfs start" 0 "firstly start nfs since it can bring rpcbind up"
+ run "service_nfs status" 0 "should start nfs successfully"
+ run "service rpcbind stop; service rpcbind stop" 0 "stop twice as workaround for bug 1257129"
run "service rpcbind status" 3 "rpcbind should be stopped"
- run "service nfs stop"
+ run "service_nfs stop"
# If a daemon tries to connect to port 111 systemd will start rpcbind automaticly
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1266993#c7
+ run "sleep 1" 0 "Wait a while for starting"
run "service rpcbind status" 0 "stopping nfs should bring rpcbind up"
rlPhaseEnd
- rlPhaseStartTest do-Test-"restarting rpbind also restart the the nfs server"
+ rlPhaseStartTest do-Test-bz1266993-"restarting rpbind also restart the the nfs server"
run "systemctl reset-failed" 0 "workaround for failure of starting too often"
log "{Info} Starting rpcbind while nfs is stopped"
- run "service nfs stop"
- run "service nfs status" 3 "nfs should be stopped"
+ run "service_nfs stop"
+ run "service_nfs status" 3 "nfs should be stopped"
run "service rpcbind restart"
- run "service nfs status" 3 "starting rpcbind should NOT bring nfs up"
+ run "service_nfs status" 3 "starting rpcbind should NOT bring nfs up"
log "{Info} Starting rpcbind while nfs is active"
- run "service nfs start"
- run "service nfs status" 0 "nfs should be active"
+ run "service_nfs start"
+ run "service_nfs status" 0 "nfs should be active"
run "service rpcbind restart"
- run "service nfs status" 0 "starting rpcbind should NOT interfere nfs"
+ run "service_nfs status" 0 "starting rpcbind should NOT interfere nfs"
log "{Info} Stopping rpcbind while nfs is active"
- run "service nfs start"
- run "service nfs status" 0 "nfs should be active"
+ run "service_nfs start"
+ run "service_nfs status" 0 "nfs should be active"
run "service rpcbind start; service rpcbind stop"
- run "service nfs status" 0 "stopping rpcbind should NOT bring nfs down"
+ run "service_nfs status" 0 "stopping rpcbind should NOT bring nfs down"
log "{Info} Stopping rpcbind while nfs is stopped"
- run "service nfs stop"
- run "service nfs status" 3 "nfs should be stopped"
+ run "service_nfs stop"
+ run "service_nfs status" 3 "nfs should be stopped"
run "service rpcbind start; service rpcbind stop"
- run "service nfs status" 3 "stopping rpcbind should NOT interfere nfs"
- rlPhaseEnd
-
- rlPhaseStartTest do-Test-fix-long-nfsd-startup-delay-in-absence-of-rpcbind
- run "systemctl stop rpcbind"
- run "systemctl stop nfs-server"
- run "systemctl mask rpcbind" 0 "Mask systemd service rpcbind.service"
- run "timeLimitRun 10 systemctl start nfs-server" 1-255 "Start service nfs-server without rpcbind will be failed due to systemd unit dependency"
- run "systemctl unmask rpcbind"
- run "timeLimitRun 10 systemctl stop nfs-server" -
+ run "service_nfs status" 3 "stopping rpcbind should NOT interfere nfs"
rlPhaseEnd
- rlPhaseStartTest do-Test-"nfs-utils need to cause gssproxy reload"
- run "cp /etc/gssproxy/gssproxy.conf /etc/gssproxy/gssproxy.conf.backup" 0 "backuping"
- run "echo '[gssproxy]' > /etc/gssproxy/gssproxy.conf"
- run "echo 'debug = true' >> /etc/gssproxy/gssproxy.conf"
- run "systemctl restart gssproxy"
-#FIXME when BZ#1535424 is fixed. Should not use /var/log/messages as it is not used on Fedora any more.
- run "echo '' > /var/log/messages"
- run "systemctl restart nfs"
- run "systemctl status nfs"
- run "systemctl status gssproxy"
- run "cat /var/log/messages | grep 'gssproxy:'" -
- run "cat /var/log/messages | grep -q 'gssproxy:.*loaded'" 0 "should re-reading config"
- run "mv /etc/gssproxy/gssproxy.conf.backup /etc/gssproxy/gssproxy.conf" 0 "recovering"
- run "systemctl restart gssproxy"
+ rlPhaseStartTest do-Test-"nfs-utils should reload gssproxy"
+ run "cp /etc/gssproxy/gssproxy.conf /etc/gssproxy/gssproxy.conf.backup" 0 "backuping"
+ run "echo '[gssproxy]' > /etc/gssproxy/gssproxy.conf"
+ run "echo 'debug = true' >> /etc/gssproxy/gssproxy.conf"
+ log "{Info} Check reloading when gssproxy is started"
+ run "systemctl restart gssproxy"
+ run "service_nfs restart"
+ run "systemctl status gssproxy -l"
+ run "systemctl status gssproxy -l | grep 'gssproxy\[[0-9]*\]' | grep -q 'New config loaded'" 0 "Should re-reading config"
+ run "systemctl status gssproxy -l | grep 'systemd\[[0-9]*\]' | grep -q 'Reloaded GSSAPI Proxy Daemon'" 0 "Should re-reading config"
+ log "{Info} Check reloading when gssproxy is stopped"
+ run "systemctl stop gssproxy"
+ run "service_nfs restart"
+ run "systemctl status gssproxy -l"
+ run "systemctl status gssproxy -l | grep 'gssproxy\[[0-9]*\]' | grep -q 'New config loaded'" 0 "Should re-reading config"
+ run "systemctl status gssproxy -l | grep 'systemd\[[0-9]*\]' | grep -q 'Reloaded GSSAPI Proxy Daemon'" 0 "Should re-reading config"
+ run "mv /etc/gssproxy/gssproxy.conf.backup /etc/gssproxy/gssproxy.conf" 0 "recovering"
+ run "systemctl restart gssproxy"
rlPhaseEnd
rlPhaseStartCleanup do-Cleanup-
- run "userdel -rf testuserqa" -
- rlFileRestore
- run 'timeLimitRun 10 service_nfsconfig restart'
+ cleanup
rlPhaseEnd
rlJournalEnd
diff --git a/tests/umount/Makefile b/tests/umount/Makefile
new file mode 100644
index 0000000..4e4da65
--- /dev/null
+++ b/tests/umount/Makefile
@@ -0,0 +1,79 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Description: Test for command umount.nfs{,4}
+# Author: Stevens Yin <jiyin@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+TENV=_env
+ifeq ($(PKG_TOP_DIR),)
+ export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ export _TOP_DIR := $(shell p=$$PWD; while :; do \
+ [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
+ -include $(PKG_TOP_DIR)/env.mk
+endif
+include $(TENV)
+ifeq ($(_TOP_DIR),)
+ _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
+endif
+#===============================================================================
+
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(TENV) $(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
+. /usr/share/beakerlib/beakerlib.sh; \
+. runtest.sh )
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+-include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Stevens Yin <jiyin@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: Test for command umount.nfs{,4}" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 30m" >> $(METADATA)
+ @echo "RunFor: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: $(PACKAGE)" >> $(METADATA)
+ @echo "Requires: library(kernel/base)" >> $(METADATA)
+ @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+
+ rhts-lint $(METADATA)
+
From ae009836a573c8b55e55d9504bf72d63800d83e4 Mon Sep 17 00:00:00 2001
From: Bruno Goncalves <bgoncalv@redhat.com>
Date: Jan 21 2019 10:57:57 +0000
Subject: [PATCH 4/6] fix ipv6 test on export-mount-local
---
diff --git a/tests/export-mount-local/runtest.sh b/tests/export-mount-local/runtest.sh
index 60d0c90..29a351a 100755
--- a/tests/export-mount-local/runtest.sh
+++ b/tests/export-mount-local/runtest.sh
@@ -48,7 +48,8 @@ subexpdir=/exportDir-$BZ/sub
tmpnfsmp=${nfsmp}-tmp
read ipv4 _nil <<<$(getDefaultIp)
-read ipv6s _nil <<<$(getDefaultIp 6)
+#read ipv6s _nil <<<$(getDefaultIp 6)
+ipv6s=::1
ipv6="[$ipv6s]"
# in case "localhost.localdomain"
if echo "$HOSTNAME" | grep -q "localhost"; then
From 2371443256b25b8d6088788f791284caa012df11 Mon Sep 17 00:00:00 2001
From: Bruno Goncalves <bgoncalv@redhat.com>
Date: Jan 21 2019 15:26:27 +0000
Subject: [PATCH 5/6] add nic name to ipv6 addr
---
diff --git a/tests/export-mount-local/runtest.sh b/tests/export-mount-local/runtest.sh
index 29a351a..eeb5dde 100755
--- a/tests/export-mount-local/runtest.sh
+++ b/tests/export-mount-local/runtest.sh
@@ -47,9 +47,9 @@ nfsmp=/mnt/nfsmp-$BZ
subexpdir=/exportDir-$BZ/sub
tmpnfsmp=${nfsmp}-tmp
+read default_nic <<<$(getDefaultNic)
read ipv4 _nil <<<$(getDefaultIp)
-#read ipv6s _nil <<<$(getDefaultIp 6)
-ipv6s=::1
+read ipv6s _nil <<<$(getDefaultIp 6nfs)
ipv6="[$ipv6s]"
# in case "localhost.localdomain"
if echo "$HOSTNAME" | grep -q "localhost"; then
From 9ba8cf83a319c5894f342e931e94ce61a7c89b88 Mon Sep 17 00:00:00 2001
From: Bruno Goncalves <bgoncalv@redhat.com>
Date: Jan 23 2019 08:04:16 +0000
Subject: [PATCH 6/6] drop export-mount-local test case and add gating file
---
diff --git a/gating.yaml b/gating.yaml
new file mode 100644
index 0000000..6985029
--- /dev/null
+++ b/gating.yaml
@@ -0,0 +1,6 @@
+--- !Policy
+product_versions:
+ - rhel-8
+decision_context: osci_compose_gate
+rules:
+ - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
diff --git a/tests/export-mount-local/Makefile b/tests/export-mount-local/Makefile
deleted file mode 100644
index 6ddfa94..0000000
--- a/tests/export-mount-local/Makefile
+++ /dev/null
@@ -1,76 +0,0 @@
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-# Description: test for: export-mount
-# Author: Jianhong Yin <jiyin@redhat.com>
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-# Copyright (c) 2014 Red Hat, Inc.
-#
-# This program is free software: you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation, either version 2 of
-# the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see http://www.gnu.org/licenses/.
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-#Generate and export TEST= PACKAGE=
-TENV=_env
-ifeq ($(PKG_TOP_DIR),)
- export PKG_TOP_DIR := $(shell p=$$PWD; while :; do \
- [ -e $$p/env.mk -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
- export _TOP_DIR := $(shell p=$$PWD; while :; do \
- [ -d $$p/.git -o -z "$$p" ] && { echo $$p; break; }; p=$${p%/*}; done)
- -include $(PKG_TOP_DIR)/env.mk
-endif
-include $(TENV)
-ifeq ($(_TOP_DIR),)
- _TOP_DIR=/mnt/tests/$(TOPLEVEL_NAMESPACE)
-endif
-#===============================================================================
-export TESTVERSION=1.0
-
-BUILT_FILES=
-FILES=$(TENV) $(METADATA) runtest.sh Makefile PURPOSE
-
-.PHONY: all install download clean
-
-run: $(FILES) build
- ( set +o posix; [ -e /usr/bin/rhts_environment.sh ] && . /usr/bin/rhts_environment.sh; \
-. /usr/share/beakerlib/beakerlib.sh || exit 1; \
-. runtest.sh )
-
-build: $(BUILT_FILES)
- test -x runtest.sh || chmod a+x runtest.sh
-
-clean:
- rm -f *~ $(BUILT_FILES)
-
--include /usr/share/rhts/lib/rhts-make.include
-
-$(METADATA): Makefile
- @echo "Owner: Jianhong Yin <jiyin@redhat.com>" > $(METADATA)
- @echo "Name: $(TEST)" >> $(METADATA)
- @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
- @echo "Path: $(TEST_DIR)" >> $(METADATA)
- @echo "Description: test for: export-mount" >> $(METADATA)
- @echo "Type: function" >> $(METADATA)
- @echo "Type: $(PACKAGE)-level-tier1" >> $(METADATA)
- @echo "TestTime: 30m" >> $(METADATA)
- @echo "RunFor: $(PACKAGE)" >> $(METADATA)
- @echo "Requires: $(PACKAGE)" >> $(METADATA)
- @echo "Priority: Normal" >> $(METADATA)
- @echo "License: GPLv2" >> $(METADATA)
- @echo "Requires: library(kernel/base)" >> $(METADATA)
- @echo "Requires: nfs-utils" >> $(METADATA)
- @echo "Requires: bind-utils" >> $(METADATA)
- @echo "RhtsRequires: library(kernel/base)" >> $(METADATA)
- rhts-lint $(METADATA)
diff --git a/tests/export-mount-local/PURPOSE b/tests/export-mount-local/PURPOSE
deleted file mode 100644
index 556df42..0000000
--- a/tests/export-mount-local/PURPOSE
+++ /dev/null
@@ -1 +0,0 @@
-# nothing
diff --git a/tests/export-mount-local/_env b/tests/export-mount-local/_env
deleted file mode 100644
index 90b8e90..0000000
--- a/tests/export-mount-local/_env
+++ /dev/null
@@ -1,7 +0,0 @@
-export TOPLEVEL_NAMESPACE=nfs-utils
-export PKG_NAMESPACE=nfs-utils
-export RELATIVE_PATH=export-mount-local
-export PACKAGE=nfs-utils
-export PACKAGE_NAME=nfs-utils
-export PKG_LIST=nfs-utils nfs-utils-lib libnfsidmap libsss_idmap libtirpc rpcbind
-export TEST=/nfs-utils/export-mount-local
diff --git a/tests/export-mount-local/runtest.sh b/tests/export-mount-local/runtest.sh
deleted file mode 100755
index eeb5dde..0000000
--- a/tests/export-mount-local/runtest.sh
+++ /dev/null
@@ -1,343 +0,0 @@
-#!/bin/bash
-# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-# Description: test for: export-mount-local
-# Author: Jianhong Yin <jiyin@redhat.com>
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-# Copyright (c) 2014 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing
-# to use, modify, copy, or redistribute it subject to the terms
-# and conditions of the GNU General Public License version 2.
-#
-# This program is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program; if not, write to the Free
-# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-# Boston, MA 02110-1301, USA.
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
-. /usr/share/beakerlib/beakerlib.sh || exit 1
-
-# Load beakerlib you needed
-rlImport kernel/base
-envinfo
-#disable_avc_check
-
-#===============================================================================
-
-#signal trap
-trap "cleanup" SIGINT SIGTERM SIGHUP SIGQUIT
-cleanup() {
- rlFileRestore
- rm -rf $expdir $nfsmp
-}
-
-#global var define
-BZ=exp-mount-local
-expdir=/exportDir-$BZ
-nfsmp=/mnt/nfsmp-$BZ
-subexpdir=/exportDir-$BZ/sub
-tmpnfsmp=${nfsmp}-tmp
-
-read default_nic <<<$(getDefaultNic)
-read ipv4 _nil <<<$(getDefaultIp)
-read ipv6s _nil <<<$(getDefaultIp 6nfs)
-ipv6="[$ipv6s]"
-# in case "localhost.localdomain"
-if echo "$HOSTNAME" | grep -q "localhost"; then
- ORIGINAL_HOSTNAME="$HOSTNAME"
- HOSTNAME="$BZ"
- hostnamectl set-hostname "$HOSTNAME"
-fi
-host="$HOSTNAME"
-
-rlJournalStart
- rlPhaseStartSetup do-Setup-
- rlFileBackup /etc/{exports,auto.master} /etc/sysconfig/{nfs,autofs} /etc/nfs.conf /etc/hosts
- if [ -n "ORIGINAL_HOSTNAME" ]; then
- run "echo '$ipv4 $host' >> /etc/hosts"
- run "echo '$ipv6s $host' >> /etc/hosts"
- run "cat /etc/hosts" -
- fi
- run "rm -rf $expdir $nfsmp && mkdir -p $expdir $nfsmp"
- run "rm -rf $subexpdir $tmpnfsmp && mkdir -p $subexpdir $tmpnfsmp"
- run "service_nfs restart"
- run "ls_nfsvers"
- rlPhaseEnd
-
- for V in $(ls_nfsvers); do
- # export by IPv4 and try to mount it
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv4
- run "exportfs -au && exportfs -iv $ipv4:$expdir -o ro,sync,no_root_squash"
- run "mount -o vers=$V $ipv4:$expdir $nfsmp"
- run "umount $nfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-ipv6-x
- if [ -n "$ipv6s" ]; then
- run "mount -o vers=$V $ipv6:$expdir $nfsmp" 1-255
- [ $? = 0 ] && run "umount $nfsmp"
- fi
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv4-mount-host-bz876847
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "umount $nfsmp"
- rlPhaseEnd
-
- if [ -n "$ipv6s" ]; then
- # export by IPv6 and try to mount it
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv6
- run "exportfs -au && exportfs -iv $ipv6:$expdir -o ro,sync,no_root_squash"
- run "mount -o vers=$V $ipv6:$expdir $nfsmp"
- run "umount $nfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-ipv4-x
- run "mount -o vers=$V $ipv4:$expdir $nfsmp" 1-255
- [ $? = 0 ] && run "umount $nfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-ipv6-mount-host
- run "dig -t aaaa $HOSTNAME +short" 0 "To get the IPv6 address"
- if [ -n "$ipv6s" ]; then
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "umount $nfsmp"
- fi
- rlPhaseEnd
- fi
-
- # export by hostname and try to mount it
- rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-host
- run "exportfs -au && exportfs -iv $host:$expdir -o ro,sync,no_root_squash"
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "umount $nfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv4
- run "mount -o vers=$V $ipv4:$expdir $nfsmp"
- run "umount $nfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-host-mount-ipv6
- run "dig -t aaaa $HOSTNAME +short" 0 "To get the IPv6 address"
- if [ -n "$ipv6s" ]; then
- run "mount -o vers=$V $ipv6:$expdir $nfsmp"
- run "umount $nfsmp"
- fi
- rlPhaseEnd
-
- # export sub-directory by IPv4 and try to mount it
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv4
- run "echo '$expdir *(ro,sync,no_root_squash)' >/etc/exports"
- run "echo '$subexpdir $ipv4(ro,sync,no_root_squash)' >>/etc/exports"
- which systemctl >/dev/null 2>&1 && run "systemctl reset-failed"
- run "service_nfs restart"
- run "showmount -e" -
- run "mount -o vers=$V $ipv4:$expdir $nfsmp"
- run "mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-ipv6-x-bz1198900
- if [ -n "$ipv6s" ]; then
- run "mount -o vers=$V $ipv6:$expdir $nfsmp"
- run "mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp" 1-255 "bz1198900 should not mount sub-directory with different ip"
- [ $? = 0 ] && run "umount $tmpnfsmp"
- run "umount $nfsmp"
- fi
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv4-mount-host
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "mount -o vers=$V $host:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- rlPhaseEnd
-
- if [ -n "$ipv6s" ]; then
- # export sub-directory by IPv6 and try to mount it
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv4-x-bz1198900
- run "echo '$expdir *(ro,sync,no_root_squash)' >/etc/exports"
- run "echo '$subexpdir $ipv6s(ro,sync,no_root_squash)' >>/etc/exports"
- which systemctl >/dev/null 2>&1 && run "systemctl reset-failed"
- run "service_nfs restart"
- run "showmount -e" -
- run "mount -o vers=$V $ipv4:$expdir $nfsmp"
- run "mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp" 1-255 "bz1198900 should not mount sub-directory with different ip"
- [ $? = 0 ] && run "umount $tmpnfsmp"
- run "umount $nfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-ipv6
- run "mount -o vers=$V $ipv6:$expdir $nfsmp"
- run "mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-ipv6-mount-host
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "mount -o vers=$V $host:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- rlPhaseEnd
- fi
-
- # export sub-directory by hostname and try to mount it
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv4
- run "echo '$expdir *(ro,sync,no_root_squash)' >/etc/exports"
- run "echo '$subexpdir $host(ro,sync,no_root_squash)' >>/etc/exports"
- which systemctl >/dev/null 2>&1 && run "systemctl reset-failed"
- run "service_nfs restart"
- run "showmount -e" -
- run "mount -o vers=$V $ipv4:$expdir $nfsmp"
- run "mount -o vers=$V $ipv4:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-ipv6
- if [ -n "$ipv6s" ]; then
- run "mount -o vers=$V $ipv6:$expdir $nfsmp"
- run "mount -o vers=$V $ipv6:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- fi
- rlPhaseEnd
- rlPhaseStartTest do-Test-nfsV$V-exp-sub-host-mount-host
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "mount -o vers=$V $host:$subexpdir $tmpnfsmp"
- run "umount $nfsmp $tmpnfsmp"
- rlPhaseEnd
-
- rlPhaseStartTest do-Test-nfsV$V-default-option-overridden-by-client-specific-option
- run "echo '$expdir -ro,sync *(rw,no_root_squash)' >/etc/exports"
- run "service_nfs restart"
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "exports option should be overridden by client specific."
- run "rm -rf $nfsmp/test*"
- run "umount $nfsmp"
- run "echo '$expdir -ro,sec=sys,sync *(rw,no_root_squash)' >/etc/exports" 0 "sec=sys may cause it to be failed."
- run "exportfs -rv"
- run "mount -o vers=$V $host:$expdir $nfsmp"
- run "touch $nfsmp/testfile && mkdir $nfsmp/testdir" 0 "bz1359042 exports option should be overridden by client specific."
- run "rm -rf $nfsmp/test*"
- run "umount $nfsmp"
- rlPhaseEnd
- done
-
- rlPhaseStartTest do-Test-bz1479135-server-side-using-bind-mount
- run "dd if=/dev/zero of=workspace.image bs=3M count=500"
- run "mkfs -t ext3 -F workspace.image"
- run "mkdir -p /workspace"
- run "mount -o loop workspace.image /workspace"
- run "mkdir -p /workspace/vmcore /srv/nfs/vmcore"
- run "touch /workspace/work_dir /workspace/vmcore/vmcore_dir"
- run "mount --bind /workspace/vmcore /srv/nfs/vmcore"
- run "echo '/srv/nfs/vmcore *(rw,no_root_squash)' > /etc/exports"
- run "echo '/workspace *(rw,no_root_squash)' >> /etc/exports"
- run "service_nfs restart"
- run "mount $host:/workspace $nfsmp"
- run "ls $nfsmp/work_dir"
- run "umount $nfsmp"
- run "exportfs -au" && run "service_nfs stop"
- run "umount /srv/nfs/vmcore"
- run "umount /workspace"
- run "rm -rf /workspace /srv/nfs/vmcore"
- run "rm workspace.image"
- rlPhaseEnd
-
- rlPhaseStartTest do-Test-bz1465259-mount-nfsv4-show-wrong-port
- run "echo '$expdir *(rw,no_root_squash)' > /etc/exports"
- run "service_nfs restart"
- run "exportfs -v"
- run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp"
- run "cat /proc/mounts | grep $nfsmp" -
- run "cat /proc/mounts | grep $nfsmp | grep -q 'port='" 1 "Omit displaying 'port=' by default"
- run "mount -o remount,ro $nfsmp"
- run "cat /proc/mounts | grep $nfsmp" -
- run "cat /proc/mounts | grep $nfsmp | grep -q 'port='" 1 "Omit displaying 'port=' by default"
- run "umount $nfsmp"
- if [ -e "/etc/nfs.conf" ]; then
- echo "[nfsd]" > /etc/nfs.conf
- echo "port=20050" >> /etc/nfs.conf
- run "cat /etc/nfs.conf" -
- run "service_nfs restart"
- run "sleep 10"
- run "rpcinfo -p | grep -w nfs | grep 20050"
- run "mount -t nfs4 -o port=20050 localhost:$expdir $nfsmp"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "cat /proc/mounts | grep $nfsmp | grep -q port=20050" 0 "Should show port=20050"
- run "mount -o remount,ro $nfsmp"
- run "cat /proc/mounts | grep $nfsmp" -
- run "cat /proc/mounts | grep $nfsmp | grep -q port=20050" 0 "Should show port=20050"
- run "umount $nfsmp"
- fi
- log "{Info} If NFS service is not available on the specified port"
- run "mount -t nfs4 -o port=2049 localhost:$expdir $nfsmp" 1-255
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- log "{Info} If port value is not specified"
- if ls_nfsvers | grep -q -w 3; then
- run "mount -t nfs -o vers=3 localhost:$expdir $nfsmp" 0 "for v2/v3 client uses port advertised by server's rpcbind service"
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- run "mount -t nfs -o vers=4 localhost:$expdir $nfsmp" 1-255 "for v4 client uses the standard NFS port (2049) without checking"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- log "{Info} If the specified port value is 0"
- run "mount -t nfs -o vers=4,port=0 localhost:$expdir $nfsmp"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "cat /proc/mounts | grep $nfsmp | grep -q port=0" 0 "Should show port=0"
- run "umount $nfsmp"
- fi
- run "echo '' > /etc/nfs.conf" 0 "Recovering"
- fi
- rlPhaseEnd
-
- if ls_nfsvers | grep -q -w "4.0"; then
- rlPhaseStartTest do-Test-bz1592915-sanity-check-clientaddr-during-mount
- run "echo '$expdir *(rw,no_root_squash)' > /etc/exports"
- run "service_nfs restart"
- run "exportfs -v"
- log "{Info} Mounting v4.0 by default"
- run "mount -o vers=4,minorversion=0 localhost:$expdir $nfsmp -v"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- log "{Info} Setting 'clientaddr=' not match any local address"
- # use normal mode (no verbose) to check the emitted warning
- run "mount -o vers=4,minorversion=0,clientaddr=1.2.3.4 localhost:$expdir $nfsmp &> >(tee stdout.log)"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- run "cat stdout.log | grep -q '[warning].*not match any existing network addresses'" 0 "Should warn the administrators"
- log "{Info} Specifying IPv4_ANY (0.0.0.0) signifying client does not want delegations"
- run "mount -o vers=4,minorversion=0,clientaddr=0.0.0.0 localhost:$expdir $nfsmp -v"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- log "{Info} Specifying IPv6_ANY (::0) signifying client does not want delegations"
- run "mount -o vers=4,minorversion=0,clientaddr=::0 localhost:$expdir $nfsmp -v"
- if [ $? -eq 0 ]; then
- run "cat /proc/mounts | grep $nfsmp" -
- run "umount $nfsmp"
- fi
- rlPhaseEnd
- fi
-
- rlPhaseStartCleanup do-Cleanup-
- run "rm -rf $expdir $nfsmp $subexpdir $tmpnfsmp"
- rlFileRestore
- run "service_nfs restart"
- if [ -n "ORIGINAL_HOSTNAME" ]; then
- HOSTNAME="$ORIGINAL_HOSTNAME"
- hostnamectl set-hostname "$HOSTNAME"
- fi
- rlPhaseEnd
-rlJournalEnd
-#rlJournalPrintText
-#enable_avc_check
diff --git a/tests/export-mount-local/subtest.yml b/tests/export-mount-local/subtest.yml
deleted file mode 100644
index 1a77920..0000000
--- a/tests/export-mount-local/subtest.yml
+++ /dev/null
@@ -1 +0,0 @@
-attr: {ssched: yes}
diff --git a/tests/tests.yml b/tests/tests.yml
index 865464b..e8d6ecb 100644
--- a/tests/tests.yml
+++ b/tests/tests.yml
@@ -8,13 +8,11 @@
- classic
tests:
- exportfs
- - export-mount-local
- mount
- nfs-mount-options-all
- systemd-nfs
- umount
required_packages:
- - bind-utils # export-mount-local needs this package
- findutils # beakerlib needs find command
- iptables # nfs-mount-options-all needs this package
- nfs-utils