summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-05-28 10:07:37 -0500
committerDavid Teigland <teigland@redhat.com>2015-06-02 11:39:34 -0500
commit7c1f8a9cbcc45f2bacced0651a05414371f8fa06 (patch)
treecec78234cdfd28b19c8f7117510618049143ccaf
parentdecd8234e28a717383400883133761d9931a19e4 (diff)
downloadlvm2-7c1f8a9cbcc45f2bacced0651a05414371f8fa06.tar.gz
test: structure for lvmlockd testing
make check_lvmlockd_sanlock T=shell/sanlock-hello-world.sh will run: shell/sanlock-prepare.sh to prepare sanlock and lvmlockd on the system shell/sanlock-hello-work.sh to test using lvmlockd and sanlock shell/sanlock-remove.sh to undo the things from sanlock-prepare.sh TODO: - use alias vgcreate="vgcreate --lock-type sanlock" in sanlock-prepare so that existing shell tests can just call vgcreate can be used to create and test sanlock vgs. - when using existing shell tests with sanlock, we need prepare_devs/prepare_pvs to create adequately large devs. See the necessity of sanlock-hello-world of specifying a large device size. This is needed for all the ondisk leases that are created by vgcreate. - get check_lvmlockd_dlm working
-rw-r--r--test/Makefile.in30
-rw-r--r--test/lib/aux.sh4
-rw-r--r--test/lib/flavour-udev-lvmlockd-dlm.sh6
-rw-r--r--test/lib/flavour-udev-lvmlockd-sanlock.sh6
-rw-r--r--test/lib/inittest.sh6
-rw-r--r--test/lib/test-corosync-conf19
-rw-r--r--test/lib/test-dlm-conf4
-rw-r--r--test/lib/test-sanlock-conf2
-rw-r--r--test/shell/dlm-prepare.sh94
-rw-r--r--test/shell/dlm-remove.sh21
-rw-r--r--test/shell/sanlock-hello-world.sh25
-rw-r--r--test/shell/sanlock-prepare.sh89
-rw-r--r--test/shell/sanlock-remove.sh28
13 files changed, 334 insertions, 0 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index cd2c42532..bba33dba4 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -70,6 +70,8 @@ help:
@echo " check_cluster Run tests with cluster daemon."
@echo " check_lvmetad Run tests with lvmetad daemon."
@echo " check_lvmpolld Run tests with lvmpolld daemon."
+ @echo " check_lvmlockd_sanlock Run tests with lvmlockd and sanlock."
+ @echo " check_lvmlockd_dlm Run tests with lvmlockd and dlm."
@echo " clean Clean dir."
@echo " help Display callable targets."
@echo -e "\nSupported variables:"
@@ -138,6 +140,32 @@ check_lvmpolld: .tests-stamp
--flavours ndev-lvmpolld,ndev-cluster-lvmpolld,ndev-lvmetad-lvmpolld --only $(T) --skip $(S)
endif
+ifeq ("@BUILD_LVMLOCKD@", "yes")
+check_lvmlockd_sanlock: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours udev-lvmlockd-sanlock --only shell/sanlock-prepare.sh
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours udev-lvmlockd-sanlock --only $(T) --skip $(S)
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours udev-lvmlockd-sanlock --only shell/sanlock-remove.sh
+endif
+
+ifeq ("@BUILD_LVMLOCKD@", "yes")
+check_lvmlockd_dlm: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours udev-lvmlockd-dlm --only shell/dlm-prepare.sh
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours udev-lvmlockd-dlm --only $(T) --skip $(S)
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours udev-lvmlockd-dlm --only shell/dlm-remove.sh
+endif
+
DATADIR = $(datadir)/lvm2-testsuite
EXECDIR = $(libexecdir)/lvm2-testsuite
@@ -153,6 +181,8 @@ LIB_FLAVOURS = \
lib/flavour-udev-lvmetad-lvmpolld\
lib/flavour-udev-lvmetad\
lib/flavour-udev-lvmpolld\
+ lib/flavour-udev-lvmlockd-sanlock\
+ lib/flavour-udev-lvmlockd-dlm\
lib/flavour-udev-vanilla
LIB_LOCAL = lib/paths lib/runner
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 53ebd8acd..55508439f 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -817,6 +817,9 @@ generate_config() {
LVM_TEST_LOCKING=${LVM_TEST_LOCKING:-1}
LVM_TEST_LVMETAD=${LVM_TEST_LVMETAD:-0}
LVM_TEST_LVMPOLLD=${LVM_TEST_LVMPOLLD:-0}
+ LVM_TEST_LVMLOCKD=${LVM_TEST_LVMLOCKD:-0}
+ LVM_TEST_LOCK_TYPE_SANLOCK=${LVM_TEST_LOCK_TYPE_SANLOCK:-0}
+ LVM_TEST_LOCK_TYPE_DLM=${LVM_TEST_LOCK_TYPE_DLM:-0}
if test "$DM_DEV_DIR" = "/dev"; then
LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-0}
else
@@ -859,6 +862,7 @@ global/thin_dump_executable = "$LVM_TEST_THIN_DUMP_CMD"
global/thin_repair_executable = "$LVM_TEST_THIN_REPAIR_CMD"
global/use_lvmetad = $LVM_TEST_LVMETAD
global/use_lvmpolld = $LVM_TEST_LVMPOLLD
+global/use_lvmlockd = $LVM_TEST_LVMLOCKD
log/activation = 1
log/file = "$TESTDIR/debug.log"
log/indent = 1
diff --git a/test/lib/flavour-udev-lvmlockd-dlm.sh b/test/lib/flavour-udev-lvmlockd-dlm.sh
new file mode 100644
index 000000000..5bd274911
--- /dev/null
+++ b/test/lib/flavour-udev-lvmlockd-dlm.sh
@@ -0,0 +1,6 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMETAD=1
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_LVMLOCKD=1
+export LVM_TEST_LOCK_TYPE_DLM=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-lvmlockd-sanlock.sh b/test/lib/flavour-udev-lvmlockd-sanlock.sh
new file mode 100644
index 000000000..859ee2e66
--- /dev/null
+++ b/test/lib/flavour-udev-lvmlockd-sanlock.sh
@@ -0,0 +1,6 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMETAD=1
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_LVMLOCKD=1
+export LVM_TEST_LOCK_TYPE_SANLOCK=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 0b898f39b..656deb22b 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -106,6 +106,12 @@ test -n "$LVM_TEST_LVMPOLLD" && {
aux prepare_lvmpolld
}
+if test -n "$LVM_TEST_LVMLOCKD" ; then
+ if test -n "$LVM_TEST_LOCK_TYPE_SANLOCK" ; then
+ aux lvmconf 'local/host_id = 1'
+ fi
+fi
+
echo "<======== Processing test: \"$TESTNAME\" ========>"
set -vx
diff --git a/test/lib/test-corosync-conf b/test/lib/test-corosync-conf
new file mode 100644
index 000000000..ccc958f1d
--- /dev/null
+++ b/test/lib/test-corosync-conf
@@ -0,0 +1,19 @@
+# created by lvm test suite
+totem {
+ version: 2
+ secauth: off
+ cluster_name: test
+}
+nodelist {
+ node {
+ ring0_addr: @LOCAL_NODE@
+ nodeid: 1
+ }
+}
+quorum {
+ provider: corosync_votequorum
+}
+logging {
+ to_syslog: yes
+}
+
diff --git a/test/lib/test-dlm-conf b/test/lib/test-dlm-conf
new file mode 100644
index 000000000..a93c93fca
--- /dev/null
+++ b/test/lib/test-dlm-conf
@@ -0,0 +1,4 @@
+# created by lvm test suite
+log_debug=1
+enable_fencing=0
+
diff --git a/test/lib/test-sanlock-conf b/test/lib/test-sanlock-conf
new file mode 100644
index 000000000..d1df598b0
--- /dev/null
+++ b/test/lib/test-sanlock-conf
@@ -0,0 +1,2 @@
+# created by lvm test suite
+SANLOCKOPTS="-U sanlock -G sanlock -w 0"
diff --git a/test/shell/dlm-prepare.sh b/test/shell/dlm-prepare.sh
new file mode 100644
index 000000000..825899ffe
--- /dev/null
+++ b/test/shell/dlm-prepare.sh
@@ -0,0 +1,94 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+test_description='Set up things to run tests with dlm'
+
+. lib/utils
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_DLM" ] && skip;
+
+COROSYNC_CONF="/etc/corosync/corosync.conf"
+COROSYNC_NODE=`hostname`
+create_corosync_conf() {
+ if test -a $COROSYNC_CONF; then
+ if ! grep "created by lvm test suite" $COROSYNC_CONF; then
+ rm $COROSYNC_CONF
+ else
+ mv $COROSYNC_CONF $COROSYNC_CONF.prelvmtest
+ fi
+ fi
+
+ sed -e "s/@LOCAL_NODE@/$(COROSYNC_NODE)/" lib/test-corosync-conf > $COROSYNC_CONF
+ echo "created new $COROSYNC_CONF"
+}
+
+DLM_CONF="/etc/dlm/dlm.conf"
+create_dlm_conf() {
+ if test -a $DLM_CONF; then
+ if ! grep "created by lvm test suite" $DLM_CONF; then
+ rm $DLM_CONF
+ else
+ mv $DLM_CONF $DLM_CONF.prelvmtest
+ fi
+ fi
+
+ cp lib/test-dlm-conf $DLM_CONF
+ echo "created new $DLM_CONF"
+}
+
+prepare_lvmlockd_dlm() {
+ if pgrep lvmlockd ; then
+ echo "Cannot run while existing lvmlockd process exists"
+ exit 1
+ fi
+
+ if pgrep dlm_controld ; then
+ echo "Cannot run while existing dlm_controld process exists"
+ exit 1
+ fi
+
+ if pgrep corosync; then
+ echo "Cannot run while existing corosync process exists"
+ exit 1
+ fi
+
+ create_corosync_conf
+ create_dlm_conf
+
+ systemctl start corosync
+ sleep 1
+ if ! pgrep corosync; then
+ echo "Failed to start corosync"
+ exit 1
+ fi
+
+ systemctl start dlm
+ sleep 1
+ if ! pgrep dlm_controld; then
+ echo "Failed to start dlm"
+ exit 1
+ fi
+
+ lvmlockd
+ sleep 1
+ if ! pgrep lvmlockd ; then
+ echo "Failed to start lvmlockd"
+ exit 1
+ fi
+}
+
+prepare_lvmlockd_dlm
+
+# FIXME: make this work
+alias vgcreate="vgcreate --lock-type dlm"
+
+
diff --git a/test/shell/dlm-remove.sh b/test/shell/dlm-remove.sh
new file mode 100644
index 000000000..5151968ae
--- /dev/null
+++ b/test/shell/dlm-remove.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+test_description='Remove the dlm test setup'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_DLM" ] && skip;
+
+# FIXME: reverse prepare_lvmlockd_dlm
+killall dlm_controld
+killall corosync
+
diff --git a/test/shell/sanlock-hello-world.sh b/test/shell/sanlock-hello-world.sh
new file mode 100644
index 000000000..1193f7d29
--- /dev/null
+++ b/test/shell/sanlock-hello-world.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+test_description='Hello world for vgcreate with sanlock'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_SANLOCK" ] && skip;
+
+aux prepare_pvs 1 1024
+
+vgcreate --lock-type sanlock --lock-opt wait $vg "$dev1"
+
+vgs -o+locktype,lockargs $vg
+
+vgremove $vg
+
diff --git a/test/shell/sanlock-prepare.sh b/test/shell/sanlock-prepare.sh
new file mode 100644
index 000000000..4ef88f030
--- /dev/null
+++ b/test/shell/sanlock-prepare.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+test_description='Set up things to run tests with sanlock'
+
+. lib/utils
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_SANLOCK" ] && skip;
+
+SANLOCK_CONF="/etc/sysconfig/sanlock"
+create_sanlock_conf() {
+ if test -a $SANLOCK_CONF; then
+ if ! grep "created by lvm test suite" $SANLOCK_CONF; then
+ rm $SANLOCK_CONF
+ else
+ mv $SANLOCK_CONF $SANLOCK_CONF.prelvmtest
+ fi
+ fi
+
+ cp lib/test-sanlock-conf $SANLOCK_CONF
+ echo "created new $SANLOCK_CONF"
+}
+
+prepare_lvmlockd_sanlock() {
+ if pgrep lvmlockd ; then
+ echo "Cannot run while existing lvmlockd process exists"
+ exit 1
+ fi
+
+ if pgrep sanlock ; then
+ echo "Cannot run while existing sanlock process exists"
+ exit 1
+ fi
+
+ create_sanlock_conf
+
+ # FIXME: use 'systemctl start sanlock' once sysconfig options work
+ sanlock daemon -U sanlock -G sanlock -w 0
+ sleep 1
+ if ! pgrep sanlock; then
+ echo "Failed to start sanlock"
+ exit 1
+ fi
+
+ lvmlockd
+ sleep 1
+ if ! pgrep lvmlockd; then
+ echo "Failed to start lvmlockd"
+ exit 1
+ fi
+}
+
+# Create a device and a VG that are both outside the scope of
+# the standard lvm test suite so that they will not be removed
+# and will remain in place while all the tests are run.
+#
+# Use this VG to hold the sanlock global lock which will be used
+# by lvmlockd during other tests.
+#
+# This script will be run before any standard tests are run.
+# After all the tests are run, another script will be run
+# to remove this VG and device.
+
+GL_DEV="/dev/mapper/GL_DEV"
+GL_FILE="$PWD/gl_file.img"
+rm -f "$GL_FILE"
+dd if=/dev/zero of="$GL_FILE" bs=$((1024*1024)) count=1024 2> /dev/null
+GL_LOOP=$(losetup -f "$GL_FILE" --show)
+echo "0 `blockdev --getsize $GL_LOOP` linear $GL_LOOP 0" | dmsetup create GL_DEV
+
+prepare_lvmlockd_sanlock
+
+vgcreate --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_DEV|", "r|.*|"]}' --lock-type sanlock --lock-gl enable --lock-opt wait glvg $GL_DEV
+
+vgs --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_DEV|", "r|.*|"]}' -o+locktype,lockargs glvg
+
+# FIXME: make this work
+alias vgcreate="vgcreate --lock-type sanlock"
+
+
diff --git a/test/shell/sanlock-remove.sh b/test/shell/sanlock-remove.sh
new file mode 100644
index 000000000..b2f5c2bff
--- /dev/null
+++ b/test/shell/sanlock-remove.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+test_description='Remove the sanlock test setup'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_SANLOCK" ] && skip;
+
+# Removes the VG with the global lock that was created by
+# the corresponding create script.
+
+vgremove --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_DEV|", "r|.*|"]}' glvg
+
+dmsetup remove GL_DEV
+
+# FIXME: reverse prepare_lvmlockd_sanlock
+sanlock shutdown -f 1
+killall lvmlockd
+