Skip to contentSkip to conversation

Add "fake" cluster locking (local locking performed in clvmd) for testing.

PATCH New Milan Broz 1 participant 2 messages Dec 28, 2009 Kbuild

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/2 Add "fake" cluster locking (local locking performed in clvmd) for testing.

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.

---
 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
configure.in +1 -0
index 834fd6e..7bd8fbd 100644
@@ -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" ])
daemons/clvmd/Makefile.in +4 -0
index dad568e..04aa6fc 100644
@@ -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
daemons/clvmd/clvmd-comms.h +7 -0
index cc5def5..72e3ed2 100644
@@ -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
daemons/clvmd/clvmd-fake.c new file +147 -0

147 lines not on this page · raw message

daemons/clvmd/clvmd.c +15 -1
index 08ad9d1..a711e30 100644
@@ -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;
 }
Signature · 1 line
1.6.5.7
author
#1 lore raw

PATCH 2/2 Add cluster-check to provide basic cluster locking (using fake cluster).

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

---
 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/test-utils.sh                      |   41 +++++++++++++++++++++++++++----
 13 files changed, 61 insertions(+), 20 deletions(-)
Makefile.in +5 -0
index 556d1ff..d21542a 100644
@@ -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
 
test/Makefile.in +2 -0
index 75366fd..5bf6b75 100644
@@ -56,6 +56,7 @@ init.sh: $(srcdir)/Makefile.in $(srcdir)/test-utils.sh .bin-dir-stamp bin/not bi
 	echo 'abs_srcdir=$(abs_srcdir)' >> $@-t
 	echo 'abs_builddir=$(abs_builddir)' >> $@-t
 	echo 'export PATH' >> $@-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 \
@@ -72,6 +73,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
test/lvm-utils.sh +3 -0
index 5ad8872..8d2a4e9 100644
@@ -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: $@"; }
@@ -201,6 +202,8 @@ init_root_dir_()
   }
   global {
     library_dir = "$G_root_/lib"
+    locking_type = $LVM_TEST_LOCKING
+    fallback_to_local_locking = 0
   }
 EOF
 }
test/t-fsadm.sh +1 -1
index 421ec6b..25367dd 100644
@@ -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
test/t-mirror-basic.sh +1 -1
index a68007c..a7c4592 100755
@@ -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
test/t-mirror-lvconvert-usage.sh +1 -1
index d27c1b3..f8322a1 100644
@@ -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
 
test/t-mirror-lvconvert.sh +1 -1
index e223d2b..914fefc 100755
@@ -11,7 +11,7 @@
 
 . ./test-utils.sh
 
-dmsetup_has_dm_devdir_support_ || exit 200
+dmsetup_has_dm_devdir_support_ || skip_test
 
 mimages_are_redundant_ ()
 {
test/t-mirror-names.sh +1 -1
index b73fd25..5165502 100644
@@ -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
test/t-mirror-vgreduce-removemissing.sh +1 -1
index efd6b5d..3ddb41c 100755
@@ -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_ ()
 {
test/t-pool-labels.sh +1 -1
index 57f4f9a..cc202f5 100755
@@ -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
 
test/t-pvcreate-operation-md.sh +7 -7
index 42895a1..382700d 100644
@@ -9,12 +9,12 @@
 # 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
-test -f /proc/mdstat || 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 || skip_test
 
 . ./test-utils.sh
 
@@ -43,7 +43,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
 
test/t-pvmove-basic.sh +1 -1
index 5070b72..ebd5661 100755
@@ -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
test/test-utils.sh +36 -5

82 lines not on this page · raw message

Signature · 1 line
1.6.5.7