All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing.
@ 2009-12-28 19:55 Milan Broz
  0 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2009-12-28 19:55 UTC (permalink / raw)
  To: lvm-devel

This patch introduces simple "cluster" locking, which basically
simulates only one node to allow clvmd running even without any cluster
infrastucture.

The puprose of this patch is to provide very simple testing environment
for cluster locking.
Basically the local locking is now performed from long-running clvmd process.

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 configure.in                |    1 +
 daemons/clvmd/Makefile.in   |    4 +
 daemons/clvmd/clvmd-comms.h |    7 ++
 daemons/clvmd/clvmd-fake.c  |  147 +++++++++++++++++++++++++++++++++++++++++++
 daemons/clvmd/clvmd.c       |   16 +++++-
 5 files changed, 174 insertions(+), 1 deletions(-)
 create mode 100644 daemons/clvmd/clvmd-fake.c

diff --git a/configure.in b/configure.in
index 834fd6e..7bd8fbd 100644
--- a/configure.in
+++ b/configure.in
@@ -342,6 +342,7 @@ AC_ARG_WITH(clvmd,
                            * cman,corosync,openais (or selection of them)
                            * all                   (autodetect)
                            * none                  (disable build)
+                           * fake                  (debugging only)
                           [TYPE=none] ],
   [ CLVMD="$withval" ],
   [ CLVMD="none" ])
diff --git a/daemons/clvmd/Makefile.in b/daemons/clvmd/Makefile.in
index dad568e..04aa6fc 100644
--- a/daemons/clvmd/Makefile.in
+++ b/daemons/clvmd/Makefile.in
@@ -71,6 +71,10 @@ ifneq (,$(findstring corosync,, "@CLVMD@,"))
 	DEFS += -DUSE_COROSYNC
 endif
 
+ifneq (,$(findstring fake,, "@CLVMD@,"))
+	SOURCES += clvmd-fake.c
+	DEFS += -DUSE_FAKE
+endif
 
 TARGETS = \
 	clvmd
diff --git a/daemons/clvmd/clvmd-comms.h b/daemons/clvmd/clvmd-comms.h
index cc5def5..72e3ed2 100644
--- a/daemons/clvmd/clvmd-comms.h
+++ b/daemons/clvmd/clvmd-comms.h
@@ -110,5 +110,12 @@ struct cluster_ops *init_openais_cluster(void);
 struct cluster_ops *init_corosync_cluster(void);
 #endif
 
+#ifdef USE_FAKE
+#  define FAKE_CSID_LEN (sizeof(int))
+#  define MAX_CLUSTER_MEMBER_NAME_LEN       64
+#  define FAKE_MAX_CLUSTER_MESSAGE          65535
+#  define MAX_CSID_LEN sizeof(int)
+struct cluster_ops *init_fake_cluster(void);
+#endif
 
 #endif
diff --git a/daemons/clvmd/clvmd-fake.c b/daemons/clvmd/clvmd-fake.c
new file mode 100644
index 0000000..54da00e
--- /dev/null
+++ b/daemons/clvmd/clvmd-fake.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*
+ * This provides the fake interface for locking manager
+ */
+
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+
+#include <configure.h>
+#include <libdevmapper.h>
+
+#include "locking.h"
+#include "lvm-logging.h"
+#include "clvm.h"
+#include "clvmd-comms.h"
+#include "lvm-functions.h"
+#include "clvmd.h"
+
+static int _init_cluster(void)
+{
+	DEBUGLOG("Connected to fakecluster\n");
+	return 0;
+}
+
+static void _cluster_closedown(void)
+{
+	DEBUGLOG("cluster_closedown\n");
+	destroy_lvhash();
+}
+
+static void _get_our_csid(char *csid)
+{
+	int nodeid = 1;
+	memcpy(csid, &nodeid, sizeof(int));
+}
+
+static int _csid_from_name(char *csid, const char *name)
+{
+	return 1;
+}
+
+static int _name_from_csid(const char *csid, char *name)
+{
+	sprintf(name, "%x", 0xdead);
+	return 0;
+}
+
+static int _get_num_nodes()
+{
+	return 1;
+}
+
+/* Node is now known to be running a clvmd */
+static void _add_up_node(const char *csid)
+{
+}
+
+/* Call a callback for each node, so the caller knows whether it's up or down */
+static int _cluster_do_node_callback(struct local_client *master_client,
+				     void (*callback)(struct local_client *,
+				     const char *csid, int node_up))
+{
+	return 0;
+}
+
+/* Real locking */
+static int _lock_resource(const char *resource, int mode, int flags, int *lockid)
+{
+	DEBUGLOG("lock_resource '%s', flags=%d, mode=%d\n", resource, flags, mode);
+	return 0;
+}
+
+static int _unlock_resource(const char *resource, int lockid)
+{
+	DEBUGLOG("unlock_resource: %s lockid: %x\n", resource, lockid);
+	return 0;
+}
+
+static int _is_quorate()
+{
+	return 1;
+}
+
+static int _get_main_cluster_fd(void)
+{
+	return 1;
+}
+
+static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
+				const char *csid,
+				struct local_client **new_client)
+{
+	return 1;
+}
+
+static int _cluster_send_message(const void *buf, int msglen,
+				 const char *csid,
+				 const char *errtext)
+{
+	return 0;
+}
+
+static int _get_cluster_name(char *buf, int buflen)
+{
+	strncpy(buf, "fakecluster", buflen);
+	return 0;
+}
+
+static struct cluster_ops _cluster_fake_ops = {
+	.cluster_init_completed   = NULL,
+	.cluster_send_message     = _cluster_send_message,
+	.name_from_csid           = _name_from_csid,
+	.csid_from_name           = _csid_from_name,
+	.get_num_nodes            = _get_num_nodes,
+	.cluster_fd_callback      = _cluster_fd_callback,
+	.get_main_cluster_fd      = _get_main_cluster_fd,
+	.cluster_do_node_callback = _cluster_do_node_callback,
+	.is_quorate               = _is_quorate,
+	.get_our_csid             = _get_our_csid,
+	.add_up_node              = _add_up_node,
+	.reread_config            = NULL,
+	.cluster_closedown        = _cluster_closedown,
+	.get_cluster_name         = _get_cluster_name,
+	.sync_lock                = _lock_resource,
+	.sync_unlock              = _unlock_resource,
+};
+
+struct cluster_ops *init_fake_cluster(void)
+{
+	if (!_init_cluster())
+		return &_cluster_fake_ops;
+	else
+		return NULL;
+}
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 08ad9d1..a711e30 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -110,7 +110,7 @@ static int child_pipe[2];
 #define DFAIL_TIMEOUT    5
 #define SUCCESS          0
 
-typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC} if_type_t;
+typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC, IF_FAKE} if_type_t;
 
 typedef void *(lvm_pthread_fn_t)(void*);
 
@@ -180,6 +180,9 @@ static void usage(char *prog, FILE *file)
 #ifdef USE_GULM
 	fprintf(file, "gulm ");
 #endif
+#ifdef USE_FAKE
+	fprintf(file, "fake ");
+#endif
 	fprintf(file, "\n");
 }
 
@@ -434,6 +437,15 @@ int main(int argc, char *argv[])
 			syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to OpenAIS");
 		}
 #endif
+#ifdef USE_FAKE
+	if (!clops)
+		if ((cluster_iface == IF_AUTO || cluster_iface == IF_FAKE) && (clops = init_fake_cluster())) {
+			max_csid_len = FAKE_CSID_LEN;
+			max_cluster_message = FAKE_MAX_CLUSTER_MESSAGE;
+			max_cluster_member_name_len = MAX_CLUSTER_MEMBER_NAME_LEN;
+			syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to FakeCluster");
+		}
+#endif
 
 	if (!clops) {
 		DEBUGLOG("Can't initialise cluster interface\n");
@@ -2063,6 +2075,8 @@ static if_type_t parse_cluster_interface(char *ifname)
 		iface = IF_OPENAIS;
 	if (!strcmp(ifname, "corosync"))
 		iface = IF_COROSYNC;
+	if (!strcmp(ifname, "fake"))
+		iface = IF_FAKE;
 
 	return iface;
 }
-- 
1.6.5.7



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing.
@ 2010-02-22 14:55 Milan Broz
  2010-02-22 14:55 ` [PATCH 2/2] Add cluster-check to provide basic cluster locking (using fake cluster) Milan Broz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Milan Broz @ 2010-02-22 14:55 UTC (permalink / raw)
  To: lvm-devel

This patch introduces simple "cluster" locking, which basically
simulates only one node to allow clvmd running even withou any cluster
infrastucture.

The puprose of this patch is to provide very simple testin environment
for cluster locking.
Basically the locking is performed from long-running clvmd process.

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 configure.in                |    1 +
 daemons/clvmd/Makefile.in   |    4 +
 daemons/clvmd/clvmd-comms.h |    7 ++
 daemons/clvmd/clvmd-fake.c  |  191 +++++++++++++++++++++++++++++++++++++++++++
 daemons/clvmd/clvmd.c       |   16 ++++-
 5 files changed, 218 insertions(+), 1 deletions(-)
 create mode 100644 daemons/clvmd/clvmd-fake.c

diff --git a/configure.in b/configure.in
index aaa21c6..6ea2e33 100644
--- a/configure.in
+++ b/configure.in
@@ -342,6 +342,7 @@ AC_ARG_WITH(clvmd,
                            * cman,corosync,openais (or selection of them)
                            * all                   (autodetect)
                            * none                  (disable build)
+                           * fake                  (debugging only)
                           [TYPE=none] ],
   [ CLVMD="$withval" ],
   [ CLVMD="none" ])
diff --git a/daemons/clvmd/Makefile.in b/daemons/clvmd/Makefile.in
index dad568e..04aa6fc 100644
--- a/daemons/clvmd/Makefile.in
+++ b/daemons/clvmd/Makefile.in
@@ -71,6 +71,10 @@ ifneq (,$(findstring corosync,, "@CLVMD@,"))
 	DEFS += -DUSE_COROSYNC
 endif
 
+ifneq (,$(findstring fake,, "@CLVMD@,"))
+	SOURCES += clvmd-fake.c
+	DEFS += -DUSE_FAKE
+endif
 
 TARGETS = \
 	clvmd
diff --git a/daemons/clvmd/clvmd-comms.h b/daemons/clvmd/clvmd-comms.h
index cc5def5..72e3ed2 100644
--- a/daemons/clvmd/clvmd-comms.h
+++ b/daemons/clvmd/clvmd-comms.h
@@ -110,5 +110,12 @@ struct cluster_ops *init_openais_cluster(void);
 struct cluster_ops *init_corosync_cluster(void);
 #endif
 
+#ifdef USE_FAKE
+#  define FAKE_CSID_LEN (sizeof(int))
+#  define MAX_CLUSTER_MEMBER_NAME_LEN       64
+#  define FAKE_MAX_CLUSTER_MESSAGE          65535
+#  define MAX_CSID_LEN sizeof(int)
+struct cluster_ops *init_fake_cluster(void);
+#endif
 
 #endif
diff --git a/daemons/clvmd/clvmd-fake.c b/daemons/clvmd/clvmd-fake.c
new file mode 100644
index 0000000..4145f6a
--- /dev/null
+++ b/daemons/clvmd/clvmd-fake.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*
+ * This provides the fake interface for locking manager
+ */
+
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+
+#include <netinet/in.h>
+#include <sys/un.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <configure.h>
+#include <libdevmapper.h>
+
+#include "locking.h"
+#include "lvm-logging.h"
+#include "clvm.h"
+#include "clvmd-comms.h"
+#include "lvm-functions.h"
+#include "clvmd.h"
+
+#define SOCKET_PATH     "/fakeclvmd"
+static int listen_fd = -1;
+
+static int init_comms()
+{
+	struct  sockaddr_un addr;
+
+	listen_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+
+	if (listen_fd < 0)
+		return -1;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.sun_family = AF_UNIX;
+	strcpy(addr.sun_path, SOCKET_PATH);
+
+	unlink(SOCKET_PATH);
+	if (bind(listen_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+		DEBUGLOG("Can't bind to port: %s\n", strerror(errno));
+		close(listen_fd);
+		return -1;
+	}
+
+	listen(listen_fd, 5);
+
+	/* Set Close-on-exec */
+	fcntl(listen_fd, F_SETFD, 1);
+
+	return 0;
+}
+
+static int _init_cluster(void)
+{
+	int r;
+
+	r = init_comms();
+	if (r)
+		return r;
+	DEBUGLOG("Connected to fakecluster\n");
+	return 0;
+}
+
+static void _cluster_closedown(void)
+{
+	unlink(SOCKET_PATH);
+	close(listen_fd);
+
+	DEBUGLOG("cluster_closedown\n");
+	destroy_lvhash();
+}
+
+static void _get_our_csid(char *csid)
+{
+	int nodeid = 1;
+	memcpy(csid, &nodeid, sizeof(int));
+}
+
+static int _csid_from_name(char *csid, const char *name)
+{
+	return 1;
+}
+
+static int _name_from_csid(const char *csid, char *name)
+{
+	sprintf(name, "%x", 0xdead);
+	return 0;
+}
+
+static int _get_num_nodes()
+{
+	return 1;
+}
+
+/* Node is now known to be running a clvmd */
+static void _add_up_node(const char *csid)
+{
+}
+
+/* Call a callback for each node, so the caller knows whether it's up or down */
+static int _cluster_do_node_callback(struct local_client *master_client,
+				     void (*callback)(struct local_client *,
+				     const char *csid, int node_up))
+{
+	return 0;
+}
+
+/* Real locking */
+static int _lock_resource(const char *resource, int mode, int flags, int *lockid)
+{
+	DEBUGLOG("lock_resource '%s', flags=%d, mode=%d\n", resource, flags, mode);
+	return 0;
+}
+
+static int _unlock_resource(const char *resource, int lockid)
+{
+	DEBUGLOG("unlock_resource: %s lockid: %x\n", resource, lockid);
+	return 0;
+}
+
+static int _is_quorate()
+{
+	return 1;
+}
+
+static int _get_main_cluster_fd(void)
+{
+	return listen_fd;
+}
+
+static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
+				const char *csid,
+				struct local_client **new_client)
+{
+	return 1;
+}
+
+static int _cluster_send_message(const void *buf, int msglen,
+				 const char *csid,
+				 const char *errtext)
+{
+	return 0;
+}
+
+static int _get_cluster_name(char *buf, int buflen)
+{
+	strncpy(buf, "fakecluster", buflen);
+	return 0;
+}
+
+static struct cluster_ops _cluster_fake_ops = {
+	.cluster_init_completed   = NULL,
+	.cluster_send_message     = _cluster_send_message,
+	.name_from_csid           = _name_from_csid,
+	.csid_from_name           = _csid_from_name,
+	.get_num_nodes            = _get_num_nodes,
+	.cluster_fd_callback      = _cluster_fd_callback,
+	.get_main_cluster_fd      = _get_main_cluster_fd,
+	.cluster_do_node_callback = _cluster_do_node_callback,
+	.is_quorate               = _is_quorate,
+	.get_our_csid             = _get_our_csid,
+	.add_up_node              = _add_up_node,
+	.reread_config            = NULL,
+	.cluster_closedown        = _cluster_closedown,
+	.get_cluster_name         = _get_cluster_name,
+	.sync_lock                = _lock_resource,
+	.sync_unlock              = _unlock_resource,
+};
+
+struct cluster_ops *init_fake_cluster(void)
+{
+	if (!_init_cluster())
+		return &_cluster_fake_ops;
+	else
+		return NULL;
+}
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 9471935..5cca3b4 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -110,7 +110,7 @@ static int child_pipe[2];
 #define DFAIL_TIMEOUT    5
 #define SUCCESS          0
 
-typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC} if_type_t;
+typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC, IF_FAKE} if_type_t;
 
 typedef void *(lvm_pthread_fn_t)(void*);
 
@@ -180,6 +180,9 @@ static void usage(char *prog, FILE *file)
 #ifdef USE_GULM
 	fprintf(file, "gulm ");
 #endif
+#ifdef USE_FAKE
+	fprintf(file, "fake ");
+#endif
 	fprintf(file, "\n");
 }
 
@@ -434,6 +437,15 @@ int main(int argc, char *argv[])
 			syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to OpenAIS");
 		}
 #endif
+#ifdef USE_FAKE
+	if (!clops)
+		if ((cluster_iface == IF_AUTO || cluster_iface == IF_FAKE) && (clops = init_fake_cluster())) {
+			max_csid_len = FAKE_CSID_LEN;
+			max_cluster_message = FAKE_MAX_CLUSTER_MESSAGE;
+			max_cluster_member_name_len = MAX_CLUSTER_MEMBER_NAME_LEN;
+			syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to FakeCluster");
+		}
+#endif
 
 	if (!clops) {
 		DEBUGLOG("Can't initialise cluster interface\n");
@@ -2063,6 +2075,8 @@ static if_type_t parse_cluster_interface(char *ifname)
 		iface = IF_OPENAIS;
 	if (!strcmp(ifname, "corosync"))
 		iface = IF_COROSYNC;
+	if (!strcmp(ifname, "fake"))
+		iface = IF_FAKE;
 
 	return iface;
 }
-- 
1.7.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Add cluster-check to provide basic cluster locking (using fake cluster).
  2010-02-22 14:55 [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
@ 2010-02-22 14:55 ` Milan Broz
  2010-02-22 15:00 ` [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
  2010-02-22 15:11 ` Christine Caulfield
  2 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2010-02-22 14:55 UTC (permalink / raw)
  To: lvm-devel

Every test starts of instance of clvmd, and must properly kill it afterwards.
(This requires to not skip test with simple "exit 200".)

For using "make cluster-check" target the source must be compiled using
configure --with-clvmd=fake --with-cluster=internal ...

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 Makefile.in                             |    5 ++++
 test/Makefile.in                        |    2 +
 test/lvm-utils.sh                       |    3 ++
 test/t-fsadm.sh                         |    2 +-
 test/t-mirror-basic.sh                  |    2 +-
 test/t-mirror-lvconvert-usage.sh        |    2 +-
 test/t-mirror-lvconvert.sh              |    2 +-
 test/t-mirror-names.sh                  |    2 +-
 test/t-mirror-vgreduce-removemissing.sh |    2 +-
 test/t-pool-labels.sh                   |    2 +-
 test/t-pvcreate-operation-md.sh         |   14 +++++-----
 test/t-pvmove-basic.sh                  |    2 +-
 test/t-snapshot-merge.sh                |    4 +-
 test/t-topology-support.sh              |    4 +-
 test/test-utils.sh                      |   38 ++++++++++++++++++++++++++++--
 15 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 556d1ff..d21542a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -86,8 +86,13 @@ all: cscope.out
 endif
 
 check: all
+	$(MAKE) -C test clean
 	$(MAKE) -C test all
 
+cluster-check: all
+	$(MAKE) -C test clean
+	$(MAKE) -C test all LVM_TEST_LOCKING=3
+
 ifneq ("@LCOV@", "")
 .PHONY: lcov-reset lcov lcov-dated
 
diff --git a/test/Makefile.in b/test/Makefile.in
index 7de6f45..13c513a 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -61,6 +61,7 @@ init.sh: $(srcdir)/Makefile.in $(srcdir)/test-utils.sh .bin-dir-stamp bin/not bi
 	echo 'abs_builddir=$(abs_builddir)' >> $@-t
 	echo 'export PATH' >> $@-t
 	echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@-t
+	echo 'export LVM_TEST_LOCKING=$(LVM_TEST_LOCKING)' >> $@-t
 	chmod a-w $@-t
 	mv $@-t $@
 	if test "$(srcdir)" != "."; then cp $(srcdir)/test-utils.sh \
@@ -77,6 +78,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  ln -s ../lvm-wrapper bin/$$i; \
 	done
 	ln -s "$(abs_top_builddir)/tools/dmsetup" bin/dmsetup
+	ln -s "$(abs_top_builddir)/daemons/clvmd/clvmd" bin/clvmd
 	touch $@
 
 lvm-wrapper: Makefile
diff --git a/test/lvm-utils.sh b/test/lvm-utils.sh
index 0aae767..017d874 100644
--- a/test/lvm-utils.sh
+++ b/test/lvm-utils.sh
@@ -12,6 +12,7 @@
 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 export LVM_SUPPRESS_FD_WARNINGS=1
+test -n "$LVM_TEST_LOCKING" || export LVM_TEST_LOCKING=1
 
 ME=$(basename "$0")
 warn() { echo >&2 "$ME: $@"; }
@@ -223,6 +224,8 @@ init_root_dir_()
   }
   global {
     library_dir = "$G_root_/lib"
+    locking_type = $LVM_TEST_LOCKING
+    fallback_to_local_locking = 0
   }
   activation {
     udev_sync = 1
diff --git a/test/t-fsadm.sh b/test/t-fsadm.sh
index 421ec6b..25367dd 100644
--- a/test/t-fsadm.sh
+++ b/test/t-fsadm.sh
@@ -11,7 +11,7 @@
 
 . ./test-utils.sh
 
-exit 200
+skip_test
 # doesn't work right now
 aux prepare_pvs 2
 aux pvcreate --metadatacopies 0 $dev1
diff --git a/test/t-mirror-basic.sh b/test/t-mirror-basic.sh
index 9c3efc4..3a641cc 100755
--- a/test/t-mirror-basic.sh
+++ b/test/t-mirror-basic.sh
@@ -14,7 +14,7 @@ test_description="ensure that basic operations on mirrored LV works"
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 # ---------------------------------------------------------------------
 # Utilities
diff --git a/test/t-mirror-lvconvert-usage.sh b/test/t-mirror-lvconvert-usage.sh
index d27c1b3..f8322a1 100644
--- a/test/t-mirror-lvconvert-usage.sh
+++ b/test/t-mirror-lvconvert-usage.sh
@@ -10,7 +10,7 @@
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 aux prepare_vg 5
 
diff --git a/test/t-mirror-lvconvert.sh b/test/t-mirror-lvconvert.sh
index 6d47ab4..10a1c2f 100755
--- a/test/t-mirror-lvconvert.sh
+++ b/test/t-mirror-lvconvert.sh
@@ -11,7 +11,7 @@
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 mimages_are_redundant_ ()
 {
diff --git a/test/t-mirror-names.sh b/test/t-mirror-names.sh
index edf9fd7..b3178e8 100644
--- a/test/t-mirror-names.sh
+++ b/test/t-mirror-names.sh
@@ -14,7 +14,7 @@ test_description="check namings of mirrored LV"
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 # ---------------------------------------------------------------------
 # Utilities
diff --git a/test/t-mirror-vgreduce-removemissing.sh b/test/t-mirror-vgreduce-removemissing.sh
index efd6b5d..3ddb41c 100755
--- a/test/t-mirror-vgreduce-removemissing.sh
+++ b/test/t-mirror-vgreduce-removemissing.sh
@@ -13,7 +13,7 @@ test_description="ensure that 'vgreduce --removemissing' works on mirrored LV"
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 lv_is_on_ ()
 {
diff --git a/test/t-pool-labels.sh b/test/t-pool-labels.sh
index 57f4f9a..cc202f5 100755
--- a/test/t-pool-labels.sh
+++ b/test/t-pool-labels.sh
@@ -20,7 +20,7 @@ create_pool_label_()
   env printf "\x04\x01\x03\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x0$1\x68\x01\x16\x70\x00\x00\x00\x00\x00\x06\x5f\xd0" | dd of=$2 bs=273 seek=1 conv=notrunc
 }
 
-env printf "" || exit 200 # skip if printf is not available
+env printf "" || skip_test # skip if printf is not available
 
 aux prepare_devs 2
 
diff --git a/test/t-pvcreate-operation-md.sh b/test/t-pvcreate-operation-md.sh
index 6c32ee6..f73a7eb 100644
--- a/test/t-pvcreate-operation-md.sh
+++ b/test/t-pvcreate-operation-md.sh
@@ -9,14 +9,14 @@
 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 # skip this test if mdadm or sfdisk (or others) aren't available
-which mdadm || exit 200
-which sfdisk || exit 200
-which perl || exit 200
-which awk || exit 200
-which cut || exit 200
+which mdadm || skip_test
+which sfdisk || skip_test
+which perl || skip_test
+which awk || skip_test
+which cut || skip_test
 
 test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
-modprobe raid0 || exit 200
+modprobe raid0 || skip_test
 
 . ./test-utils.sh
 
@@ -45,7 +45,7 @@ cleanup_md() {
 }
 
 # create 2 disk MD raid0 array (stripe_width=128K)
-[ -b "$mddev" ] && exit 200
+[ -b "$mddev" ] && skip_test
 mdadm --create $mddev --auto=md --level 0 --raid-devices=2 --chunk 64 $dev1 $dev2
 trap 'aux cleanup_md' EXIT # cleanup this MD device at the end of the test
 
diff --git a/test/t-pvmove-basic.sh b/test/t-pvmove-basic.sh
index 5070b72..ebd5661 100755
--- a/test/t-pvmove-basic.sh
+++ b/test/t-pvmove-basic.sh
@@ -14,7 +14,7 @@ test_description="ensure that pvmove works with basic options"
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 # ---------------------------------------------------------------------
 # Utilities
diff --git a/test/t-snapshot-merge.sh b/test/t-snapshot-merge.sh
index 9d953cf..2015505 100755
--- a/test/t-snapshot-merge.sh
+++ b/test/t-snapshot-merge.sh
@@ -10,7 +10,7 @@
 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 set -xv
 
-which mkfs.ext3 || exit 200
+which mkfs.ext3 || skip_test
 
 . ./test-utils.sh
 
@@ -48,7 +48,7 @@ aux prepare_vg 1 100
 setup_merge $vg $lv1
 
 # now that snapshot LV is created: test if snapshot-merge target is available
-$(dmsetup targets | grep -q snapshot-merge) || exit 200
+$(dmsetup targets | grep -q snapshot-merge) || skip_test
 
 lvs -a
 lvconvert --merge $vg/$(snap_lv_name_ $lv1)
diff --git a/test/t-topology-support.sh b/test/t-topology-support.sh
index 27ea4f7..f6b4b1e 100644
--- a/test/t-topology-support.sh
+++ b/test/t-topology-support.sh
@@ -8,12 +8,12 @@
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-which mkfs.ext3 || exit 200
+which mkfs.ext3 || skip_test
 
 # Get linux minor version
 linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1)
 
-test $linux_minor -ge 31 || exit 200
+test $linux_minor -ge 31 || skip_test
 
 . ./test-utils.sh
 
diff --git a/test/test-utils.sh b/test/test-utils.sh
index 6606c56..e13b5b4 100644
--- a/test/test-utils.sh
+++ b/test/test-utils.sh
@@ -17,6 +17,25 @@ aux() {
 	#"$@"
 }
 
+prepare_clvmd() {
+	if test "$LVM_TEST_LOCKING" -ne 3 ; then
+		return 0
+	fi
+
+	if pgrep clvmd ; then
+		return 1
+	fi
+
+	clvmd -Ifake -d 1 >clvmd.log 2>&1 &
+}
+
+stop_clvmd() {
+	if test "$LVM_TEST_LOCKING" -eq 3 ; then
+		pkill -9 clvmd
+		sleep 1
+	fi
+}
+
 STACKTRACE() {
 	trap - ERR;
 	i=0;
@@ -65,14 +84,22 @@ teardown() {
 		test -n "$LOOPFILE" && rm -f $LOOPFILE
 	fi
 	unset devs # devs is set in prepare_devs()
+	return 0
 }
 
 teardown_() {
+	stop_clvmd
 	teardown
 	cleanup_ # user-overridable cleanup
 	testlib_cleanup_ # call test-lib cleanup routine, too
 }
 
+skip_test() {
+	trap - exit
+	teardown_
+	exit 200
+}
+
 make_ioerror() {
 	echo 0 10000000 error | dmsetup create ioerror
 	ln -s $G_dev_/mapper/ioerror $G_dev_/ioerror
@@ -83,9 +110,6 @@ prepare_loop() {
 	test -n "$size" || size=32
 
 	test -n "$LOOP" && return 0
-	trap 'aux teardown_' EXIT # don't forget to clean up
-	trap 'set +vex; STACKTRACE; set -vex' ERR
-	#trap - ERR
 
 	LOOPFILE="$PWD/test.img"
 	dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=1 seek=$(($size-1))
@@ -294,6 +318,8 @@ prepare_lvmconf() {
     abort_on_internal_errors = 1
     library_dir = "$G_root_/lib"
     locking_dir = "$G_root_/var/lock/lvm"
+    locking_type = $LVM_TEST_LOCKING
+    fallback_to_local_locking = 0
   }
   activation {
     udev_sync = 1
@@ -304,4 +330,10 @@ EOF
 
 set -vexE -o pipefail
 aux prepare_lvmconf
+aux prepare_clvmd || {
+	echo "Cannot use fake cluster locking with real clvmd running."
+	exit 200
+}
+trap 'aux teardown_' EXIT # don't forget to clean up
+trap 'set +vex; STACKTRACE; set -vex' ERR
 
-- 
1.7.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing.
  2010-02-22 14:55 [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
  2010-02-22 14:55 ` [PATCH 2/2] Add cluster-check to provide basic cluster locking (using fake cluster) Milan Broz
@ 2010-02-22 15:00 ` Milan Broz
  2010-02-22 15:11 ` Christine Caulfield
  2 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2010-02-22 15:00 UTC (permalink / raw)
  To: lvm-devel

On 02/22/2010 03:55 PM, Milan Broz wrote:
> This patch introduces simple "cluster" locking, which basically

(beware: still not finished, it is more like cluster aware no-locking,
but useful for some testing for now.)

Milan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing.
  2010-02-22 14:55 [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
  2010-02-22 14:55 ` [PATCH 2/2] Add cluster-check to provide basic cluster locking (using fake cluster) Milan Broz
  2010-02-22 15:00 ` [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
@ 2010-02-22 15:11 ` Christine Caulfield
  2 siblings, 0 replies; 5+ messages in thread
From: Christine Caulfield @ 2010-02-22 15:11 UTC (permalink / raw)
  To: lvm-devel

On 22/02/10 14:55, Milan Broz wrote:
> This patch introduces simple "cluster" locking, which basically
> simulates only one node to allow clvmd running even withou any cluster
> infrastucture.
>
> The puprose of this patch is to provide very simple testin environment
> for cluster locking.
> Basically the locking is performed from long-running clvmd process.
>
> Signed-off-by: Milan Broz<mbroz@redhat.com>
> ---
>   configure.in                |    1 +
>   daemons/clvmd/Makefile.in   |    4 +
>   daemons/clvmd/clvmd-comms.h |    7 ++
>   daemons/clvmd/clvmd-fake.c  |  191 +++++++++++++++++++++++++++++++++++++++++++
>   daemons/clvmd/clvmd.c       |   16 ++++-
>   5 files changed, 218 insertions(+), 1 deletions(-)
>   create mode 100644 daemons/clvmd/clvmd-fake.c
>


> +static int init_comms()
> +{
> +	struct  sockaddr_un addr;
> +
> +	listen_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
> +
> +	if (listen_fd<  0)
> +		return -1;
> +
> +	memset(&addr, 0, sizeof(addr));
> +	addr.sun_family = AF_UNIX;
> +	strcpy(addr.sun_path, SOCKET_PATH);
> +
> +	unlink(SOCKET_PATH);
> +	if (bind(listen_fd, (struct sockaddr *)&addr, sizeof(addr))<  0) {
> +		DEBUGLOG("Can't bind to port: %s\n", strerror(errno));
> +		close(listen_fd);
> +		return -1;
> +	}
> +
> +	listen(listen_fd, 5);
> +
> +	/* Set Close-on-exec */
> +	fcntl(listen_fd, F_SETFD, 1);
> +
> +	return 0;


If you only need a a dummy FD then you might as well use /dev/null 
rather than opening a real socket.


> +#ifdef USE_FAKE
> +	if (!clops)
> +		if ((cluster_iface == IF_AUTO || cluster_iface == IF_FAKE)&&  (clops = init_fake_cluster())) {
> +			max_csid_len = FAKE_CSID_LEN;
> +			max_cluster_message = FAKE_MAX_CLUSTER_MESSAGE;
> +			max_cluster_member_name_len = MAX_CLUSTER_MEMBER_NAME_LEN;
> +			syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to FakeCluster");
> +		}
> +#endif
>

Please don't add it to the auto-detect list, that will only cause 
confusion. Only enable fake if it's specified on the command-line.

Chrissie



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-22 15:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-22 14:55 [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
2010-02-22 14:55 ` [PATCH 2/2] Add cluster-check to provide basic cluster locking (using fake cluster) Milan Broz
2010-02-22 15:00 ` [PATCH 1/2] Add "fake" cluster locking (local locking performed in clvmd) for testing Milan Broz
2010-02-22 15:11 ` Christine Caulfield
  -- strict thread matches above, loose matches on Subject: below --
2009-12-28 19:55 Milan Broz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.