Skip to contentSkip to conversation

nfs_lib.sh: Add nfs_get_remote_path()

PATCH Superseded Martin Doucha 2 participants 4 messages Nov 18, 2021 – Nov 23, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 nfs_lib.sh: Add nfs_get_remote_path()

Sometimes it's necessary to manipulate remote NFS directory directly e.g. to simulate external server activity. nfs_get_remote_path() will print the remote path so that it can then be used by tst_rhost_run().

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
testcases/network/nfs/nfs_stress/nfs_lib.sh +13 -0
index 206f11fdd..790655643 100644
@@ -52,6 +52,19 @@ get_socket_type()
 	done
 }
 
+nfs_get_remote_path()
+{
+	local v
+	local type=$(get_socket_type ${2:-0})
+
+	for v in $VERSION; do
+		break;
+	done
+
+	v=${1:-$v}
+	echo "$TST_TMPDIR/$v/$type"
+}
+
 nfs_server_udp_enabled()
 {
 	local config f
Signature · 5 lines
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 2/3 nfs_lib.sh: Add support for test-specific parameters

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +3 -1
index 790655643..b01215136 100644
@@ -19,10 +19,12 @@ nfs_parse_args()
 	case "$1" in
 	v) VERSION="$(echo $2 | tr ',' ' ')";;
 	t) SOCKET_TYPE="$(echo $2 | tr ',' ' ')";;
+	*) [ "$NFS_PARSE_ARGS_CALLER" ] && $NFS_PARSE_ARGS_CALLER "$@";;
 	esac
 }
 
-TST_OPTS="v:t:"
+NFS_PARSE_ARGS_CALLER="$TST_PARSE_ARGS"
+TST_OPTS="v:t:$TST_OPTS"
 TST_PARSE_ARGS=nfs_parse_args
 TST_USAGE=nfs_usage
 TST_NEEDS_TMPDIR=1
Signature · 5 lines
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

PATCH 3/3 Add test for NFS directory listing regression

In reply to Martin Doucha
---
 runtest/net.nfs                           | 11 +++++
 testcases/network/nfs/nfs_stress/Makefile |  3 +-
 testcases/network/nfs/nfs_stress/nfs07.sh | 56 +++++++++++++++++++++++
 3 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100755 testcases/network/nfs/nfs_stress/nfs07.sh
runtest/net.nfs +11 -0
index 3df35809a..042c14ce4 100644
@@ -61,6 +61,17 @@ nfs01_06  nfs06 -v "3,3,3,4,4,4" -t "udp,udp,tcp,tcp,tcp,tcp"
 nfs02_06 nfs06 -v "3,4,4.1,4.2,4.2,4.2" -t "udp,tcp,tcp,tcp,tcp,tcp"
 nfs03_ipv6_06 nfs06 -6 -v "4,4.1,4.1,4.2,4.2,4.2" -t "tcp,tcp,tcp,tcp,tcp,tcp"
 
+nfs3_07 nfs07.sh -v 3 -t udp
+nfs3t_07 nfs07.sh -v 3 -t tcp
+nfs4_07 nfs07.sh -v 4 -t tcp
+nfs41_07 nfs07.sh -v 4.1 -t tcp
+nfs42_07 nfs07.sh -v 4.2 -t tcp
+nfs3_ipv6_07 nfs07.sh -6 -v 3 -t udp
+nfs3t_ipv6_07 nfs07.sh -6 -v 3 -t tcp
+nfs4_ipv6_07 nfs07.sh -6 -v 4 -t tcp
+nfs41_ipv6_07 nfs07.sh -6 -v 4.1 -t tcp
+nfs42_ipv6_07 nfs07.sh -6 -v 4.2 -t tcp
+
 nfslock3_01 nfslock01 -v 3 -t udp
 nfslock3t_01 nfslock01 -v 3 -t tcp
 nfslock4_01 nfslock01 -v 4 -t tcp
testcases/network/nfs/nfs_stress/Makefile +2 -1
index 856008ce2..0b7408e29 100644
@@ -15,6 +15,7 @@ INSTALL_TARGETS		:= nfs_lib.sh \
 			   nfs03 \
 			   nfs04 \
 			   nfs05 \
-			   nfs06
+			   nfs06 \
+			   nfs07.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/nfs/nfs_stress/nfs07.sh new file +56 -0

56 lines not on this page · raw message

Signature · 5 lines
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 3/3] Add test for NFS directory listing regression

Hi Martin,

Cc: Alexey
...

testcases/network/nfs/nfs_stress/Makefile INSTALL_TARGETS := nfs_lib.sh \ · line 19

Quoted 8 lines

+++ b/testcases/network/nfs/nfs_stress/Makefile

testcases/network/nfs/nfs_stress/Makefile +2 -1
@@ -15,6 +15,7 @@ INSTALL_TARGETS		:= nfs_lib.sh \
 			   nfs03 \
 			   nfs04 \
 			   nfs05 \
-			   nfs06
+			   nfs06 \
+			   nfs07.sh

+ 1 for .sh name, we should later add it to the rest of NFS shell scripts.

Quoted 16 lines
testcases/network/nfs/nfs_stress/Makefile +0 -0
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/nfs/nfs_stress/nfs07.sh new file +9 -0
new file mode 100755
index 000000000..d8e482751
@@ -0,0 +1,56 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 SUSE LLC <[email protected]>
+#
+#  DESCRIPTION: Create a large number of files and directories on NFS volume.
+#  Then check whether they can be listed via NFS.
+
+FILE_COUNT=5000
+

testcases/network/nfs/nfs_stress/nfs07.sh line 19

Quoted 10 lines
testcases/network/nfs/nfs_stress/nfs07.sh new file +10 -0
+TST_OPTS="n:"
+TST_PARSE_ARGS=do_parse_args
+TST_TESTFUNC="do_test"
+TST_SETUP="do_setup"
+
+do_parse_args()
+{
+	case "$1" in
+	n) FILE_COUNT="$2";;
+	esac

nit: nfs07.sh -h does not list this, would you care to add TST_USAGE?

testcases/network/nfs/nfs_stress/nfs07.sh line 30

Quoted 11 lines
testcases/network/nfs/nfs_stress/nfs07.sh new file +11 -0
+}
+
+. nfs_lib.sh
+
+do_setup()
+{
+	nfs_setup
+
+	local rpath=$(nfs_get_remote_path)
+	tst_rhost_run -s -c "touch $rpath/file{1..$FILE_COUNT}"
+	tst_rhost_run -s -c "mkdir $rpath/dir{1..$FILE_COUNT}"

Unfortunately {1..$FILE_COUNT} is bashism (not work at least on dash). Could you please rewrite it to using for cycle and seq?
It might be reasonably slower on bash, but working everywhere.

The rest LGTM, good idea to add this test.

Kind regards,
Petr

Quoted 26 lines
testcases/network/nfs/nfs_stress/nfs07.sh new file +26 -0
+}
+
+do_test()
+{
+	local count
+
+	# Pass the list of files through `sort -u` in case `ls` doesn't fitler
+	# out potential duplicate filenames returned by buggy NFS
+	count=`ls | grep '^file' | sort -u | wc -l`
+
+	if [ $count -ne $FILE_COUNT ]; then
+		tst_res TFAIL "Listing files failed: $count != $FILE_COUNT"
+		return
+	fi
+
+	count=`ls | grep '^dir' | sort -u | wc -l`
+
+	if [ $count -ne $FILE_COUNT ]; then
+		tst_res TFAIL "Listing dirs failed: $count != $FILE_COUNT"
+		return
+	fi
+
+	tst_res TPASS "All files and directories were correctly listed"
+}
+
+tst_run
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp