Skip to contentSkip to conversation

network/nfs_lib: add support for multiple mounts

PATCH New Alexey Kodanev 2 participants 3 messages Aug 4, 2016 – Sep 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 network/nfs_lib: add support for multiple mounts

Keep previous behaviour as well as adding an option to create multiple NFS mounts (the same or different), e.g.:

nfs_test.sh -v "3 4.1 4.1 4.2" -t "udp tcp tcp tcp"

NFS server exports:
* /3/udp
* /4.1/tcp
* /4.2/tcp

NFS client mounts:
* /3/0
* /4.1/1
* /4.1/2
* /4.2/3

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh |   95 +++++++++++++++++++--------
 1 files changed, 67 insertions(+), 28 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +67 -28
index aca150d..eef387f 100644
@@ -39,10 +39,21 @@ while getopts :ht:v:6 opt; do
 	esac
 done
 
-nfs_setup()
+get_socket_type()
 {
-	SOCKET_TYPE="${SOCKET_TYPE}${TST_IPV6}"
+	local t
+	local k=0
+	for t in $SOCKET_TYPE; do
+		if [ "$k" -eq "$1" ]; then
+			echo "${t}${TST_IPV6}"
+			return
+		fi
+		k=$(( k + 1 ))
+	done
+}
 
+nfs_setup()
+{
 	tst_check_cmds mount exportfs
 
 	tst_tmpdir
@@ -52,42 +63,70 @@ nfs_setup()
 		tst_brkm TCONF "Cannot run nfs-stress test on mounted NFS"
 	fi
 
-	tst_resm TINFO "NFS_TYPE: $NFS_TYPE, NFS VERSION: $VERSION"
-	tst_resm TINFO "NFILES: $NFILES, SOCKET_TYPE: $SOCKET_TYPE"
+	local i
+	local type
+	local n=0
+	local opts
+	local local_dir
+	local remote_dir
+	local mount_dir
+	for i in $VERSION; do
+		type=$(get_socket_type $n)
+		tst_resm TINFO "setup NFSv$i, socket type $type"
 
-	if [ "$NFS_TYPE" != "nfs4" ]; then
-		OPTS=${OPTS:="-o proto=$SOCKET_TYPE,vers=$VERSION "}
-	fi
+		local_dir="$TST_TMPDIR/$i/$n"
+		remote_dir="$TST_TMPDIR/$i/$type"
 
-	tst_rhost_run -s -c "mkdir -p $TST_TMPDIR"
+		mkdir -p $local_dir
 
-	if [ $TST_IPV6 ]; then
-		REMOTE_DIR="[$(tst_ipaddr rhost)]:$TST_TMPDIR"
-	else
-		REMOTE_DIR="$(tst_ipaddr rhost):$TST_TMPDIR"
-	fi
+		tst_rhost_run -c "test -d $remote_dir"
+		if [ "$?" -ne 0  ]; then
+			tst_rhost_run -s -c "mkdir -p $remote_dir"
+			tst_rhost_run -s -c "exportfs -i -o no_root_squash,rw \
+				*:$remote_dir"
+		fi
 
-	if [ "$NFS_TYPE" = "nfs4" ]; then
-		tst_rhost_run -s -c "mkdir -p /export$TST_TMPDIR"
-		tst_rhost_run -s -c "mount --bind $TST_TMPDIR /export$TST_TMPDIR"
-		tst_rhost_run -s -c "exportfs -o no_root_squash,rw,nohide,\
-			insecure,no_subtree_check *:$TST_TMPDIR"
-	else
-		tst_rhost_run -s -c "exportfs -i -o no_root_squash,rw \
-			*:$TST_TMPDIR"
-	fi
+		opts="-o proto=$type,vers=$i"
+
+		if [ $TST_IPV6 ]; then
+			mount_dir="[$(tst_ipaddr rhost)]:$remote_dir"
+		else
+			mount_dir="$(tst_ipaddr rhost):$remote_dir"
+		fi
 
-	tst_resm TINFO "Mounting NFS '$REMOTE_DIR' with options '$OPTS'"
-	ROD mount -t $NFS_TYPE $OPTS $REMOTE_DIR $TST_TMPDIR
-	cd $TST_TMPDIR
+
+		tst_resm TINFO "Mounting NFS '$mount_dir'"
+		tst_resm TINFO "to '$local_dir' with options '$opts'"
+
+		ROD mount -t nfs $opts $mount_dir $local_dir
+
+		n=$(( n + 1 ))
+	done
+
+	if [ "$n" -eq 1 ]; then
+		cd ${VERSION}/0
+	fi
 }
 
 nfs_cleanup()
 {
 	tst_resm TINFO "Cleaning up testcase"
 	cd $LTPROOT
-	grep -q "$TST_TMPDIR" /proc/mounts && umount $TST_TMPDIR
 
-	tst_rhost_run -c "exportfs -u *:$TST_TMPDIR"
-	tst_rhost_run -c "rm -rf $TST_TMPDIR"
+	local i
+	local n=0
+	local type
+	local local_dir
+	local remote_dir
+	for i in $VERSION; do
+		type=$(get_socket_type $n)
+
+		local_dir="$TST_TMPDIR/$i/$n"
+		remote_dir="$TST_TMPDIR/$i/$type"
+
+		grep -q "$local_dir" /proc/mounts && umount $local_dir
+		tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
+		tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
+		n=$(( n + 1 ))
+	done
 }
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/2 network/nfs06: rewrite the test and change test-cases

Changes:
* instead of NFSv2 & NFSv3 test runs NFSv3, 4, 4.1 & 4.2.
* remove test duration, fsstress processes are running with '1 loop' parameter. After a process completes, test will check its status.
* sar statistic was removed for now. Test didn't handle it and just saved it to a file.
* add '-c' option, which prevents fsstress to cleanup its files as there can be multiple processes running and using the same files.

---
 runtest/net.nfs                        |    4 +
 testcases/network/nfs/nfs_stress/nfs06 |  168 +++++++++++---------------------
 2 files changed, 61 insertions(+), 111 deletions(-)
runtest/net.nfs +4 -0
index 9898f1b..0bbe7c3 100644
@@ -47,6 +47,10 @@ nfs4_ipv6_05 nfs05 -6 -v 4 -t tcp
 nfs41_ipv6_05 nfs05 -6 -v 4.1 -t tcp
 nfs42_ipv6_05 nfs05 -6 -v 4.2 -t tcp
 
+nfs06 nfs06 -v "3 3 3 4 4 4" -t "udp udp tcp tcp tcp tcp"
+nfs06 nfs06 -v "3 4 4.1 4.2 4.2 4.2" -t "udp tcp tcp tcp tcp tcp"
+nfs06 nfs06 -6 -v "4 4.1 4.1 4.2 4.2 4.2" -t "tcp tcp tcp tcp tcp tcp"
+
 nfslock3_01 nfslock01 -v 3 -t udp
 nfslock4_01 nfslock01 -v 4 -t tcp
 nfslock41_01 nfslock01 -v 4.1 -t tcp
testcases/network/nfs/nfs_stress/nfs06 +57 -111

174 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 network/nfs06: rewrite the test and change test-cases

Hi!

Quoted 24 lines
testcases/network/nfs/nfs_stress/nfs06 +24 -0
+TCID=nfs06
+TST_TOTAL=1
+TST_CLEANUP="nfs_cleanup"
+
+. nfs_lib.sh
+. test_net.sh
+
+do_test()
+{
+	tst_resm TINFO "Starting fsstress processes on NFS mounts"
+
+	local n=0
+	local pids
+	for i in $VERSION; do
+		fsstress -l 1 -d $TST_TMPDIR/$i/$n -n 1000 -p 50 -r -c > /dev/null &
+		pids="$pids $!"
+		n=$(( n + 1 ))
+	done
+
+	tst_resm TINFO "waiting for pids:$pids"
+	for p in $pids; do
+		wait $p
+		if [ $? -ne 0 ]; then
+			kill -9 $pids

testcases/network/nfs/nfs_stress/nfs06 line 57

Quoted 10 lines
testcases/network/nfs/nfs_stress/nfs06 +10 -0
+			tst_brkm TFAIL "fsstress process failed"
+		else
+			tst_resm TINFO "fsstress '$p' completed"
+		fi
+	done
+
+	tst_resm TPASS "all fsstress processes completed on '$n' NFS mounts"
+}
+
+tst_check_cmds sar

Do we still need this check?

Signature · 2 lines
Cyril Hrubis
[email protected]