Skip to contentSkip to conversation

nfs-utils: add testing infrastructure to nfs-utils (try #3)

PATCH In review Jeff Layton 4 participants 20 messages Jan 5, 2010 – Jan 8, 2010 5 messages not in the archive

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

cover nfs-utils: add testing infrastructure to nfs-utils (try #3)

This is an updated patchset for adding test infrastructure to nfs-utils. The main differences from the last patchset are:

1) renamed "statdtest" to "nsm_client", since that's a bit more descriptive of its actual purpose.

2) added a very simple "statdb_dump" program that dumps out the more interesting fields of the of the NSM monitor DB. The inital mon/unmon test now uses that program to verify the contents of the DB after the MON call.

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 fairly simple to do.

Jeff Layton (3):
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 +-
 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                  |   75 ++++++
 tests/t0001-statd-basic-mon-unmon.sh |   55 ++++
 tests/test-lib.sh                    |   41 +++
 10 files changed, 753 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
 create mode 100644 tests/statdb_dump.c
 create mode 100755 tests/t0001-statd-basic-mon-unmon.sh
 create mode 100755 tests/test-lib.sh
#1 lore raw

PATCH 1/3 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/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
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..1dc4249 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/nsm_client/Makefile])
 AC_OUTPUT
 
tests/Makefile.am new file +5 -0
new file mode 100644
index 0000000..375af80
@@ -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
new file mode 100644
index 0000000..85379dd
@@ -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
#2 lore raw

PATCH 2/3 nfs-utils: add statdb_dump utility

In reply to Jeff Layton

To dump contents of statd's monitor DB.

---
 tests/Makefile.am   |    6 ++++
 tests/statdb_dump.c |   75 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)
 create mode 100644 tests/statdb_dump.c
tests/Makefile.am +6 -0
index 375af80..a20b42b 100644
@@ -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 +75 -0

75 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#3 lore raw

Re: [PATCH 2/3] nfs-utils: add statdb_dump utility

Quoted 45 lines · Jeff Layton

To dump contents of statd's monitor DB.

---
tests/Makefile.am | 6 ++++
tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++++
+++++++++

2 files changed, 81 insertions(+), 0 deletions(-)

create mode 100644 tests/statdb_dump.c

tests/Makefile.am +6 -0
index 375af80..a20b42b 100644
@@ -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 +13 -0
new file mode 100644
index 0000000..655213a
@@ -0,0 +1,75 @@
+/*
+ * statdb_dump.c -- dump contents of statd's monitor DB
+ *
+ * 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

tests/statdb_dump.c line 23

Quoted 10 lines
tests/statdb_dump.c new file +10 -0
+ * 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.
+ *
+ * Output format is:
+ *
+ * <hostname> <cookie> <mon_name>

my_name might also be interesting when we get local multi-homed support going. Perhaps some command line switches could control what is displayed.

Quoted 28 lines
tests/statdb_dump.c new file +22 -0
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "nsm.h"
+#include "xlog.h"
+
+static char cookiebuf[(SM_PRIV_SIZE * 2) + 1];
+
+static _Bool
+error_check(const int len, const size_t buflen)
+{
+        return (len < 0) || ((size_t)len >= buflen);
+}
+
+static unsigned int
+dump_host(const char *hostname, const struct sockaddr *sa, const  

struct mon *m,

tests/statdb_dump.c new file +5 -0
+	  const time_t timestamp)
+{
+	int i, len;
+	char *buf = cookiebuf;
+	size_t remaining = sizeof(cookiebuf);

tests/statdb_dump.c line 60

Quoted 10 lines
tests/statdb_dump.c new file +10 -0
+
+	/* convert cookie to text string */
+	for (i = 0; i < SM_PRIV_SIZE; i++) {
+		len = snprintf(buf, remaining, "%02x",
+				(unsigned int)(0xff & m->priv[i]));
+		if (error_check(len, remaining))
+			return 0;
+		buf += len;
+		remaining -= (size_t)len;
+	}

I wonder if having a shared helper in support/nsm/file.c for converting a priv cookie to a string would be generally useful.

Quoted 18 lines
tests/statdb_dump.c new file +15 -0
+
+	printf("%s %s %s\n", hostname, cookiebuf, m->mon_id.mon_name);
+	return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+	xlog_syslog(0);
+	xlog_stderr(1);
+	xlog_open(argv[0]);
+	
+	nsm_load_monitor_list(dump_host);
+	return 0;
+}
Signature · 1 line
1.6.5.2
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#4 lore raw

Re: [PATCH 2/3] nfs-utils: add statdb_dump utility

Quoted 54 lines · On Tue, 5 Jan 2010 11:09:20 -0500 Chuck Lever <[email protected]> wrote:
Quoted 51 lines · Jeff Layton

To dump contents of statd's monitor DB.

---
tests/Makefile.am | 6 ++++
tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++++
+++++++++

2 files changed, 81 insertions(+), 0 deletions(-)

create mode 100644 tests/statdb_dump.c

tests/Makefile.am +6 -0
index 375af80..a20b42b 100644
@@ -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 +19 -0
new file mode 100644
index 0000000..655213a
@@ -0,0 +1,75 @@
+/*
+ * statdb_dump.c -- dump contents of statd's monitor DB
+ *
+ * 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 Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
Quoted 9 lines

tests/statdb_dump.c line 23

Quoted 4 lines
tests/statdb_dump.c new file +4 -0
+ *
+ * Output format is:
+ *
+ * <hostname> <cookie> <mon_name>

my_name might also be interesting when we get local multi-homed support going. Perhaps some command line switches could control what is displayed.

Ok, I can add my_name. I'm not crazy about adding options though. My thinking at this point is to keep the program really simple and let the caller parse out what it needs.

Quoted 33 lines
Quoted 33 lines
tests/statdb_dump.c new file +22 -0
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "nsm.h"
+#include "xlog.h"
+
+static char cookiebuf[(SM_PRIV_SIZE * 2) + 1];
+
+static _Bool
+error_check(const int len, const size_t buflen)
+{
+        return (len < 0) || ((size_t)len >= buflen);
+}
+
+static unsigned int
+dump_host(const char *hostname, const struct sockaddr *sa, const  

struct mon *m,

tests/statdb_dump.c new file +10 -0
+	  const time_t timestamp)
+{
+	int i, len;
+	char *buf = cookiebuf;
+	size_t remaining = sizeof(cookiebuf);
+
+	/* convert cookie to text string */
+	for (i = 0; i < SM_PRIV_SIZE; i++) {
+		len = snprintf(buf, remaining, "%02x",
+				(unsigned int)(0xff & m->priv[i]));
Quoted 9 lines

tests/statdb_dump.c line 60

Quoted 5 lines
tests/statdb_dump.c new file +5 -0
+		if (error_check(len, remaining))
+			return 0;
+		buf += len;
+		remaining -= (size_t)len;
+	}

I wonder if having a shared helper in support/nsm/file.c for converting a priv cookie to a string would be generally useful.

I thought about that too but didn't because I only saw one other place that did this. Still though, it's probably the right thing to do. I'll have a look at that.

Quoted 19 lines
Quoted 18 lines
tests/statdb_dump.c new file +15 -0
+
+	printf("%s %s %s\n", hostname, cookiebuf, m->mon_id.mon_name);
+	return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+	xlog_syslog(0);
+	xlog_stderr(1);
+	xlog_open(argv[0]);
+	
+	nsm_load_monitor_list(dump_host);
+	return 0;
+}
Signature · 1 line
1.6.5.2
Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20100105141732.4590bcce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#6 lore raw

Re: [PATCH 2/3] nfs-utils: add statdb_dump utility

Quoted 69 lines · Jeff Layton
Quoted 56 lines · On Tue, 5 Jan 2010 11:09:20 -0500 Chuck Lever <[email protected]> wrote:
Quoted 53 lines · Jeff Layton

To dump contents of statd's monitor DB.

---
tests/Makefile.am | 6 ++++
tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++
++
+++++++++

2 files changed, 81 insertions(+), 0 deletions(-)

create mode 100644 tests/statdb_dump.c

tests/Makefile.am +6 -0
index 375af80..a20b42b 100644
@@ -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 +16 -0
new file mode 100644
index 0000000..655213a
@@ -0,0 +1,75 @@
+/*
+ * statdb_dump.c -- dump contents of statd's monitor DB
+ *
+ * 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 Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.

Quoted 9 lines
Quoted 4 lines

+ *
+ * Output format is:
+ *
+ * <hostname> <cookie> <mon_name>

my_name might also be interesting when we get local multi-homed support going. Perhaps some command line switches could control what is displayed.

Quoted 3 lines

Ok, I can add my_name. I'm not crazy about adding options though. My thinking at this point is to keep the program really simple and let the caller parse out what it needs.

In that case you should probably display the socket address and RPC number parameters as well.

Quoted 70 lines
Quoted 33 lines
Quoted 33 lines

+ *
+ */

tests/statdb_dump.c new file +20 -0
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "nsm.h"
+#include "xlog.h"
+
+static char cookiebuf[(SM_PRIV_SIZE * 2) + 1];
+
+static _Bool
+error_check(const int len, const size_t buflen)
+{
+        return (len < 0) || ((size_t)len >= buflen);
+}
+
+static unsigned int
+dump_host(const char *hostname, const struct sockaddr *sa, const

struct mon *m,

tests/statdb_dump.c new file +10 -0
+	  const time_t timestamp)
+{
+	int i, len;
+	char *buf = cookiebuf;
+	size_t remaining = sizeof(cookiebuf);
+
+	/* convert cookie to text string */
+	for (i = 0; i < SM_PRIV_SIZE; i++) {
+		len = snprintf(buf, remaining, "%02x",
+				(unsigned int)(0xff & m->priv[i]));
Quoted 9 lines

tests/statdb_dump.c line 60

Quoted 5 lines
tests/statdb_dump.c new file +5 -0
+		if (error_check(len, remaining))
+			return 0;
+		buf += len;
+		remaining -= (size_t)len;
+	}

I wonder if having a shared helper in support/nsm/file.c for converting a priv cookie to a string would be generally useful.

I thought about that too but didn't because I only saw one other place that did this. Still though, it's probably the right thing to do. I'll have a look at that.

Quoted 19 lines
Quoted 18 lines
tests/statdb_dump.c new file +15 -0
+
+	printf("%s %s %s\n", hostname, cookiebuf, m->mon_id.mon_name);
+	return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+	xlog_syslog(0);
+	xlog_stderr(1);
+	xlog_open(argv[0]);
+	
+	nsm_load_monitor_list(dump_host);
+	return 0;
+}
Signature · 1 line
1.6.5.2
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#7 lore raw

PATCH 3/3 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 a20b42b..faa8197 100644
@@ -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 +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
#8 lore raw

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

Quoted 106 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 a20b42b..faa8197 100644
@@ -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 +55 -0
new file mode 100755
index 0000000..6e0b869
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd
+#
+# 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 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`
+
+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 +12 -0
new file mode 100755
index 0000000..e509859
@@ -0,0 +1,41 @@
+#!/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,

tests/test-lib.sh line 22

Quoted 10 lines
tests/test-lib.sh new file +10 -0
+# 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/nsm_client

How or Where is '$srcdir' set??

steved.

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

#10 lore raw

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

Quoted 3 lines · On Tue, 05 Jan 2010 11:37:39 -0500 Steve Dickson <[email protected]> wrote:
Quoted 1 line

+export PATH=$PATH:$srcdir/nsm_client

How or Where is '$srcdir' set??

In the Makefile. Automake sets that along with other variables like $top_srcdir. make then stuffs those variables into the environment when it forks.

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

A message that is not in the archive (sent off-list or not yet received): 20100105132519.02c3c76d-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#12 lore raw

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

Quoted 11 lines · On Tue, 5 Jan 2010 13:25:19 -0500 Jeff Layton <[email protected]> wrote:
Quoted 3 lines · On Tue, 05 Jan 2010 11:37:39 -0500 Steve Dickson <[email protected]> wrote:
Quoted 1 line

+export PATH=$PATH:$srcdir/nsm_client

How or Where is '$srcdir' set??

In the Makefile. Automake sets that along with other variables like $top_srcdir. make then stuffs those variables into the environment when it forks.

Sorry, I need to correct myself here. Not everything is exported ($top_srcdir isn't in particular). $srcdir is explicitly exported though. From the automake generated Makefile:

check-TESTS: $(TESTS)

        @failed=0; all=0; xfail=0; xpass=0; skip=0; \
        srcdir=$(srcdir); export srcdir; \

Still, I'll plan to make the scripts set srcdir if it isn't set (and maybe also check its validity). That should allow us to run these scripts standalone too.

Signature · 1 line
Jeff Layton <[email protected]>
#13 lore raw
In reply to Jeff Layton
Quoted 11 lines · Jeff Layton

This is an updated patchset for adding test infrastructure to nfs-utils. The main differences from the last patchset are:

1) renamed "statdtest" to "nsm_client", since that's a bit more descriptive of its actual purpose.

2) added a very simple "statdb_dump" program that dumps out the more interesting fields of the of the NSM monitor DB. The inital mon/unmon test now uses that program to verify the contents of the DB after the MON call.

Quoted 7 lines

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.

This probably just shows I'm not reading carefully, but: are you requiring root, and messing with their existing nfs configuration at all?

For the export stuff it would also be great to have some tests that set up a few dummy exports (using tmpfs?) and tried to mount them (just over loopback), but I'd be afraid someone would try to run "make check" on their production server. So I'm not sure where to put that kind of test.

--b.

Quoted 50 lines

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 fairly simple to do.

Jeff Layton (3):
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 +-
 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                  |   75 ++++++
 tests/t0001-statd-basic-mon-unmon.sh |   55 ++++
 tests/test-lib.sh                    |   41 +++
 10 files changed, 753 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
 create mode 100644 tests/statdb_dump.c
 create mode 100755 tests/t0001-statd-basic-mon-unmon.sh
 create mode 100755 tests/test-lib.sh

--
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

#14 lore raw
Quoted 24 lines · On Wed, 6 Jan 2010 14:17:06 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 11 lines · Jeff Layton

This is an updated patchset for adding test infrastructure to nfs-utils. The main differences from the last patchset are:

1) renamed "statdtest" to "nsm_client", since that's a bit more descriptive of its actual purpose.

2) added a very simple "statdb_dump" program that dumps out the more interesting fields of the of the NSM monitor DB. The inital mon/unmon test now uses that program to verify the contents of the DB after the MON call.

Quoted 7 lines

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.

This probably just shows I'm not reading carefully, but: are you requiring root, and messing with their existing nfs configuration at all?

Quoted 6 lines

For the export stuff it would also be great to have some tests that set up a few dummy exports (using tmpfs?) and tried to mount them (just over loopback), but I'd be afraid someone would try to run "make check" on their production server. So I'm not sure where to put that kind of test.

The script I have so far doesn't check for root privs, but it won't work unless you have them since statd will fail to start. statd currently requires root privs to start though it does drop them soon afterward.

I'm open to suggestions on changing this as I'm not crazy about that either.

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

A message that is not in the archive (sent off-list or not yet received): 20100106144247.18dc10de-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#16 lore raw
Quoted 14 lines · Jeff Layton
Quoted 10 lines · On Wed, 6 Jan 2010 14:17:06 -0500 "J. Bruce Fields" <[email protected]>…

This probably just shows I'm not reading carefully, but: are you requiring root, and messing with their existing nfs configuration at all?

For the export stuff it would also be great to have some tests that set up a few dummy exports (using tmpfs?) and tried to mount them (just over loopback), but I'd be afraid someone would try to run "make check" on their production server. So I'm not sure where to put that kind of test.

Quoted 7 lines

The script I have so far doesn't check for root privs, but it won't work unless you have them since statd will fail to start. statd currently requires root privs to start though it does drop them soon afterward.

I'm open to suggestions on changing this as I'm not crazy about that either.

My feeling is that it will be hard to find a realistic way to test everything without having root and taking over the machine to some degree.

Just so long as the user understands whether it needs to be run as root, whether it's safe to be run on a host connected to the network, etc.... I don't know if 'make check' is the right ui for that.

--b.

#17 lore raw
Quoted 23 lines · On Wed, 6 Jan 2010 14:58:19 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 14 lines · Jeff Layton
Quoted 10 lines · On Wed, 6 Jan 2010 14:17:06 -0500 "J. Bruce Fields" <[email protected]>…

This probably just shows I'm not reading carefully, but: are you requiring root, and messing with their existing nfs configuration at all?

For the export stuff it would also be great to have some tests that set up a few dummy exports (using tmpfs?) and tried to mount them (just over loopback), but I'd be afraid someone would try to run "make check" on their production server. So I'm not sure where to put that kind of test.

Quoted 7 lines

The script I have so far doesn't check for root privs, but it won't work unless you have them since statd will fail to start. statd currently requires root privs to start though it does drop them soon afterward.

I'm open to suggestions on changing this as I'm not crazy about that either.

Quoted 8 lines

My feeling is that it will be hard to find a realistic way to test everything without having root and taking over the machine to some degree.

Just so long as the user understands whether it needs to be run as root, whether it's safe to be run on a host connected to the network, etc.... I don't know if 'make check' is the right ui for that.

I guess I don't really envision this being run by people who are just downloading and building the sources. I see it as more useful for us as developers of this code as a way to periodically sanity check functionality.

I can certainly add a check here to tell people "Hey you need to run make check as root, don't hurt yourself if you do". I can also do something that says "Hey you need to start up statd, mountd, etc...run these programs as root and hit return when you're done".

Any way you look at it though, yes you will need to take over the machine to some degree. I'm not sure that "make check" is any worse than any other UI though. It certainly has the advantage of not requiring a lot of extra infrastructure.

If we require a lot of extra infrastructure to run a test suite then I fear that no one will ever bother run it. I think convenience is a requirement here.

Signature · 1 line
Jeff Layton <[email protected]>
#18 lore raw
In reply to J. Bruce Fields
Quoted 23 lines · J. Bruce Fields
Quoted 14 lines · Jeff Layton
Quoted 10 lines · On Wed, 6 Jan 2010 14:17:06 -0500 "J. Bruce Fields" <[email protected]>…

This probably just shows I'm not reading carefully, but: are you requiring root, and messing with their existing nfs configuration at all?

For the export stuff it would also be great to have some tests that set up a few dummy exports (using tmpfs?) and tried to mount them (just over loopback), but I'd be afraid someone would try to run "make check" on their production server. So I'm not sure where to put that kind of test.

Quoted 7 lines

The script I have so far doesn't check for root privs, but it won't work unless you have them since statd will fail to start. statd currently requires root privs to start though it does drop them soon afterward.

I'm open to suggestions on changing this as I'm not crazy about that either.

Quoted 7 lines

My feeling is that it will be hard to find a realistic way to test everything without having root and taking over the machine to some degree.

Just so long as the user understands whether it needs to be run as root, whether it's safe to be run on a host connected to the network, etc.... I don't know if 'make check' is the right ui for that.

I hear your concern. I would have some trepidation about using "make check" if I knew it required root, and was not familiar enough with the code to know exactly what it does.

My original idea was that this facility would be a set of smaller unit tests. Since some of statd/sm-notify is now broken out into libraries, I think that makes it a little easier to craft targeted tests that don't require a full-blown statd running to carry out (Of course, that's speculation; I could be wrong, and Jeff has kindly set up the code for us to test this theory!).

The old code has a statd simulator that doesn't require root, and uses its own RPC program number. It might be reasonable to adopt that approach instead of using the real statd, for some test cases.

Another way to set this up might be to use a container, or run it under a lightweight kvm.

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com

#19 lore raw
Quoted 10 lines · Chuck Lever

My original idea was that this facility would be a set of smaller unit tests. Since some of statd/sm-notify is now broken out into libraries, I think that makes it a little easier to craft targeted tests that don't require a full-blown statd running to carry out (Of course, that's speculation; I could be wrong, and Jeff has kindly set up the code for us to test this theory!).

The old code has a statd simulator that doesn't require root, and uses its own RPC program number. It might be reasonable to adopt that approach instead of using the real statd, for some test cases.

Like I say, it might be nice to be able to add even more intrusive tests (e.g. that modify the exports and then test the results over "lo" with the kernel client), so I'm actually happy Jeff says he's not bending over backwards to make the tests unprivileged.

Quoted 2 lines

Another way to set this up might be to use a container, or run it under a lightweight kvm.

Sounds ambitious for now.

--b.

#20 lore raw
Quoted 8 lines · On Wed, 6 Jan 2010 15:33:13 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 7 lines · Chuck Lever

My original idea was that this facility would be a set of smaller unit tests. Since some of statd/sm-notify is now broken out into libraries, I think that makes it a little easier to craft targeted tests that don't require a full-blown statd running to carry out (Of course, that's speculation; I could be wrong, and Jeff has kindly set up the code for us to test this theory!).

Quoted 9 lines
Quoted 3 lines

The old code has a statd simulator that doesn't require root, and uses its own RPC program number. It might be reasonable to adopt that approach instead of using the real statd, for some test cases.

Like I say, it might be nice to be able to add even more intrusive tests (e.g. that modify the exports and then test the results over "lo" with the kernel client), so I'm actually happy Jeff says he's not bending over backwards to make the tests unprivileged.

The root privs problem is definitely a valid concern.

After thinking about this problem I think the thing to do is probably to create a "run as root" script that starts up statd (for now) and other daemons (eventually). make check can then prompt the user to inspect and run that script as root and then hit return when it's ok to proceed.

That should allow someone to run most of the actual test code as an unprivileged user. I'll plan to incorporate something like this in the next respin.

Quoted 5 lines
Quoted 2 lines

Another way to set this up might be to use a container, or run it under a lightweight kvm.

Sounds ambitious for now.

Agreed. That would be hard to implement across different distros (at least until the virt stuff is more standardized).

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

A message that is not in the archive (sent off-list or not yet received): 20100107091832.687cb7eb-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org

#22 lore raw
Quoted 29 lines · Jeff Layton
Quoted 8 lines · On Wed, 6 Jan 2010 15:33:13 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 7 lines · Chuck Lever

My original idea was that this facility would be a set of smaller unit tests. Since some of statd/sm-notify is now broken out into libraries, I think that makes it a little easier to craft targeted tests that don't require a full-blown statd running to carry out (Of course, that's speculation; I could be wrong, and Jeff has kindly set up the code for us to test this theory!).

Quoted 9 lines
Quoted 3 lines

The old code has a statd simulator that doesn't require root, and uses its own RPC program number. It might be reasonable to adopt that approach instead of using the real statd, for some test cases.

Like I say, it might be nice to be able to add even more intrusive tests (e.g. that modify the exports and then test the results over "lo" with the kernel client), so I'm actually happy Jeff says he's not bending over backwards to make the tests unprivileged.

The root privs problem is definitely a valid concern.

After thinking about this problem I think the thing to do is probably to create a "run as root" script that starts up statd (for now) and other daemons (eventually). make check can then prompt the user to inspect and run that script as root and then hit return when it's ok to proceed.

Quoted 3 lines

That should allow someone to run most of the actual test code as an unprivileged user. I'll plan to incorporate something like this in the next respin.

That sounds complicated. And, as I said above, we might some day like to include tests where the privileged stuff makes up the body of the test.

Why not just "the tests you are about to run need root privileges, and will start and stop statd; continue (y/n)?"

--b.

Quoted 16 lines
Quoted 6 lines
Quoted 3 lines

Another way to set this up might be to use a container, or run it under a lightweight kvm.

Sounds ambitious for now.

Agreed. That would be hard to implement across different distros (at least until the virt stuff is more standardized).

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
#23 lore raw
Quoted 34 lines · On Fri, 8 Jan 2010 00:05:56 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 29 lines · Jeff Layton
Quoted 8 lines · On Wed, 6 Jan 2010 15:33:13 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 7 lines · Chuck Lever

My original idea was that this facility would be a set of smaller unit tests. Since some of statd/sm-notify is now broken out into libraries, I think that makes it a little easier to craft targeted tests that don't require a full-blown statd running to carry out (Of course, that's speculation; I could be wrong, and Jeff has kindly set up the code for us to test this theory!).

Quoted 9 lines
Quoted 3 lines

The old code has a statd simulator that doesn't require root, and uses its own RPC program number. It might be reasonable to adopt that approach instead of using the real statd, for some test cases.

Like I say, it might be nice to be able to add even more intrusive tests (e.g. that modify the exports and then test the results over "lo" with the kernel client), so I'm actually happy Jeff says he's not bending over backwards to make the tests unprivileged.

The root privs problem is definitely a valid concern.

After thinking about this problem I think the thing to do is probably to create a "run as root" script that starts up statd (for now) and other daemons (eventually). make check can then prompt the user to inspect and run that script as root and then hit return when it's ok to proceed.

Quoted 3 lines

That should allow someone to run most of the actual test code as an unprivileged user. I'll plan to incorporate something like this in the next respin.

Quoted 7 lines

That sounds complicated. And, as I said above, we might some day like to include tests where the privileged stuff makes up the body of the test.

Why not just "the tests you are about to run need root privileges, and will start and stop statd; continue (y/n)?"

Ok. Most statd tests probably won't need root privs, but it makes sense that other tests eventually will. That's certainly a simpler approach.

Signature · 1 line
Jeff Layton <[email protected]>
#24 lore raw
In reply to J. Bruce Fields
Quoted 13 lines · On Fri, 8 Jan 2010 00:05:56 -0500 "J. Bruce Fields" <[email protected]>…
Quoted 9 lines

The root privs problem is definitely a valid concern.

After thinking about this problem I think the thing to do is probably to create a "run as root" script that starts up statd (for now) and other daemons (eventually). make check can then prompt the user to inspect and run that script as root and then hit return when it's ok to proceed.

Quoted 3 lines

That should allow someone to run most of the actual test code as an unprivileged user. I'll plan to incorporate something like this in the next respin.

Quoted 7 lines

That sounds complicated. And, as I said above, we might some day like to include tests where the privileged stuff makes up the body of the test.

Why not just "the tests you are about to run need root privileges, and will start and stop statd; continue (y/n)?"

It turns out that this is a little tricky to do within "make check". The tests are all run as individual scripts, so it's not straightforward to have one do this check and force all of the others to exit.

It also seems like a useless question. If we have root privileges, there's no point in asking. If we don't have them, we just have to exit anyway. I don't see any point in prompting...

What I can do fairly easily is add a check to the individual test that makes sure the euid is 0, and then exits with a "skip this test" error code if it's not. After some consideration, I like that better anyway since it will make it possible to run a subset of the tests as an unprivileged user.

I'll post a new set with this change in a bit...

Cheers,

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