* [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
@ 2010-01-05 15:40 Jeff Layton
2010-01-05 15:40 ` [PATCH 1/3] nfs-utils: introduce new statd testing simulator Jeff Layton
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 15:40 UTC (permalink / raw)
To: steved; +Cc: chuck.lever, linux-nfs
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/3] nfs-utils: introduce new statd testing simulator
2010-01-05 15:40 [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) Jeff Layton
@ 2010-01-05 15:40 ` Jeff Layton
2010-01-05 15:40 ` [PATCH 2/3] nfs-utils: add statdb_dump utility Jeff Layton
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 15:40 UTC (permalink / raw)
To: steved; +Cc: chuck.lever, linux-nfs
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.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
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
diff --git a/Makefile.am b/Makefile.am
index b3a6e91..ae7cd16 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = tools support utils linux-nfs
+SUBDIRS = tools support utils linux-nfs tests
MAINTAINERCLEANFILES = Makefile.in
diff --git a/configure.ac b/configure.ac
index 7dffeaf..1dc4249 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..375af80
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,5 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS = nsm_client
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
new file mode 100644
index 0000000..4bf0a45
--- /dev/null
+++ b/tests/nsm_client/Makefile.am
@@ -0,0 +1,45 @@
+## Process this file with automake to produce Makefile.in
+
+GENFILES_CLNT = nlm_sm_inter_clnt.c
+GENFILES_SVC = nlm_sm_inter_svc.c
+GENFILES_XDR = nlm_sm_inter_xdr.c
+GENFILES_H = nlm_sm_inter.h
+
+GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
+
+
+check_PROGRAMS = nsm_client
+nsm_client_SOURCES = $(GENFILES) nsm_client.c
+
+BUILT_SOURCES = $(GENFILES)
+nsm_client_LDADD = ../../support/nfs/libnfs.a \
+ ../../support/nsm/libnsm.a $(LIBCAP)
+
+if CONFIG_RPCGEN
+RPCGEN = $(top_builddir)/tools/rpcgen/rpcgen
+$(RPCGEN):
+ make -C ../../tools/rpcgen all
+else
+RPCGEN = @RPCGEN_PATH@
+endif
+
+$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN)
+ test -f $@ && rm -rf $@ || true
+ $(RPCGEN) -l -o $@ $<
+
+$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
+ test -f $@ && rm -rf $@ || true
+ $(RPCGEN) -m -o $@ $<
+
+$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN)
+ test -f $@ && rm -rf $@ || true
+ $(RPCGEN) -c -o $@ $<
+
+$(GENFILES_H): %.h: %.x $(RPCGEN)
+ test -f $@ && rm -rf $@ || true
+ $(RPCGEN) -h -o $@ $<
+
+MAINTAINERCLEANFILES = Makefile.in
+
+CLEANFILES = $(GENFILES)
+
diff --git a/tests/nsm_client/README b/tests/nsm_client/README
new file mode 100644
index 0000000..85379dd
--- /dev/null
+++ b/tests/nsm_client/README
@@ -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.
diff --git a/tests/nsm_client/nlm_sm_inter.x b/tests/nsm_client/nlm_sm_inter.x
new file mode 100644
index 0000000..95fa326
--- /dev/null
+++ b/tests/nsm_client/nlm_sm_inter.x
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff
+ * Modified by Olaf Kirch, 1996.
+ * Modified by H.J. Lu, 1998.
+ * Modified by Jeff Layton, 2010.
+ *
+ * NLM similator for Linux
+ */
+
+#ifdef RPC_CLNT
+%#include <string.h>
+#endif
+
+/*
+ * statd rejects monitor registrations for any non-lockd services, so pretend
+ * to be lockd when testing. Furthermore, the only call we care about from
+ * statd is #16, which is the downcall to notify the kernel of a host's status
+ * change.
+ */
+program NLM_SM_PROG {
+ /* version 3 of the NLM protocol */
+ version NLM_SM_VERS3 {
+ void NLM_SM_NOTIFY(struct nlm_sm_notify) = 16;
+ } = 3;
+
+ /* version 2 of NLM protocol */
+ version NLM_SM_VERS4 {
+ void NLM_SM_NOTIFY(struct nlm_sm_notify) = 16;
+ } = 4;
+} = 100021;
+
+const SM_MAXSTRLEN = 1024;
+const SM_PRIV_SIZE = 16;
+
+/*
+ * structure of the status message sent back by the status monitor
+ * when monitor site status changes
+ */
+struct nlm_sm_notify {
+ string mon_name<SM_MAXSTRLEN>;
+ int state;
+ opaque priv[SM_PRIV_SIZE]; /* stored private information */
+};
diff --git a/tests/nsm_client/nsm_client.c b/tests/nsm_client/nsm_client.c
new file mode 100644
index 0000000..0d1159a
--- /dev/null
+++ b/tests/nsm_client/nsm_client.c
@@ -0,0 +1,465 @@
+/*
+ * nsm_client.c -- synthetic client and lockd simulator for testing statd
+ *
+ * Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
+ *
+ * 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.
+ *
+ * Very loosely based on "simulator.c" in the statd directory. Original
+ * copyright for that program follows:
+ *
+ * Copyright (C) 1995-1997, 1999 Jeffrey A. Uphoff
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <errno.h>
+#include <getopt.h>
+#include <netdb.h>
+#include <signal.h>
+#include <string.h>
+#include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
+#include <rpcmisc.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "nfslib.h"
+#include "nfsrpc.h"
+#include "nsm.h"
+#include "sm_inter.h"
+#include "nlm_sm_inter.h"
+#include "sockaddr.h"
+#include "xcommon.h"
+
+static void daemon_simulator(void);
+static void sim_killer(int sig);
+static int nsm_client_crash(char *);
+static int nsm_client_mon(char *, char *, char *, char *, int, int);
+static int nsm_client_stat(char *, char *);
+static int nsm_client_notify(char *, char *, char *);
+static int nsm_client_unmon(char *, char *, char *, int, int);
+static int nsm_client_unmon_all(char *, char *, int, int);
+
+extern void nlm_sm_prog_4(struct svc_req *rqstp, register SVCXPRT *transp);
+extern void svc_exit(void);
+
+/*
+ * default to 15 retransmit interval, which seems to be the default for
+ * UDP clients w/ legacy glibc RPC
+ */
+static struct timeval retrans_interval =
+{
+ .tv_sec = 15,
+};
+
+static struct option longopts[] =
+{
+ { "help", 0, 0, 'h' },
+ { "host", 0, 0, 'H' },
+ { "name", 1, 0, 'n' },
+ { "program", 1, 0, 'P' },
+ { "version", 1, 0, 'v' },
+ { NULL, 0, 0, 0 },
+};
+
+static int
+usage(char *program)
+{
+ printf("Usage:\n");
+ printf("%s [options] <command> [arg]...\n", program);
+ printf("where command is one of these with the specified args:\n");
+ printf("crash\t\t\t\ttell host to simulate crash\n");
+ printf("daemon\t\t\t\t\tstart up lockd daemon simulator\n");
+ printf("notify <mon_name> <state>\tsend a reboot notification to host\n");
+ printf("stat <mon_name>\t\t\tget status of <mon_name> on host\n");
+ printf("unmon_all\t\t\ttell host to unmon everything\n");
+ printf("unmon <mon_name>\t\t\ttell host to unmon <mon_name>\n");
+ printf("mon <mon_name> <cookie>\t\ttell host to monitor <mon_name> with private <cookie>\n");
+ return 1;
+}
+
+static int
+hex2bin(char *dst, size_t dstlen, char *src)
+{
+ int i;
+ unsigned int tmp;
+
+ for (i = 0; *src && i < dstlen; i++) {
+ if (sscanf(src, "%2x", &tmp) != 1)
+ return 0;
+ dst[i] = tmp;
+ src++;
+ if (!*src)
+ break;
+ src++;
+ }
+
+ return 1;
+}
+
+static void
+bin2hex(char *dst, char *src, size_t srclen)
+{
+ int i;
+
+ for (i = 0; i < srclen; i++)
+ dst += sprintf(dst, "%02x", 0xff & src[i]);
+}
+
+int
+main(int argc, char **argv)
+{
+ int arg, err = 0;
+ int remaining_args;
+ char my_name[NI_MAXHOST], host[NI_MAXHOST];
+ char cookie[SM_PRIV_SIZE];
+ int my_prog = NLM_SM_PROG;
+ int my_vers = NLM_SM_VERS4;
+
+ my_name[0] = '\0';
+ host[0] = '\0';
+
+ while ((arg = getopt_long(argc, argv, "hHn:P:v:", longopts,
+ NULL)) != EOF) {
+ switch (arg) {
+ case 'H':
+ strncpy(host, optarg, sizeof(host));
+ case 'n':
+ strncpy(my_name, optarg, sizeof(my_name));
+ case 'P':
+ my_prog = atoi(optarg);
+ case 'v':
+ my_vers = atoi(optarg);
+ }
+ }
+
+ remaining_args = argc - optind;
+ if (remaining_args <= 0)
+ usage(argv[0]);
+
+ if (!my_name[0])
+ gethostname(my_name, sizeof(my_name));
+ if (!host[0])
+ strncpy(host, "127.0.0.1", sizeof(host));
+
+ if (!strcasecmp(argv[optind], "daemon")) {
+ daemon_simulator();
+ } else if (!strcasecmp(argv[optind], "crash")) {
+ err = nsm_client_crash(host);
+ } else if (!strcasecmp(argv[optind], "stat")) {
+ if (remaining_args < 2)
+ usage(argv[0]);
+ err = nsm_client_stat(host, argv[optind + 2]);
+ } else if (!strcasecmp(argv[optind], "unmon_all")) {
+ err = nsm_client_unmon_all(host, my_name, my_prog, my_vers);
+ } else if (!strcasecmp(argv[optind], "unmon")) {
+ if (remaining_args < 2)
+ usage(argv[0]);
+ err = nsm_client_unmon(host, argv[optind + 1], my_name, my_prog,
+ my_vers);
+ } else if (!strcasecmp(argv[optind], "notify")) {
+ if (remaining_args < 2)
+ usage(argv[0]);
+ err = nsm_client_notify(host, argv[optind + 1],
+ argv[optind + 2]);
+ } else if (!strcasecmp(argv[optind], "mon")) {
+ if (remaining_args < 2)
+ usage(argv[0]);
+
+ memset(cookie, '\0', SM_PRIV_SIZE);
+ if (!hex2bin(cookie, sizeof(cookie), argv[optind + 2])) {
+ fprintf(stderr, "SYS:%d\n", EINVAL);
+ printf("Unable to convert hex cookie %s to binary.\n",
+ argv[optind + 2]);
+ return 1;
+ }
+
+ err = nsm_client_mon(host, argv[optind + 1], cookie, my_name,
+ my_prog, my_vers);
+ } else {
+ err = usage(argv[0]);
+ }
+
+ return err;
+}
+
+static CLIENT *
+nsm_client_get_rpcclient(const char *node)
+{
+ unsigned short port;
+ struct addrinfo *ai;
+ struct addrinfo hints = { .ai_flags = AI_ADDRCONFIG };
+ int err;
+ CLIENT *client = NULL;
+
+#ifndef IPV6_ENABLED
+ hints.ai_family = AF_INET;
+#endif /* IPV6_ENABLED */
+
+ /* FIXME: allow support for providing port? */
+ err = getaddrinfo(node, NULL, &hints, &ai);
+ if (err) {
+ fprintf(stderr, "EAI:%d\n", err);
+ if (err == EAI_SYSTEM)
+ fprintf(stderr, "SYS:%d\n", errno);
+ printf("Unable to translate host to address: %s\n",
+ err == EAI_SYSTEM ? strerror(errno) :
+ gai_strerror(err));
+ return client;
+ }
+
+ /* FIXME: allow for TCP too? */
+ port = nfs_getport(ai->ai_addr, ai->ai_addrlen, SM_PROG,
+ SM_VERS, IPPROTO_UDP);
+ if (!port) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("Unable to determine port for service\n");
+ goto out;
+ }
+
+ nfs_set_port(ai->ai_addr, port);
+
+ client = nfs_get_rpcclient(ai->ai_addr, ai->ai_addrlen, IPPROTO_UDP,
+ SM_PROG, SM_VERS, &retrans_interval);
+ if (!client) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("RPC client creation failed\n");
+ }
+out:
+ freeaddrinfo(ai);
+ return client;
+}
+
+static int
+nsm_client_mon(char *calling, char *monitoring, char *cookie, char *my_name,
+ int my_prog, int my_vers)
+{
+ CLIENT *client;
+ sm_stat_res *result;
+ mon mon;
+ int err = 0;
+
+ printf("Calling %s (as %s) to monitor %s\n", calling, my_name,
+ monitoring);
+
+ if ((client = nsm_client_get_rpcclient(calling)) == NULL)
+ return 1;
+
+ memcpy(mon.priv, cookie, SM_PRIV_SIZE);
+ mon.mon_id.my_id.my_name = my_name;
+ mon.mon_id.my_id.my_prog = my_prog;
+ mon.mon_id.my_id.my_vers = my_vers;
+ mon.mon_id.my_id.my_proc = NLM_SM_NOTIFY;
+ mon.mon_id.mon_name = monitoring;
+
+ if (!(result = sm_mon_1(&mon, client))) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("%s\n", clnt_sperror(client, "sm_mon_1"));
+ err = 1;
+ goto mon_out;
+ }
+
+ printf("SM_MON request %s, state: %d\n",
+ result->res_stat == stat_succ ? "successful" : "failed",
+ result->state);
+
+ if (result->res_stat != stat_succ) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ err = 1;
+ }
+
+mon_out:
+ clnt_destroy(client);
+ return err;
+}
+
+static int
+nsm_client_unmon(char *calling, char *unmonitoring, char *my_name, int my_prog,
+ int my_vers)
+{
+ CLIENT *client;
+ sm_stat *result;
+ mon_id mon_id;
+ int err = 0;
+
+ printf("Calling %s (as %s) to unmonitor %s\n", calling, my_name,
+ unmonitoring);
+
+ if ((client = nsm_client_get_rpcclient(calling)) == NULL)
+ return 1;
+
+ mon_id.my_id.my_name = my_name;
+ mon_id.my_id.my_prog = my_prog;
+ mon_id.my_id.my_vers = my_vers;
+ mon_id.my_id.my_proc = NLM_SM_NOTIFY;
+ mon_id.mon_name = unmonitoring;
+
+ if (!(result = sm_unmon_1(&mon_id, client))) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("%s\n", clnt_sperror(client, "sm_unmon_1"));
+ err = 1;
+ goto unmon_out;
+ }
+
+ printf("SM_UNMON state: %d\n", result->state);
+
+unmon_out:
+ clnt_destroy(client);
+ return err;
+}
+
+static int
+nsm_client_unmon_all(char *calling, char *my_name, int my_prog, int my_vers)
+{
+ CLIENT *client;
+ sm_stat *result;
+ my_id my_id;
+ int err = 0;
+
+ printf("Calling %s (as %s) to unmonitor all hosts\n", calling, my_name);
+
+ if ((client = nsm_client_get_rpcclient(calling)) == NULL) {
+ printf("RPC client creation failed\n");
+ return 1;
+ }
+
+ my_id.my_name = my_name;
+ my_id.my_prog = my_prog;
+ my_id.my_vers = my_vers;
+ my_id.my_proc = NLM_SM_NOTIFY;
+
+ if (!(result = sm_unmon_all_1(&my_id, client))) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("%s\n", clnt_sperror(client, "sm_unmon_all_1"));
+ err = 1;
+ goto unmon_all_out;
+ }
+
+ printf("SM_UNMON_ALL state: %d\n", result->state);
+
+unmon_all_out:
+ return err;
+}
+
+static int
+nsm_client_crash(char *host)
+{
+ CLIENT *client;
+
+ if ((client = nsm_client_get_rpcclient(host)) == NULL)
+ return 1;
+
+ if (!sm_simu_crash_1(NULL, client)) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("%s\n", clnt_sperror(client, "sm_simu_crash_1"));
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+nsm_client_stat(char *calling, char *monitoring)
+{
+ CLIENT *client;
+ sm_name checking;
+ sm_stat_res *result;
+
+ if ((client = nsm_client_get_rpcclient(calling)) == NULL)
+ return 1;
+
+ checking.mon_name = monitoring;
+
+ if (!(result = sm_stat_1(&checking, client))) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("%s\n", clnt_sperror(client, "sm_stat_1"));
+ return 1;
+ }
+
+ if (result->res_stat != stat_succ) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("stat_fail from %s for %s, state: %d\n", calling,
+ monitoring, result->state);
+ return 1;
+ }
+
+ printf("stat_succ from %s for %s, state: %d\n", calling,
+ monitoring, result->state);
+
+ return 0;
+}
+
+static int
+nsm_client_notify(char *calling, char *mon_name, char *statestr)
+{
+ CLIENT *client;
+
+ stat_chge stat_chge = { .mon_name = mon_name };
+
+ stat_chge.state = atoi(statestr);
+
+ if ((client = nsm_client_get_rpcclient(calling)) == NULL)
+ return 1;
+
+ if (!sm_notify_1(&stat_chge, client)) {
+ fprintf(stderr, "RPC:%d\n", rpc_createerr.cf_stat);
+ printf("%s\n", clnt_sperror(client, "sm_notify_1"));
+ return 1;
+ }
+
+ return 0;
+}
+
+static void sim_killer(int sig)
+{
+#ifdef HAVE_LIBTIRPC
+ (void) rpcb_unset(NLM_SM_PROG, NLM_SM_VERS4, NULL);
+#else
+ (void) pmap_unset(NLM_SM_PROG, NLM_SM_VERS4);
+#endif
+ exit(0);
+}
+
+static void daemon_simulator(void)
+{
+ signal(SIGHUP, sim_killer);
+ signal(SIGINT, sim_killer);
+ signal(SIGTERM, sim_killer);
+ /* FIXME: allow for different versions? */
+ nfs_svc_create("nlmsim", NLM_SM_PROG, NLM_SM_VERS4, nlm_sm_prog_4, 0);
+ svc_run();
+}
+
+void *nlm_sm_notify_4_svc(struct nlm_sm_notify *argp, struct svc_req *rqstp)
+{
+ static char *result;
+ char priv[SM_PRIV_SIZE * 2 + 1];
+
+ bin2hex(priv, argp->priv, SM_PRIV_SIZE);
+
+ printf("state=%d:mon_name=%s:private=%s\n", argp->state,
+ argp->mon_name, priv);
+ return (void *) &result;
+}
+
+void *nlm_sm_notify_3_svc(struct nlm_sm_notify *argp, struct svc_req *rqstp)
+{
+ return nlm_sm_notify_4_svc(argp, rqstp);
+}
--
1.6.5.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/3] nfs-utils: add statdb_dump utility
2010-01-05 15:40 [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) Jeff Layton
2010-01-05 15:40 ` [PATCH 1/3] nfs-utils: introduce new statd testing simulator Jeff Layton
@ 2010-01-05 15:40 ` Jeff Layton
2010-01-05 16:09 ` Chuck Lever
2010-01-05 15:40 ` [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check" Jeff Layton
2010-01-06 19:17 ` [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) J. Bruce Fields
3 siblings, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 15:40 UTC (permalink / raw)
To: steved; +Cc: chuck.lever, linux-nfs
To dump contents of statd's monitor DB.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
tests/Makefile.am | 6 ++++
tests/statdb_dump.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 0 deletions(-)
create mode 100644 tests/statdb_dump.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 375af80..a20b42b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
new file mode 100644
index 0000000..655213a
--- /dev/null
+++ b/tests/statdb_dump.c
@@ -0,0 +1,75 @@
+/*
+ * statdb_dump.c -- dump contents of statd's monitor DB
+ *
+ * Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
+ *
+ * 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.
+ *
+ * Output format is:
+ *
+ * <hostname> <cookie> <mon_name>
+ *
+ */
+
+#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,
+ 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]));
+ if (error_check(len, remaining))
+ return 0;
+ buf += len;
+ remaining -= (size_t)len;
+ }
+
+ 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;
+}
--
1.6.5.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check"
2010-01-05 15:40 [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) Jeff Layton
2010-01-05 15:40 ` [PATCH 1/3] nfs-utils: introduce new statd testing simulator Jeff Layton
2010-01-05 15:40 ` [PATCH 2/3] nfs-utils: add statdb_dump utility Jeff Layton
@ 2010-01-05 15:40 ` Jeff Layton
2010-01-05 16:37 ` Steve Dickson
2010-01-06 19:17 ` [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) J. Bruce Fields
3 siblings, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 15:40 UTC (permalink / raw)
To: steved; +Cc: chuck.lever, linux-nfs
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 <jlayton@redhat.com>
---
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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a20b42b..faa8197 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,3 +9,5 @@ statdb_dump_LDADD = ../support/nfs/libnfs.a \
SUBDIRS = nsm_client
MAINTAINERCLEANFILES = Makefile.in
+
+TESTS = t0001-statd-basic-mon-unmon.sh
diff --git a/tests/t0001-statd-basic-mon-unmon.sh b/tests/t0001-statd-basic-mon-unmon.sh
new file mode 100755
index 0000000..6e0b869
--- /dev/null
+++ b/tests/t0001-statd-basic-mon-unmon.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd
+#
+# Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
+#
+# 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
+
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
new file mode 100755
index 0000000..e509859
--- /dev/null
+++ b/tests/test-lib.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# test-lib.sh -- library of functions for nfs-utils tests
+#
+# Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
+#
+# 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/nsm_client
+
+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 "
+ echo " be down when starting this test"
+ return 1
+ fi
+ $srcdir/../utils/statd/statd --no-notify
+}
+
+kill_statd() {
+ kill `cat /var/run/rpc.statd.pid`
+}
--
1.6.5.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/3] nfs-utils: add statdb_dump utility
2010-01-05 15:40 ` [PATCH 2/3] nfs-utils: add statdb_dump utility Jeff Layton
@ 2010-01-05 16:09 ` Chuck Lever
2010-01-05 19:17 ` Jeff Layton
0 siblings, 1 reply; 20+ messages in thread
From: Chuck Lever @ 2010-01-05 16:09 UTC (permalink / raw)
To: Jeff Layton; +Cc: steved, linux-nfs
On Jan 5, 2010, at 10:40 AM, Jeff Layton wrote:
> To dump contents of statd's monitor DB.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> tests/Makefile.am | 6 ++++
> tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++++
> +++++++++
> 2 files changed, 81 insertions(+), 0 deletions(-)
> create mode 100644 tests/statdb_dump.c
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 375af80..a20b42b 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -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
> diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
> new file mode 100644
> index 0000000..655213a
> --- /dev/null
> +++ b/tests/statdb_dump.c
> @@ -0,0 +1,75 @@
> +/*
> + * statdb_dump.c -- dump contents of statd's monitor DB
> + *
> + * Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
> + *
> + * 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.
> + *
> + * 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.
> + *
> + */
> +
> +#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,
> + 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]));
> + 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.
> +
> + 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;
> +}
> --
> 1.6.5.2
>
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check"
2010-01-05 15:40 ` [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check" Jeff Layton
@ 2010-01-05 16:37 ` Steve Dickson
[not found] ` <4B436AD3.2080107-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 20+ messages in thread
From: Steve Dickson @ 2010-01-05 16:37 UTC (permalink / raw)
To: Jeff Layton; +Cc: chuck.lever, linux-nfs
On 01/05/2010 10:40 AM, Jeff Layton wrote:
> 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 <jlayton@redhat.com>
> ---
> 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
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index a20b42b..faa8197 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -9,3 +9,5 @@ statdb_dump_LDADD = ../support/nfs/libnfs.a \
> SUBDIRS = nsm_client
>
> MAINTAINERCLEANFILES = Makefile.in
> +
> +TESTS = t0001-statd-basic-mon-unmon.sh
> diff --git a/tests/t0001-statd-basic-mon-unmon.sh b/tests/t0001-statd-basic-mon-unmon.sh
> new file mode 100755
> index 0000000..6e0b869
> --- /dev/null
> +++ b/tests/t0001-statd-basic-mon-unmon.sh
> @@ -0,0 +1,55 @@
> +#!/bin/bash
> +#
> +# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd
> +#
> +# Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
> +#
> +# 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
> +
> diff --git a/tests/test-lib.sh b/tests/test-lib.sh
> new file mode 100755
> index 0000000..e509859
> --- /dev/null
> +++ b/tests/test-lib.sh
> @@ -0,0 +1,41 @@
> +#!/bin/bash
> +#
> +# test-lib.sh -- library of functions for nfs-utils tests
> +#
> +# Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
> +#
> +# 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/nsm_client
How or Where is '$srcdir' set??
steved.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check"
[not found] ` <4B436AD3.2080107-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
@ 2010-01-05 18:25 ` Jeff Layton
[not found] ` <20100105132519.02c3c76d-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 18:25 UTC (permalink / raw)
To: Steve Dickson; +Cc: chuck.lever, linux-nfs
On Tue, 05 Jan 2010 11:37:39 -0500
Steve Dickson <SteveD@redhat.com> wrote:
> > +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.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/3] nfs-utils: add statdb_dump utility
2010-01-05 16:09 ` Chuck Lever
@ 2010-01-05 19:17 ` Jeff Layton
[not found] ` <20100105141732.4590bcce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 19:17 UTC (permalink / raw)
To: Chuck Lever; +Cc: steved, linux-nfs
On Tue, 5 Jan 2010 11:09:20 -0500
Chuck Lever <chuck.lever@oracle.com> wrote:
>
> On Jan 5, 2010, at 10:40 AM, Jeff Layton wrote:
>
> > To dump contents of statd's monitor DB.
> >
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > tests/Makefile.am | 6 ++++
> > tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++++
> > +++++++++
> > 2 files changed, 81 insertions(+), 0 deletions(-)
> > create mode 100644 tests/statdb_dump.c
> >
> > diff --git a/tests/Makefile.am b/tests/Makefile.am
> > index 375af80..a20b42b 100644
> > --- a/tests/Makefile.am
> > +++ b/tests/Makefile.am
> > @@ -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
> > diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
> > new file mode 100644
> > index 0000000..655213a
> > --- /dev/null
> > +++ b/tests/statdb_dump.c
> > @@ -0,0 +1,75 @@
> > +/*
> > + * statdb_dump.c -- dump contents of statd's monitor DB
> > + *
> > + * Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
> > + *
> > + * 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.
> > + *
> > + * 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.
> > + *
> > + */
> > +
> > +#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,
> > + 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]));
> > + 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.
> > +
> > + 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;
> > +}
> > --
> > 1.6.5.2
> >
>
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/3] nfs-utils: add statdb_dump utility
[not found] ` <20100105141732.4590bcce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
@ 2010-01-05 19:25 ` Chuck Lever
0 siblings, 0 replies; 20+ messages in thread
From: Chuck Lever @ 2010-01-05 19:25 UTC (permalink / raw)
To: Jeff Layton; +Cc: steved, linux-nfs
On Jan 5, 2010, at 2:17 PM, Jeff Layton wrote:
> On Tue, 5 Jan 2010 11:09:20 -0500
> Chuck Lever <chuck.lever@oracle.com> wrote:
>
>>
>> On Jan 5, 2010, at 10:40 AM, Jeff Layton wrote:
>>
>>> To dump contents of statd's monitor DB.
>>>
>>> Signed-off-by: Jeff Layton <jlayton@redhat.com>
>>> ---
>>> tests/Makefile.am | 6 ++++
>>> tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++
>>> ++
>>> +++++++++
>>> 2 files changed, 81 insertions(+), 0 deletions(-)
>>> create mode 100644 tests/statdb_dump.c
>>>
>>> diff --git a/tests/Makefile.am b/tests/Makefile.am
>>> index 375af80..a20b42b 100644
>>> --- a/tests/Makefile.am
>>> +++ b/tests/Makefile.am
>>> @@ -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
>>> diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
>>> new file mode 100644
>>> index 0000000..655213a
>>> --- /dev/null
>>> +++ b/tests/statdb_dump.c
>>> @@ -0,0 +1,75 @@
>>> +/*
>>> + * statdb_dump.c -- dump contents of statd's monitor DB
>>> + *
>>> + * Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
>>> + *
>>> + * 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.
>>> + *
>>> + * 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.
In that case you should probably display the socket address and RPC
number parameters as well.
>>> + *
>>> + */
>>> +
>>> +#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,
>>> + 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]));
>>> + 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.
>
>>> +
>>> + 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;
>>> +}
>>> --
>>> 1.6.5.2
>>>
>>
>
>
> --
> Jeff Layton <jlayton@redhat.com>
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check"
[not found] ` <20100105132519.02c3c76d-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
@ 2010-01-05 21:29 ` Jeff Layton
0 siblings, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2010-01-05 21:29 UTC (permalink / raw)
To: Jeff Layton; +Cc: Steve Dickson, chuck.lever, linux-nfs
On Tue, 5 Jan 2010 13:25:19 -0500
Jeff Layton <jlayton@redhat.com> wrote:
> On Tue, 05 Jan 2010 11:37:39 -0500
> Steve Dickson <SteveD@redhat.com> wrote:
>
> > > +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.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-05 15:40 [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) Jeff Layton
` (2 preceding siblings ...)
2010-01-05 15:40 ` [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check" Jeff Layton
@ 2010-01-06 19:17 ` J. Bruce Fields
2010-01-06 19:42 ` Jeff Layton
3 siblings, 1 reply; 20+ messages in thread
From: J. Bruce Fields @ 2010-01-06 19:17 UTC (permalink / raw)
To: Jeff Layton; +Cc: steved, chuck.lever, linux-nfs
On Tue, Jan 05, 2010 at 10:40:32AM -0500, Jeff Layton wrote:
> 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.
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.
> 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-06 19:17 ` [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) J. Bruce Fields
@ 2010-01-06 19:42 ` Jeff Layton
[not found] ` <20100106144247.18dc10de-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2010-01-06 19:42 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: steved, chuck.lever, linux-nfs
On Wed, 6 Jan 2010 14:17:06 -0500
"J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Tue, Jan 05, 2010 at 10:40:32AM -0500, Jeff Layton wrote:
> > 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.
>
> 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.
>
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.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
[not found] ` <20100106144247.18dc10de-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
@ 2010-01-06 19:58 ` J. Bruce Fields
2010-01-06 20:10 ` Jeff Layton
2010-01-06 20:22 ` Chuck Lever
0 siblings, 2 replies; 20+ messages in thread
From: J. Bruce Fields @ 2010-01-06 19:58 UTC (permalink / raw)
To: Jeff Layton; +Cc: steved, chuck.lever, linux-nfs
On Wed, Jan 06, 2010 at 02:42:47PM -0500, Jeff Layton wrote:
> On Wed, 6 Jan 2010 14:17:06 -0500
> "J. Bruce Fields" <bfields@fieldses.org> wrote:
>
> > 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.
> >
>
> 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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-06 19:58 ` J. Bruce Fields
@ 2010-01-06 20:10 ` Jeff Layton
2010-01-06 20:22 ` Chuck Lever
1 sibling, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2010-01-06 20:10 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: steved, chuck.lever, linux-nfs
On Wed, 6 Jan 2010 14:58:19 -0500
"J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Wed, Jan 06, 2010 at 02:42:47PM -0500, Jeff Layton wrote:
> > On Wed, 6 Jan 2010 14:17:06 -0500
> > "J. Bruce Fields" <bfields@fieldses.org> wrote:
> >
> > > 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.
> > >
> >
> > 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.
>
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.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-06 19:58 ` J. Bruce Fields
2010-01-06 20:10 ` Jeff Layton
@ 2010-01-06 20:22 ` Chuck Lever
2010-01-06 20:33 ` J. Bruce Fields
1 sibling, 1 reply; 20+ messages in thread
From: Chuck Lever @ 2010-01-06 20:22 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Jeff Layton, steved, linux-nfs
On Jan 6, 2010, at 2:58 PM, J. Bruce Fields wrote:
> On Wed, Jan 06, 2010 at 02:42:47PM -0500, Jeff Layton wrote:
>> On Wed, 6 Jan 2010 14:17:06 -0500
>> "J. Bruce Fields" <bfields@fieldses.org> wrote:
>>
>>> 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.
>>>
>>
>> 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.
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-06 20:22 ` Chuck Lever
@ 2010-01-06 20:33 ` J. Bruce Fields
2010-01-07 14:18 ` Jeff Layton
0 siblings, 1 reply; 20+ messages in thread
From: J. Bruce Fields @ 2010-01-06 20:33 UTC (permalink / raw)
To: Chuck Lever; +Cc: Jeff Layton, steved, linux-nfs
On Wed, Jan 06, 2010 at 03:22:55PM -0500, Chuck Lever wrote:
> 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.
> Another way to set this up might be to use a container, or run it under a
> lightweight kvm.
Sounds ambitious for now.
--b.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-06 20:33 ` J. Bruce Fields
@ 2010-01-07 14:18 ` Jeff Layton
[not found] ` <20100107091832.687cb7eb-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2010-01-07 14:18 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Chuck Lever, steved, linux-nfs
On Wed, 6 Jan 2010 15:33:13 -0500
"J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Wed, Jan 06, 2010 at 03:22:55PM -0500, Chuck Lever wrote:
> > 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.
>
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.
> > 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).
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
[not found] ` <20100107091832.687cb7eb-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
@ 2010-01-08 5:05 ` J. Bruce Fields
2010-01-08 12:03 ` Jeff Layton
2010-01-08 14:51 ` Jeff Layton
0 siblings, 2 replies; 20+ messages in thread
From: J. Bruce Fields @ 2010-01-08 5:05 UTC (permalink / raw)
To: Jeff Layton; +Cc: Chuck Lever, steved, linux-nfs
On Thu, Jan 07, 2010 at 09:18:32AM -0500, Jeff Layton wrote:
> On Wed, 6 Jan 2010 15:33:13 -0500
> "J. Bruce Fields" <bfields@fieldses.org> wrote:
>
> > On Wed, Jan 06, 2010 at 03:22:55PM -0500, Chuck Lever wrote:
> > > 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.
> >
>
> 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.
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.
>
> > > 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).
>
> --
> Jeff Layton <jlayton@redhat.com>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-08 5:05 ` J. Bruce Fields
@ 2010-01-08 12:03 ` Jeff Layton
2010-01-08 14:51 ` Jeff Layton
1 sibling, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2010-01-08 12:03 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Chuck Lever, steved, linux-nfs
On Fri, 8 Jan 2010 00:05:56 -0500
"J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Thu, Jan 07, 2010 at 09:18:32AM -0500, Jeff Layton wrote:
> > On Wed, 6 Jan 2010 15:33:13 -0500
> > "J. Bruce Fields" <bfields@fieldses.org> wrote:
> >
> > > On Wed, Jan 06, 2010 at 03:22:55PM -0500, Chuck Lever wrote:
> > > > 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.
> > >
> >
> > 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.
>
> 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.
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3)
2010-01-08 5:05 ` J. Bruce Fields
2010-01-08 12:03 ` Jeff Layton
@ 2010-01-08 14:51 ` Jeff Layton
1 sibling, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2010-01-08 14:51 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Chuck Lever, steved, linux-nfs
On Fri, 8 Jan 2010 00:05:56 -0500
"J. Bruce Fields" <bfields@fieldses.org> wrote:
> >
> > 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.
>
> 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,
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2010-01-08 14:51 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-05 15:40 [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) Jeff Layton
2010-01-05 15:40 ` [PATCH 1/3] nfs-utils: introduce new statd testing simulator Jeff Layton
2010-01-05 15:40 ` [PATCH 2/3] nfs-utils: add statdb_dump utility Jeff Layton
2010-01-05 16:09 ` Chuck Lever
2010-01-05 19:17 ` Jeff Layton
[not found] ` <20100105141732.4590bcce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-01-05 19:25 ` Chuck Lever
2010-01-05 15:40 ` [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check" Jeff Layton
2010-01-05 16:37 ` Steve Dickson
[not found] ` <4B436AD3.2080107-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-05 18:25 ` Jeff Layton
[not found] ` <20100105132519.02c3c76d-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-01-05 21:29 ` Jeff Layton
2010-01-06 19:17 ` [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) J. Bruce Fields
2010-01-06 19:42 ` Jeff Layton
[not found] ` <20100106144247.18dc10de-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-01-06 19:58 ` J. Bruce Fields
2010-01-06 20:10 ` Jeff Layton
2010-01-06 20:22 ` Chuck Lever
2010-01-06 20:33 ` J. Bruce Fields
2010-01-07 14:18 ` Jeff Layton
[not found] ` <20100107091832.687cb7eb-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2010-01-08 5:05 ` J. Bruce Fields
2010-01-08 12:03 ` Jeff Layton
2010-01-08 14:51 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox