#4 Add CI tests using the standard test interface
Opened 2 years ago by sturivny. Modified 2 years ago
git://fedorapeople.org/~sturivny/nfs-utils add-tests  into  master

Add CI tests using the standard test interface
Serhii Turivnyi • a year ago  
tests/MIGRATED
file added
+1

@@ -0,0 +1,1 @@

+ README.rst 

\ No newline at end of file

tests/README.rst
file added
+1

@@ -0,0 +1,1 @@

+ Test has been migrated to dist-git https://src.fedoraproject.org/rpms/nfs-utils/pull-request/1

tests/export-mount-local/PURPOSE
file added
+1

@@ -0,0 +1,1 @@

+ # nothing

tests/export-mount-local/_env
file added
+7

@@ -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

tests/export-mount-local/runtest.sh
file added
+304

@@ -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

tests/export-mount-local/subtest.yml
file added
+1

@@ -0,0 +1,1 @@

+ attr: {ssched: yes}

tests/exportfs/PURPOSE
file added
+2

@@ -0,0 +1,2 @@

+ Description: test for command exportfs

+ Author: Stevens Yin <jiyin@redhat.com>

tests/exportfs/_env
file added
+7

@@ -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

tests/exportfs/runtest.sh
file added
+313

@@ -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

+ 

tests/mount/PURPOSE
file added
+2

@@ -0,0 +1,2 @@

+ Description: Test for command mount.nfs{,4}

+ Author: Stevens Yin <jiyin@redhat.com>

tests/mount/_env
file added
+7

@@ -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

tests/mount/runtest.sh
file added
+113

@@ -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

+ 

tests/nfs-mount-options-all/PURPOSE
file added
+3

@@ -0,0 +1,3 @@

+ Description:

+ 	Test nfs general mount options supported by all nfs versions.

+ 	Especially test it within specific scenarioes.

tests/nfs-mount-options-all/_env
file added
+7

@@ -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

tests/nfs-mount-options-all/runtest.sh
file added
+347

@@ -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

+ 

tests/systemd-nfs/PURPOSE
file added
+1

@@ -0,0 +1,1 @@

+ # nothing

tests/systemd-nfs/_env
file added
+7

@@ -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

tests/systemd-nfs/runtest.sh
file added
+287

@@ -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

tests/systemd-nfs/subtest.yml
file added
+2

@@ -0,0 +1,2 @@

+ attr: {ssched: yes.dangerous}

+ attr: {ssched: yes.dangerous}, setup: [--kernel-options=ipv6.disable=1]

tests/tests.yml
file added
+20