Skip to contentSkip to conversation

nfs-utils: add testing infrastructure to nfs-utils

PATCH In review Jeff Layton 3 participants 7 messages Dec 16, 2009 – Dec 29, 2009 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover nfs-utils: add testing infrastructure to nfs-utils

This set is the same as the one I sent a month or so ago, with some small changes to account for header file changes in Chuck's tree. This patchset depends on the patches that add libnsm.a to nfs-utils.

This patchset is intended as a starting point for an automated test suite for nfs-utils. The idea here is to start simply and add a suite of tests that we can run via "make check" -- the standard automake method for running tests.

Clearly there are limits to what we can test without a multi-host test harness. My hope is that this should help keep us from breaking basic functionality by allowing us to test it in a very simple fashion. At some point in the future we should also consider how to best handle multi-machine testing, but I see that as complimenting this code rather than replacing it.

For this set, the focus is on testing statd, which is particularly susceptible to subtle breakage. Problems with it are often not noticed until lock recovery breaks, and that may greatly lag the actual breakage.

To faciitate statd testing, I've added a "statdtest" program that can serve as a synthetic statd client and an NLM simulator. It's very loosely based on the old statd simulator code. That program is dependent on some of Chuck Lever's recent statd patches -- notably the ones that break out common NSM code into libnsm.a.

For this initial drop, I'm just adding a single test that tests mon and unmon functionality with statd. Adding more tests should fairly simple to do.

Jeff Layton (2):
nfs-utils: introduce new statd testing simulator
nfs-utils: add initial tests for statd that run via "make check"

 Makefile.am                          |    2 +-
 configure.ac                         |    4 +-
 tests/Makefile.am                    |    7 +
 tests/statdtest/Makefile.am          |   45 ++++
 tests/statdtest/README               |   12 +
 tests/statdtest/nlm_sm_inter.x       |   43 +++
 tests/statdtest/statdtest.c          |  464 ++++++++++++++++++++++++++++++++++
 tests/t0001-statd-basic-mon-unmon.sh |   55 ++++
 tests/test-lib.sh                    |   41 +++
 9 files changed, 671 insertions(+), 2 deletions(-)
 create mode 100644 tests/Makefile.am
 create mode 100644 tests/statdtest/Makefile.am
 create mode 100644 tests/statdtest/README
 create mode 100644 tests/statdtest/nlm_sm_inter.x
 create mode 100644 tests/statdtest/statdtest.c
 create mode 100755 tests/t0001-statd-basic-mon-unmon.sh
 create mode 100755 tests/test-lib.sh
#1 lore raw

PATCH 1/2 nfs-utils: introduce new statd testing simulator

rpc.statd is often prone to subtle, difficult to detect breakage. When it has problems, they're often invisible and only manifest themselves as failed lock recovery.

This program is intended to function as part of a test harness for statd. It's a multicall binary that serves as a synthetic NSM client program, and a daemon that can simulate lockd for purposes of testing the NSM to NLM downcall.

A new top level "tests/" directory is also added to nfs-utils to start as a repository for automated tests of nfs-utils components.

---
 Makefile.am                    |    2 +-
 configure.ac                   |    4 +-
 tests/Makefile.am              |    5 +
 tests/statdtest/Makefile.am    |   45 ++++
 tests/statdtest/README         |   12 +
 tests/statdtest/nlm_sm_inter.x |   43 ++++
 tests/statdtest/statdtest.c    |  464 ++++++++++++++++++++++++++++++++++++++++
 7 files changed, 573 insertions(+), 2 deletions(-)
 create mode 100644 tests/Makefile.am
 create mode 100644 tests/statdtest/Makefile.am
 create mode 100644 tests/statdtest/README
 create mode 100644 tests/statdtest/nlm_sm_inter.x
 create mode 100644 tests/statdtest/statdtest.c
Makefile.am +1 -1
index b3a6e91..ae7cd16 100644
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = tools support utils linux-nfs
+SUBDIRS = tools support utils linux-nfs tests
 
 MAINTAINERCLEANFILES = Makefile.in
 
configure.ac +3 -1
index 7dffeaf..e7298c6 100644
@@ -420,6 +420,8 @@ AC_CONFIG_FILES([
 	utils/nfsd/Makefile
 	utils/nfsstat/Makefile
 	utils/showmount/Makefile
-	utils/statd/Makefile])
+	utils/statd/Makefile
+	tests/Makefile
+	tests/statdtest/Makefile])
 AC_OUTPUT
 
tests/Makefile.am new file +5 -0
new file mode 100644
index 0000000..997ac51
@@ -0,0 +1,5 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS = statdtest
+
+MAINTAINERCLEANFILES = Makefile.in
tests/statdtest/Makefile.am new file +45 -0

45 lines not on this page · raw message

tests/statdtest/README new file +12 -0
new file mode 100644
index 0000000..034fbba
@@ -0,0 +1,12 @@
+The statdtest program is a multicall binary intended for testing statd.
+It has the ability to act as a synthetic NSM client for sending
+artificial NSM calls to any host you choose.
+
+It also has an NLM simulator that implements the call that statd uses to
+communicate with lockd. The daemon simulator will start itself up,
+register as an NLM service and listen for upcalls from statd. When it
+gets one, it will log a message.
+
+Note that lockd will need to be down when using the daemon simulator, it
+also does not implement the entire NLM protocol and is only really
+useful for testing statd.
tests/statdtest/nlm_sm_inter.x new file +43 -0

43 lines not on this page · raw message

tests/statdtest/statdtest.c new file +464 -0

464 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#2 lore raw

PATCH 2/2 nfs-utils: add initial tests for statd that run via "make check"

In reply to Jeff Layton

Leverage the support that automake already has for running tests via make check. Add a simple test that just checks that the statd mon and unmon calls actually work.

Adding more tests should be a simple matter of adding new scripts exit 0 on success and non-zero on fail, and adding those to the Makefile.am.

---
 tests/Makefile.am                    |    2 +
 tests/t0001-statd-basic-mon-unmon.sh |   55 ++++++++++++++++++++++++++++++++++
 tests/test-lib.sh                    |   41 +++++++++++++++++++++++++
 3 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100755 tests/t0001-statd-basic-mon-unmon.sh
 create mode 100755 tests/test-lib.sh
tests/Makefile.am +2 -0
index 997ac51..634fb7b 100644
@@ -3,3 +3,5 @@
 SUBDIRS = statdtest
 
 MAINTAINERCLEANFILES = Makefile.in
+
+TESTS = t0001-statd-basic-mon-unmon.sh
tests/t0001-statd-basic-mon-unmon.sh new file +55 -0

55 lines not on this page · raw message

tests/test-lib.sh new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#3 lore raw

Re: [PATCH 2/2] nfs-utils: add initial tests for statd that run via "make check"

Quoted 63 lines · Jeff Layton

Leverage the support that automake already has for running tests via make check. Add a simple test that just checks that the statd mon and unmon calls actually work.

Adding more tests should be a simple matter of adding new scripts exit 0 on success and non-zero on fail, and adding those to the Makefile.am.

---
 tests/Makefile.am                    |    2 +
 tests/t0001-statd-basic-mon-unmon.sh |   55 ++++++++++++++++++++++++++++++++++
 tests/test-lib.sh                    |   41 +++++++++++++++++++++++++
 3 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100755 tests/t0001-statd-basic-mon-unmon.sh
 create mode 100755 tests/test-lib.sh
tests/Makefile.am +2 -0
index 997ac51..634fb7b 100644
@@ -3,3 +3,5 @@
 SUBDIRS = statdtest
 
 MAINTAINERCLEANFILES = Makefile.in
+
+TESTS = t0001-statd-basic-mon-unmon.sh
tests/t0001-statd-basic-mon-unmon.sh new file +30 -0
new file mode 100755
index 0000000..d5dffc5
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd
+#
+# Copyright (C) 2009  Red Hat, Jeff Layton <[email protected]>
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+. ./test-lib.sh
+
+start_statd
+if [ $? -ne 0 ]; then
+	echo "FAIL: problem starting statd"
+	exit 1
+fi
+
+COOKIE=`echo $$ | md5sum | cut -d' ' -f1`

tests/t0001-statd-basic-mon-unmon.sh line 40

Quoted 10 lines
tests/t0001-statd-basic-mon-unmon.sh new file +10 -0
+MON_NAME=`hostname`
+
+statdtest mon $MON_NAME $COOKIE
+if [ $? -ne 0 ]; then
+	echo "FAIL: mon failed"
+	kill_statd
+	exit 1
+fi
+
+grep -q $COOKIE /var/lib/nfs/statd/sm/$MON_NAME

This is a distro specific path... The default is /var/lib/nfs/sm It would be nice if somehow we could pull in the NFS_STATEDIR define from support/include/config.h file...

Quoted 47 lines
tests/t0001-statd-basic-mon-unmon.sh new file +15 -0
+if [ $? -ne 0 ]; then
+	echo "FAIL: $COOKIE not present in monitor file"
+	kill_statd
+	exit 1
+fi
+
+statdtest unmon $MON_NAME
+if [ $? -ne 0 ]; then
+	echo "FAIL: unmon failed"
+	kill_statd
+	exit 1
+fi
+
+kill_statd
+
tests/test-lib.sh new file +26 -0
new file mode 100755
index 0000000..053e46d
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# test-lib.sh -- library of functions for nfs-utils tests
+#
+# Copyright (C) 2009  Red Hat, Jeff Layton <[email protected]>
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+export PATH=$PATH:$srcdir/statdtest
+
+lockd_registered() {
+	rpcinfo -p | grep -q nlockmgr
+	return $?

tests/test-lib.sh line 36

Quoted 10 lines
tests/test-lib.sh new file +10 -0
+}
+
+start_statd() {
+	rpcinfo -u 127.0.0.1 status 1 &> /dev/null
+	if [ $? -eq 0 ]; then
+		echo "***ERROR***: statd is already running and should "
+		echo "             be down when starting this test"
+		return 1
+	fi
+	$srcdir/../utils/statd/statd --no-notify

the $srcdir variable is not define so the script fails right out of the box... So maybe something like this... Initialize srcdir=dirname $PWD
then '$srcdir/utils/statd/statd --no-notify' will work.

tests/test-lib.sh line 41

Quoted 5 lines
tests/test-lib.sh new file +5 -0
+}
+
+kill_statd() {
+	kill `cat /var/run/rpc.statd.pid`
+}

Overall I like the idea of having a test harness... but I have to wonder if we start building the harness in shell scripts if we are not limiting things right out of the box...

Maybe we should consider doing the harness in a more up to date scripting languages like perl or python or even java... Granted I'm not as familiar (or comfortable) with those languages as with shell scripting. Plus its not clear what type of dependencies that would added to the core nfs-utils code, but we should at least think about using a language that might give us more possibilities down the road... Who knowns, in the end, shell scripting might be the best way to go...

steved.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH 2/2] nfs-utils: add initial tests for statd that run via "make check"

Quoted 69 lines · On Thu, 24 Dec 2009 08:27:01 -0500 Steve Dickson <[email protected]> wrote:
Quoted 68 lines · Jeff Layton

Leverage the support that automake already has for running tests via make check. Add a simple test that just checks that the statd mon and unmon calls actually work.

Adding more tests should be a simple matter of adding new scripts exit 0 on success and non-zero on fail, and adding those to the Makefile.am.

---
 tests/Makefile.am                    |    2 +
 tests/t0001-statd-basic-mon-unmon.sh |   55 ++++++++++++++++++++++++++++++++++
 tests/test-lib.sh                    |   41 +++++++++++++++++++++++++
 3 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100755 tests/t0001-statd-basic-mon-unmon.sh
 create mode 100755 tests/test-lib.sh
tests/Makefile.am +2 -0
index 997ac51..634fb7b 100644
@@ -3,3 +3,5 @@
 SUBDIRS = statdtest
 
 MAINTAINERCLEANFILES = Makefile.in
+
+TESTS = t0001-statd-basic-mon-unmon.sh
tests/t0001-statd-basic-mon-unmon.sh new file +35 -0
new file mode 100755
index 0000000..d5dffc5
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd
+#
+# Copyright (C) 2009  Red Hat, Jeff Layton <[email protected]>
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+. ./test-lib.sh
+
+start_statd
+if [ $? -ne 0 ]; then
+	echo "FAIL: problem starting statd"
+	exit 1
+fi
+
+COOKIE=`echo $$ | md5sum | cut -d' ' -f1`
+MON_NAME=`hostname`
+
+statdtest mon $MON_NAME $COOKIE
+if [ $? -ne 0 ]; then
+	echo "FAIL: mon failed"
Quoted 9 lines

tests/t0001-statd-basic-mon-unmon.sh line 40

Quoted 5 lines
tests/t0001-statd-basic-mon-unmon.sh new file +5 -0
+	kill_statd
+	exit 1
+fi
+
+grep -q $COOKIE /var/lib/nfs/statd/sm/$MON_NAME

This is a distro specific path... The default is /var/lib/nfs/sm It would be nice if somehow we could pull in the NFS_STATEDIR define from support/include/config.h file...

Good point. I'll need to think on how we can deal with that. Maybe what I should do is add a new "statdtest" command that prints out this directory? Unless someone has a better idea, I'll respin this set with that change soon.

Quoted 53 lines
Quoted 53 lines
tests/t0001-statd-basic-mon-unmon.sh new file +15 -0
+if [ $? -ne 0 ]; then
+	echo "FAIL: $COOKIE not present in monitor file"
+	kill_statd
+	exit 1
+fi
+
+statdtest unmon $MON_NAME
+if [ $? -ne 0 ]; then
+	echo "FAIL: unmon failed"
+	kill_statd
+	exit 1
+fi
+
+kill_statd
+
tests/test-lib.sh new file +32 -0
new file mode 100755
index 0000000..053e46d
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# test-lib.sh -- library of functions for nfs-utils tests
+#
+# Copyright (C) 2009  Red Hat, Jeff Layton <[email protected]>
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+export PATH=$PATH:$srcdir/statdtest
+
+lockd_registered() {
+	rpcinfo -p | grep -q nlockmgr
+	return $?
+}
+
+start_statd() {
+	rpcinfo -u 127.0.0.1 status 1 &> /dev/null
+	if [ $? -eq 0 ]; then
+		echo "***ERROR***: statd is already running and should "
Quoted 9 lines

tests/test-lib.sh line 36

Quoted 4 lines
tests/test-lib.sh new file +4 -0
+		echo "             be down when starting this test"
+		return 1
+	fi
+	$srcdir/../utils/statd/statd --no-notify

the $srcdir variable is not define so the script fails right out of the box... So maybe something like this... Initialize srcdir=dirname $PWD
then '$srcdir/utils/statd/statd --no-notify' will work.

This script is run via "make check". Automake or autoconf (I forget which) set $srcdir. There's no need to redefine it here.

Quoted 10 lines

tests/test-lib.sh line 41

Quoted 5 lines
tests/test-lib.sh new file +5 -0
+}
+
+kill_statd() {
+	kill `cat /var/run/rpc.statd.pid`
+}

Overall I like the idea of having a test harness... but I have to wonder if we start building the harness in shell scripts if we are not limiting things right out of the box...

Quoted 9 lines

Maybe we should consider doing the harness in a more up to date scripting languages like perl or python or even java... Granted I'm not as familiar (or comfortable) with those languages as with shell scripting. Plus its not clear what type of dependencies that would added to the core nfs-utils code, but we should at least think about using a language that might give us more possibilities down the road... Who knowns, in the end, shell scripting might be the best way to go...

One of the nice things about this "test harness" is that it's pretty minimalistic. You can write tests in whatever you like as long as it can be run from the makefile. While this test is written as a shell script, the bulk of the test is a C program (statdtest.c).

I have no objection to writing tests in something else, but that does add additional dependencies. There's something to be said for not adding those unless they're really needed.

Thanks for the review so far,

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20091224192007.217a9ed5-PC62bkCOHzGdMjc06nkz3ljfA9RmPOcC@public.gmane.org

#7 lore raw

Re: [PATCH 2/2] nfs-utils: add initial tests for statd that run via "make check"

Quoted 86 lines · Jeff Layton
Quoted 73 lines · On Thu, 24 Dec 2009 08:27:01 -0500 Steve Dickson <[email protected]> wrote:
Quoted 72 lines · Jeff Layton

Leverage the support that automake already has for running tests via make check. Add a simple test that just checks that the statd mon and unmon calls actually work.

Adding more tests should be a simple matter of adding new scripts exit 0 on success and non-zero on fail, and adding those to the Makefile.am.

---
tests/Makefile.am | 2 +
tests/t0001-statd-basic-mon-unmon.sh | 55 +++++++++++++++++++++++
+++++++++++
tests/test-lib.sh | 41 +++++++++++++++++++++++
++

3 files changed, 98 insertions(+), 0 deletions(-)

create mode 100755 tests/t0001-statd-basic-mon-unmon.sh create mode 100755 tests/test-lib.sh

tests/Makefile.am +0 -0
index 997ac51..634fb7b 100644
@@ -3,3 +3,5 @@

SUBDIRS = statdtest

MAINTAINERCLEANFILES = Makefile.in

tests/Makefile.am +2 -0
+
+TESTS = t0001-statd-basic-mon-unmon.sh
tests/t0001-statd-basic-mon-unmon.sh new file +3 -0
new file mode 100755
index 0000000..d5dffc5
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# statd_basic_mon_unmon -- test basic mon/unmon functionality  

with statd

tests/t0001-statd-basic-mon-unmon.sh new file +15 -0
+#
+# Copyright (C) 2009  Red Hat, Jeff Layton <[email protected]>
+#
+# 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, write to the Free Software  

Foundation, Inc.,

tests/t0001-statd-basic-mon-unmon.sh new file +17 -0
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+. ./test-lib.sh
+
+start_statd
+if [ $? -ne 0 ]; then
+	echo "FAIL: problem starting statd"
+	exit 1
+fi
+
+COOKIE=`echo $$ | md5sum | cut -d' ' -f1`
+MON_NAME=`hostname`
+
+statdtest mon $MON_NAME $COOKIE
+if [ $? -ne 0 ]; then
+	echo "FAIL: mon failed"
Quoted 9 lines

tests/t0001-statd-basic-mon-unmon.sh line 40

Quoted 5 lines
tests/t0001-statd-basic-mon-unmon.sh new file +5 -0
+	kill_statd
+	exit 1
+fi
+
+grep -q $COOKIE /var/lib/nfs/statd/sm/$MON_NAME

This is a distro specific path... The default is /var/lib/nfs/sm It would be nice if somehow we could pull in the NFS_STATEDIR define from support/include/config.h file...

Quoted 4 lines

Good point. I'll need to think on how we can deal with that. Maybe what I should do is add a new "statdtest" command that prints out this directory? Unless someone has a better idea, I'll respin this set with that change soon.

We'd be better off, I think, if you did this test using calls to libnsm.a, rather than naked greps. You're adding yet another invisible and undocumented dependency on the "formal API" that is the state directory. I'd rather see the C API tested here, and then deprecate direct accesses over time.

Quoted 103 lines
Quoted 54 lines
Quoted 54 lines
tests/t0001-statd-basic-mon-unmon.sh new file +15 -0
+if [ $? -ne 0 ]; then
+	echo "FAIL: $COOKIE not present in monitor file"
+	kill_statd
+	exit 1
+fi
+
+statdtest unmon $MON_NAME
+if [ $? -ne 0 ]; then
+	echo "FAIL: unmon failed"
+	kill_statd
+	exit 1
+fi
+
+kill_statd
+
tests/test-lib.sh new file +18 -0
new file mode 100755
index 0000000..053e46d
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# test-lib.sh -- library of functions for nfs-utils tests
+#
+# Copyright (C) 2009  Red Hat, Jeff Layton <[email protected]>
+#
+# 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, write to the Free Software  

Foundation, Inc.,

tests/test-lib.sh new file +14 -0
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+export PATH=$PATH:$srcdir/statdtest
+
+lockd_registered() {
+	rpcinfo -p | grep -q nlockmgr
+	return $?
+}
+
+start_statd() {
+	rpcinfo -u 127.0.0.1 status 1 &> /dev/null
+	if [ $? -eq 0 ]; then
+		echo "***ERROR***: statd is already running and should "
Quoted 9 lines

tests/test-lib.sh line 36

Quoted 4 lines
tests/test-lib.sh new file +4 -0
+		echo "             be down when starting this test"
+		return 1
+	fi
+	$srcdir/../utils/statd/statd --no-notify

the $srcdir variable is not define so the script fails right out of the box... So maybe something like this... Initialize srcdir=dirname $PWD
then '$srcdir/utils/statd/statd --no-notify' will work.

This script is run via "make check". Automake or autoconf (I forget which) set $srcdir. There's no need to redefine it here.

Quoted 10 lines

tests/test-lib.sh line 41

Quoted 5 lines
tests/test-lib.sh new file +5 -0
+}
+
+kill_statd() {
+	kill `cat /var/run/rpc.statd.pid`
+}

Overall I like the idea of having a test harness... but I have to wonder if we start building the harness in shell scripts if we are not limiting things right out of the box...

Quoted 9 lines

Maybe we should consider doing the harness in a more up to date scripting languages like perl or python or even java... Granted I'm not as familiar (or comfortable) with those languages as with shell scripting. Plus its not clear what type of dependencies that would added to the core nfs-utils code, but we should at least think about using a language that might give us more possibilities down the road... Who knowns, in the end, shell scripting might be the best way to go...

One of the nice things about this "test harness" is that it's pretty minimalistic. You can write tests in whatever you like as long as it can be run from the makefile. While this test is written as a shell script, the bulk of the test is a C program (statdtest.c).

I have no objection to writing tests in something else, but that does add additional dependencies. There's something to be said for not adding those unless they're really needed.

Thanks for the review so far,

Signature · 5 lines
Jeff Layton <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#8 lore raw

Re: [PATCH 2/2] nfs-utils: add initial tests for statd that run via "make check"

Quoted 12 lines · On Tue, 29 Dec 2009 10:38:38 -0500 Chuck Lever <[email protected]> wrote:
Quoted 11 lines
Quoted 5 lines
Quoted 1 line

+grep -q $COOKIE /var/lib/nfs/statd/sm/$MON_NAME

This is a distro specific path... The default is /var/lib/nfs/sm It would be nice if somehow we could pull in the NFS_STATEDIR define from support/include/config.h file...

Good point. I'll need to think on how we can deal with that. Maybe what
I should do is add a new "statdtest" command that prints out this directory? Unless someone has a better idea, I'll respin this set with that change soon.

Quoted 6 lines

We'd be better off, I think, if you did this test using calls to libnsm.a, rather than naked greps. You're adding yet another invisible and undocumented dependency on the "formal API" that is the state directory. I'd rather see the C API tested here, and then deprecate direct accesses over time.

Ok, maybe I need to sit down and write a "statdb" utility that can read/manipulate the statd DB via the libnsm.a interfaces? That might be handy for other purposes too. I'll look at that when I get back from vacation...

Signature · 1 line
Jeff Layton <[email protected]>