nfs-utils: add testing infrastructure to nfs-utils (try #6)
Subsystems (3)
cover nfs-utils: add testing infrastructure to nfs-utils (try #6)
This is an updated patchset for adding test infrastructure to nfs-utils. The main differences in this patchset are:
1) some bugfixes in the statdb_dump program
2) an extra check for root privs in the t0001 test. If the caller doesn't have root privs, then the test is skipped
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 "nsm_client" 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 be fairly simple to do.
Jeff Layton (4):
nfs-utils: make private cookie to hex conversion a library routine
nfs-utils: introduce new statd testing simulator
nfs-utils: add statdb_dump utility
nfs-utils: add initial tests for statd that run via "make check"
Makefile.am | 2 +- configure.ac | 4 +- support/include/nsm.h | 2 + support/nsm/file.c | 44 +++- tests/Makefile.am | 13 + tests/nsm_client/Makefile.am | 45 ++++ tests/nsm_client/README | 12 + tests/nsm_client/nlm_sm_inter.x | 43 +++ tests/nsm_client/nsm_client.c | 465 ++++++++++++++++++++++++++++++++++ tests/statdb_dump.c | 99 +++++++ tests/t0001-statd-basic-mon-unmon.sh | 58 +++++ tests/test-lib.sh | 60 +++++ 12 files changed, 835 insertions(+), 12 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/nsm_client/Makefile.am create mode 100644 tests/nsm_client/README create mode 100644 tests/nsm_client/nlm_sm_inter.x create mode 100644 tests/nsm_client/nsm_client.c create mode 100644 tests/statdb_dump.c create mode 100755 tests/t0001-statd-basic-mon-unmon.sh create mode 100755 tests/test-lib.sh
PATCH 1/4 nfs-utils: make private cookie to hex conversion a library routine
--- support/include/nsm.h | 2 ++ support/nsm/file.c | 44 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 10 deletions(-)
support/include/nsm.h +2 -0
@@ -71,6 +71,8 @@ extern void nsm_delete_monitored_host(const char *hostname, const char *mon_name, const char *my_name);extern void nsm_delete_notified_host (const char *hostname,const char *mon_name,const char *my_name); +extern size_t nsm_priv_to_hex (const char *priv,char *buf, +const size_t buflen);/* rpc.c */
support/nsm/file.c +34 -10
62 lines not on this page · raw message
Signature · 1 line
1.6.5.2
PATCH 2/4 nfs-utils: introduce new statd testing simulator
In reply to Jeff Laytonrpc.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/nsm_client/Makefile.am | 45 ++++ tests/nsm_client/README | 12 + tests/nsm_client/nlm_sm_inter.x | 43 ++++ tests/nsm_client/nsm_client.c | 465 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 574 insertions(+), 2 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/nsm_client/Makefile.am create mode 100644 tests/nsm_client/README create mode 100644 tests/nsm_client/nlm_sm_inter.x create mode 100644 tests/nsm_client/nsm_client.c
Makefile.am +1 -1
@@ -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
@@ -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/nsm_client/Makefile]) AC_OUTPUT
tests/Makefile.am new file +5 -0
@@ -0,0 +1,5 @@ +## Process this file with automake to produce Makefile.in + +SUBDIRS = nsm_client + +MAINTAINERCLEANFILES = Makefile.in
tests/nsm_client/Makefile.am new file +45 -0
45 lines not on this page · raw message
tests/nsm_client/README new file +12 -0
@@ -0,0 +1,12 @@ +The nsm_client program is 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 "downcalls" 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's downcall.
tests/nsm_client/nlm_sm_inter.x new file +43 -0
43 lines not on this page · raw message
tests/nsm_client/nsm_client.c new file +465 -0
465 lines not on this page · raw message
Signature · 1 line
1.6.5.2
PATCH 3/4 nfs-utils: add statdb_dump utility
In reply to Jeff LaytonTo dump contents of statd's monitor DB.
--- tests/Makefile.am | 6 +++ tests/statdb_dump.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 0 deletions(-) create mode 100644 tests/statdb_dump.c
tests/Makefile.am +6 -0
@@ -1,5 +1,11 @@ ## Process this file with automake to produce Makefile.in +check_PROGRAMS = statdb_dump +statdb_dump_SOURCES = statdb_dump.c + +statdb_dump_LDADD = ../support/nfs/libnfs.a \ + ../support/nsm/libnsm.a $(LIBCAP) + SUBDIRS = nsm_client MAINTAINERCLEANFILES = Makefile.in
tests/statdb_dump.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
1.6.5.2
PATCH 4/4 nfs-utils: add initial tests for statd that run via "make check"
In reply to Jeff LaytonLeverage 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 | 58 ++++++++++++++++++++++++++++++++ tests/test-lib.sh | 60 ++++++++++++++++++++++++++++++++++ 3 files changed, 120 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
@@ -9,3 +9,5 @@ statdb_dump_LDADD = ../support/nfs/libnfs.a \ SUBDIRS = nsm_client MAINTAINERCLEANFILES = Makefile.in + +TESTS = t0001-statd-basic-mon-unmon.sh
tests/t0001-statd-basic-mon-unmon.sh new file +58 -0
58 lines not on this page · raw message
tests/test-lib.sh new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
1.6.5.2
Re: [PATCH 4/4] nfs-utils: add initial tests for statd that run via "make check"
Quoted 145 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.
Signed-off-by Jeff Layton <[email protected]>---
tests/Makefile.am | 2 +tests/t0001-statd-basic-mon-unmon.sh| 58 +++++++++++++++++++++++++
+++++++tests/test-lib.sh| 60 +++++++++++++++++++++++++
+++++++++3 files changed, 120 insertions(+), 0 deletions(-)create mode 100755
tests/t0001-statd-basic-mon-unmon.shcreate mode 100755tests/test-lib.shtests/Makefile.am +0
-0@@ -9,3 +9,5 @@ statdb_dump_LDADD = ../support/nfs/libnfs.a \SUBDIRS =
nsm_clientMAINTAINERCLEANFILES = Makefile.in
tests/Makefile.am +2
-0+ +TESTS = t0001-statd-basic-mon-unmon.shtests/t0001-statd-basic-mon-unmon.sh new file +3
-0@@ -0,0 +1,58 @@ +#!/bin/bash +# +# statd_basic_mon_unmon -- test basic mon/unmon functionality withstatd
tests/t0001-statd-basic-mon-unmon.sh new file +15
-0+# +# Copyright (C) 2010 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 SoftwareFoundation, Inc.,
tests/t0001-statd-basic-mon-unmon.sh new file +40
-0+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +. ./test-lib.sh + +# This test needs root privileges +check_root + +start_statd +if [ $? -ne 0 ]; then + echo "FAIL: problem starting statd" + exit 1 +fi + +COOKIE=`echo $$ | md5sum | cut -d' ' -f1` +MON_NAME=`hostname` + +nsm_client mon $MON_NAME $COOKIE +if [ $? -ne 0 ]; then + echo "FAIL: mon failed" + kill_statd + exit 1 +fi + +statdb_dump | grep $MON_NAME | grep -q $COOKIE +if [ $? -ne 0 ]; then + echo "FAIL: monitor DB doesn't seem to contain entry" + kill_statd + exit 1 +fi + +nsm_client 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@@ -0,0 +1,60 @@ +#!/bin/bash +# +# test-lib.sh -- library of functions for nfs-utils tests +# +# Copyright (C) 2010 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 SoftwareFoundation, Inc.,
tests/test-lib.sh new file +13
-0+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# make sure $srcdir is set and sanity check it +srcdir=${srcdir-.} +if [ ! -d ${srcdir} ]; then + echo "***ERROR***: bad installation -- \$srcdir=${srcdir}" + exit 1 +fi + +export PATH=$PATH:${srcdir}:${srcdir}/nsm_client + +# Some tests require root privileges. Check for them and skip thetest (exit 77)
tests/test-lib.sh new file +11
-0+# if the caller doesn't have them. +check_root() { + if [ $EUID -ne 0 ]; then + echo "*** Skipping this test as it requires root privs ***" + exit 77 + fi +} + +# is lockd registered as a service? +lockd_registered() { + rpcinfo -p | grep -q nlockmgr
tests/test-lib.sh line 52
Quoted 10 lines
tests/test-lib.sh new file +10
-0+ return $? +} + +# start up statd +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
Basically what this tells me is that you can't runs these tests at all if your development tree lives on an NFSv2/3 mount point.
tests/test-lib.sh
Quoted 2 lines
tests/test-lib.sh new file +2
-0+ fi + $srcdir/../utils/statd/statd --no-notify
Is --no-notify really needed? I guess that's just a safety net.
Quoted 8 lines
tests/test-lib.sh new file +6
-0+} + +# shut down statd +kill_statd() { + kill `cat /var/run/rpc.statd.pid` +}Signature · 1 line
1.6.5.2
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 4/4] nfs-utils: add initial tests for statd that run via "make check"
Quoted 4 lines · On Fri, 8 Jan 2010 11:49:16 -0500 Chuck Lever <[email protected]> wrote:
Basically what this tells me is that you can't runs these tests at all if your development tree lives on an NFSv2/3 mount point.
I don't think the test I have so far will do any fcntl locking, so that one would probably work. No guarantees on any that are added later though.
It's probably best to assume that doing so would be problematic.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ fi + $srcdir/../utils/statd/statd --no-notifyIs --no-notify really needed? I guess that's just a safety net.
Yeah. On the off chance that someone has monitored hosts in the db after shutting down statd, I don't think we want to start spraying notifications when we start the test.
Quoted 20 lines
Quoted 8 lines
tests/test-lib.sh new file +6
-0+} + +# shut down statd +kill_statd() { + kill `cat /var/run/rpc.statd.pid` +}Signature · 1 line
1.6.5.2--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com--
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 · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100108115651.7a84a3c5-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Re: [PATCH 4/4] nfs-utils: add initial tests for statd that run via "make check"
Quoted 19 lines · Jeff Layton
Quoted 4 lines · On Fri, 8 Jan 2010 11:49:16 -0500 Chuck Lever <[email protected]> wrote:
Basically what this tells me is that you can't runs these tests at all if your development tree lives on an NFSv2/3 mount point.
I don't think the test I have so far will do any fcntl locking, so that one would probably work. No guarantees on any that are added later though.
It's probably best to assume that doing so would be problematic.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ fi + $srcdir/../utils/statd/statd --no-notifyIs --no-notify really needed? I guess that's just a safety net.
Quoted 3 lines
Yeah. On the off chance that someone has monitored hosts in the db after shutting down statd, I don't think we want to start spraying notifications when we start the test.
statd/sm-notify are supposed to be smart enough to send reboot notifications once per reboot anyway. But it can't hurt to enforce it here.
Quoted 15 lines
Quoted 15 lines
Quoted 8 lines
tests/test-lib.sh new file +6
-0+} + +# shut down statd +kill_statd() { + kill `cat /var/run/rpc.statd.pid` +}Signature · 1 line
1.6.5.2--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Quoted 9 lines
Quoted 5 lines
--
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.htmlSignature · 1 line
Jeff Layton <[email protected]>
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 4/4] nfs-utils: add initial tests for statd that run via "make check"
In reply to Chuck LeverQuoted 154 lines · Chuck Lever
Quoted 151 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.
Signed-off-by Jeff Layton <[email protected]>---
tests/Makefile.am | 2 +tests/t0001-statd-basic-mon-unmon.sh| 58 +++++++++++++++++++++++++
+++++++tests/test-lib.sh| 60 +++++++++++++++++++++++++
+++++++++3 files changed, 120 insertions(+), 0 deletions(-)create mode 100755
tests/t0001-statd-basic-mon-unmon.shcreate mode 100755tests/test-lib.shtests/Makefile.am +0
-0@@ -9,3 +9,5 @@ statdb_dump_LDADD = ../support/nfs/libnfs.a \SUBDIRS =
nsm_clientMAINTAINERCLEANFILES = Makefile.in
tests/Makefile.am +2
-0+ +TESTS = t0001-statd-basic-mon-unmon.shtests/t0001- renamed from tests/t0001-statd-basic-mon-unmon.sh +0
-0
statd-basic-mon-unmon.sh
new file mode 100755
index 0000000..00127fbtests/t0001-statd-basic-mon-unmon.sh new file +3
-0@@ -0,0 +1,58 @@ +#!/bin/bash +# +# statd_basic_mon_unmon -- test basic mon/unmon functionality withstatd
tests/t0001-statd-basic-mon-unmon.sh new file +15
-0+# +# Copyright (C) 2010 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 SoftwareFoundation, Inc.,
tests/t0001-statd-basic-mon-unmon.sh new file +40
-0+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +. ./test-lib.sh + +# This test needs root privileges +check_root + +start_statd +if [ $? -ne 0 ]; then + echo "FAIL: problem starting statd" + exit 1 +fi + +COOKIE=`echo $$ | md5sum | cut -d' ' -f1` +MON_NAME=`hostname` + +nsm_client mon $MON_NAME $COOKIE +if [ $? -ne 0 ]; then + echo "FAIL: mon failed" + kill_statd + exit 1 +fi + +statdb_dump | grep $MON_NAME | grep -q $COOKIE +if [ $? -ne 0 ]; then + echo "FAIL: monitor DB doesn't seem to contain entry" + kill_statd + exit 1 +fi + +nsm_client 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@@ -0,0 +1,60 @@ +#!/bin/bash +# +# test-lib.sh -- library of functions for nfs-utils tests +# +# Copyright (C) 2010 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 SoftwareFoundation, Inc.,
tests/test-lib.sh new file +13
-0+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# make sure $srcdir is set and sanity check it +srcdir=${srcdir-.} +if [ ! -d ${srcdir} ]; then + echo "***ERROR***: bad installation -- \$srcdir=${srcdir}" + exit 1 +fi + +export PATH=$PATH:${srcdir}:${srcdir}/nsm_client + +# Some tests require root privileges. Check for them and skip thetest (exit 77)
tests/test-lib.sh new file +16
-0+# if the caller doesn't have them. +check_root() { + if [ $EUID -ne 0 ]; then + echo "*** Skipping this test as it requires root privs ***" + exit 77 + fi +} + +# is lockd registered as a service? +lockd_registered() { + rpcinfo -p | grep -q nlockmgr + return $? +} + +# start up statd +start_statd() {
Quoted 8 lines
tests/test-lib.sh line 52
Quoted 5 lines
tests/test-lib.sh new file +5
-0+ 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 1Basically what this tells me is that you can't runs these tests at all if your development tree lives on an NFSv2/3 mount point.
Personally what I'll do is run this on a kvm guest or otherwise dedicated test machine. So I can live with that assumption.
--b.
Quoted 35 lines · Jeff Layton
This is an updated patchset for adding test infrastructure to nfs-utils. The main differences in this patchset are:
1) some bugfixes in the
statdb_dumpprogram2) an extra check for root privs in the t0001 test. If the caller doesn't have root privs, then the test is skipped
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 "
nsm_client" 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 be fairly simple to do.
Quoted 6 lines
Jeff Layton (4):
nfs-utils: make private cookie to hex conversion a library routine
nfs-utils: introduce new statd testing simulator
nfs-utils: addstatdb_dumputility
nfs-utils: add initial tests for statd that run via "make check"
Committed...
steved.