Skip to contentSkip to conversation

tst_net.sh: Move check_portmap_rpcbind() + fixes

PATCH New Petr Vorel 2 participants 6 messages May 25, 2021 – May 26, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/3 tst_net.sh: Move check_portmap_rpcbind() + fixes

move from rpc_lib.sh, because it'll be used also in NFS tests.

Fixes:
* check for pgrep
* local and lowercase for variable

And remove rpc_lib.sh, as check_portmap_rpcbind() was the only function in it.

---
 testcases/lib/tst_net.sh                       | 18 +++++++++++++++++-
 testcases/network/rpc/basic_tests/Makefile     |  1 -
 .../network/rpc/basic_tests/rpc01/rpc01.sh     |  2 +-
 testcases/network/rpc/basic_tests/rpc_lib.sh   | 15 ---------------
 .../rpc/basic_tests/rpcinfo/rpcinfo01.sh       |  2 +-
 testcases/network/rpc/rpc-tirpc/rpc_test.sh    |  2 +-
 6 files changed, 20 insertions(+), 20 deletions(-)
 delete mode 100644 testcases/network/rpc/basic_tests/rpc_lib.sh
testcases/lib/tst_net.sh +17 -1
index fc5719057..d793541e2 100644
@@ -1,7 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) 2016-2019 Petr Vorel <[email protected]>
+# Copyright (c) 2016-2021 Petr Vorel <[email protected]>
 # Author: Alexey Kodanev <[email protected]>
 
 [ -n "$TST_LIB_NET_LOADED" ] && return 0
@@ -933,6 +933,22 @@ tst_default_max_pkt()
 	echo "$((mtu + mtu / 10))"
 }
 
+check_portmap_rpcbind()
+{
+	local portmapper
+
+	tst_require_cmds pgrep
+
+	if pgrep portmap > /dev/null; then
+		portmapper="portmap"
+	else
+		pgrep rpcbind > /dev/null && portmapper="rpcbind" || \
+			tst_brk TCONF "portmap or rpcbind is not running"
+	fi
+
+	tst_res TINFO "using $portmapper"
+}
+
 # Management Link
 [ -z "$RHOST" ] && TST_USE_NETNS="yes"
 export RHOST="$RHOST"
testcases/network/rpc/basic_tests/Makefile +0 -1
index 7862e41e5..66e9d5675 100644
@@ -21,7 +21,6 @@
 #
 
 top_srcdir		?= ../../../..
-INSTALL_TARGETS	:= rpc_lib.sh
 
 include $(top_srcdir)/include/mk/env_pre.mk
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
testcases/network/rpc/basic_tests/rpc01/rpc01.sh +1 -1
index 9ca5daae6..7a8ff75e6 100755
@@ -7,7 +7,7 @@ TST_TESTFUNC=do_test
 TST_SETUP=do_setup
 TST_CLEANUP=do_cleanup
 TST_NEEDS_CMDS="pkill rpcinfo"
-. rpc_lib.sh
+. tst_net.sh
 
 NUMLOOPS=${NUMLOOPS:-3}
 DATAFILES="${DATAFILES:-file.1 file.2}"
testcases/network/rpc/basic_tests/rpc_lib.sh deleted +0 -15
deleted file mode 100644
index c7c868709..000000000
@@ -1,15 +0,0 @@
-#!/bin/sh
-# Copyright (c) 2020 Petr Vorel <[email protected]>
-
-. tst_net.sh
-
-check_portmap_rpcbind()
-{
-	if pgrep portmap > /dev/null; then
-		PORTMAPPER="portmap"
-	else
-		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
-			tst_brk TCONF "portmap or rpcbind is not running"
-	fi
-	tst_res TINFO "using $PORTMAPPER"
-}
testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh +1 -1
index 811f79ef7..0a371ceac 100755
@@ -7,7 +7,7 @@ TST_TESTFUNC=do_test
 TST_SETUP=do_setup
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_CMDS="rpcinfo wc"
-. rpc_lib.sh
+. tst_net.sh
 
 do_setup()
 {
testcases/network/rpc/rpc-tirpc/rpc_test.sh +1 -1
index ffb58769d..48ed97742 100755
@@ -17,7 +17,7 @@ TST_SETUP=setup
 TST_CLEANUP=cleanup
 TST_PARSE_ARGS=rpc_parse_args
 TST_NEEDS_CMDS="pkill rpcinfo"
-. rpc_lib.sh
+. tst_net.sh
 
 usage()
 {
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/3 nfs_lib.sh: Check running rpc.mountd, rpcbind/portmap

Both are required to be running for NFS tests.

This requires to add pgrep dependency, as we don't have custom LTP C based tool for searching in processes.

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +6 -1
index 1bd057717..25fe67bda 100644
@@ -27,7 +27,7 @@ TST_PARSE_ARGS=nfs_parse_args
 TST_USAGE=nfs_usage
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_ROOT=1
-TST_NEEDS_CMDS="$TST_NEEDS_CMDS mount exportfs"
+TST_NEEDS_CMDS="$TST_NEEDS_CMDS exportfs mount pgrep"
 TST_SETUP="${TST_SETUP:-nfs_setup}"
 TST_CLEANUP="${TST_CLEANUP:-nfs_cleanup}"
 
@@ -107,6 +107,11 @@ nfs_setup()
 		tst_brk TCONF "Cannot run nfs-stress test on mounted NFS"
 	fi
 
+	pgrep rpc.mountd > /dev/null || \
+		tst_brk TCONF "rpc.mountd not running"
+
+	check_portmap_rpcbind
+
 	local i
 	local type
 	local n=0
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH 2/3 nfs_lib.sh: Check running rpc.mountd, rpcbind/portmap

Hi Alexey,

Quoted 24 lines

Both are required to be running for NFS tests.

This requires to add pgrep dependency, as we don't have custom LTP C based tool for searching in processes.

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +1 -1
index 1bd057717..25fe67bda 100644
@@ -27,7 +27,7 @@ TST_PARSE_ARGS=nfs_parse_args
 TST_USAGE=nfs_usage
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_ROOT=1
-TST_NEEDS_CMDS="$TST_NEEDS_CMDS mount exportfs"
+TST_NEEDS_CMDS="$TST_NEEDS_CMDS exportfs mount pgrep"
 TST_SETUP="${TST_SETUP:-nfs_setup}"
 TST_CLEANUP="${TST_CLEANUP:-nfs_cleanup}"
 

testcases/network/nfs/nfs_stress/nfs_lib.sh nfs_setup() · line 113

Quoted 7 lines
testcases/network/nfs/nfs_stress/nfs_lib.sh +4 -0
@@ -107,6 +107,11 @@ nfs_setup()
 		tst_brk TCONF "Cannot run nfs-stress test on mounted NFS"
 	fi
 
+	pgrep rpc.mountd > /dev/null || \
+		tst_brk TCONF "rpc.mountd not running"
+
+	check_portmap_rpcbind

I found that at least some tests (e.g. nfs01) runs with stopped rpcbind. I suppose that's because nfs-server.service is able to restart it (it's activated via socket).

Although rpc.mountd (nfs-mountd.service) is required, nfs-mountd.service is a nfs-server.service dependency (nfs-server.service:Requires=nfs-mountd.service). Thus it's probably enough to check that rpc.nfsd is running.
=> sending v2 with just single commit.

Kind regards,
Petr

author
#3 lore raw

PATCH 3/3 nfs_lib.sh: Print verbose mount info on error

In reply to Petr Vorel
---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +4 -3
index 25fe67bda..fb0f10020 100644
@@ -83,16 +83,17 @@ nfs_mount()
 		mount_dir="$(tst_ipaddr $host_type):$remote_dir"
 	fi
 
-	local mnt_cmd="mount -t nfs $opts $mount_dir $local_dir"
+	local mnt_cmd="mount -v -t nfs $opts $mount_dir $local_dir"
 
 	tst_res TINFO "Mounting NFS: $mnt_cmd"
 	if [ -n "$LTP_NETNS" ] && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then
-		tst_rhost_run -c "$mnt_cmd"
+		tst_rhost_run -c "$mnt_cmd" > mount.log
 	else
-		$mnt_cmd > /dev/null
+		$mnt_cmd > mount.log
 	fi
 
 	if [ $? -ne 0 ]; then
+		cat mount.log
 		if [ "$type" = "udp" -o "$type" = "udp6" ] && tst_kvcmp -ge 5.6; then
 			tst_brk TCONF "UDP support disabled with the kernel config NFS_DISABLE_UDP_SUPPORT?"
 		fi
Signature · 1 line
2.31.1
#4 lore raw

PATCH 3/3 nfs_lib.sh: Print verbose mount info on error

Quoted 22 lines · Petr Vorel
---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +2 -2
index 25fe67bda..fb0f10020 100644
@@ -83,16 +83,17 @@ nfs_mount()
 		mount_dir="$(tst_ipaddr $host_type):$remote_dir"
 	fi
 
-	local mnt_cmd="mount -t nfs $opts $mount_dir $local_dir"
+	local mnt_cmd="mount -v -t nfs $opts $mount_dir $local_dir"
 
 	tst_res TINFO "Mounting NFS: $mnt_cmd"
 	if [ -n "$LTP_NETNS" ] && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then
-		tst_rhost_run -c "$mnt_cmd"
+		tst_rhost_run -c "$mnt_cmd" > mount.log

testcases/network/nfs/nfs_stress/nfs_lib.sh nfs_mount() · line 99

Quoted 10 lines
testcases/network/nfs/nfs_stress/nfs_lib.sh +2 -1
 	else
-		$mnt_cmd > /dev/null
+		$mnt_cmd > mount.log
 	fi
 
 	if [ $? -ne 0 ]; then
+		cat mount.log
 		if [ "$type" = "udp" -o "$type" = "udp6" ] && tst_kvcmp -ge 5.6; then
 			tst_brk TCONF "UDP support disabled with the kernel config NFS_DISABLE_UDP_SUPPORT?"
 		fi

Thanks Petr! For the patch series:

author
#5 lore raw

PATCH 3/3 nfs_lib.sh: Print verbose mount info on error

Hi Alexey,

Quoted 3 lines

Thanks Petr! For the patch series:

Thanks a lot! Merged this commit, more info at other commits.

Kind regards,
Petr