summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authorOndrej Kozina <okozina@redhat.com>2015-05-09 00:59:18 +0100
committerAlasdair G Kergon <agk@redhat.com>2015-05-09 00:59:18 +0100
commite587b0677b705786a78f21bac1966621f70b2752 (patch)
treee3c742e63c7e2146866a7eadaa39cfd54cb5914e /test/lib
parentbe23fae488b7df19147259d3e8505fc8301076cd (diff)
downloadlvm2-e587b0677b705786a78f21bac1966621f70b2752.tar.gz
lvmpolld: Add standalone polldaemon.
See doc/lvmpolld_overview.txt
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/aux.sh100
-rw-r--r--test/lib/flavour-ndev-cluster-lvmpolld.sh2
-rw-r--r--test/lib/flavour-ndev-lvmetad-lvmpolld.sh3
-rw-r--r--test/lib/flavour-ndev-lvmpolld.sh2
-rw-r--r--test/lib/flavour-udev-cluster-lvmpolld.sh3
-rw-r--r--test/lib/flavour-udev-lvmetad-lvmpolld.sh4
-rw-r--r--test/lib/flavour-udev-lvmpolld.sh3
-rw-r--r--test/lib/inittest.sh7
8 files changed, 117 insertions, 7 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index d1d38f8bb..cb0fe4fca 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -136,6 +136,47 @@ notify_lvmetad() {
fi
}
+prepare_lvmpolld() {
+ set -x
+ rm -f debug.log
+ # skip if we don't have our own lvmpolld...
+ (which lvmpolld 2>/dev/null | grep "$abs_builddir") || skip
+
+ lvmconf "global/use_lvmpolld = 1"
+
+ local run_valgrind=
+ test "${LVM_VALGRIND_LVMPOLLD:-0}" -eq 0 || run_valgrind="run_valgrind"
+
+ kill_sleep_kill_ LOCAL_LVMPOLLD ${LVM_VALGRIND_LVMPOLLD:-0}
+
+ echo "preparing lvmpolld..."
+ $run_valgrind lvmpolld -f "$@" -s "$TESTDIR/lvmpolld.socket" -B "$TESTDIR/lib/lvm" -l all &
+ echo $! > LOCAL_LVMPOLLD
+ while ! test -e "$TESTDIR/lvmpolld.socket"; do echo -n .; sleep .1; done # wait for the socket
+ echo ok
+}
+
+lvmpolld_talk() {
+ local use=nc
+ if type -p socat >& /dev/null; then
+ use=socat
+ elif echo | not nc -U "$TESTDIR/lvmpolld.socket" ; then
+ echo "WARNING: Neither socat nor nc -U seems to be available." 1>&2
+ echo "# failed to contact lvmpolld"
+ return 1
+ fi
+
+ if test "$use" = nc ; then
+ nc -U "$TESTDIR/lvmpolld.socket"
+ else
+ socat "unix-connect:$TESTDIR/lvmpolld.socket" -
+ fi | tee -a lvmpolld-talk.txt
+}
+
+lvmpolld_dump() {
+ (echo 'request="dump"'; echo '##') | lvmpolld_talk "$@"
+}
+
teardown_devs_prefixed() {
local prefix=$1
local stray=${2:-0}
@@ -286,6 +327,10 @@ teardown() {
$vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log strace.log
}
+ kill_sleep_kill_ LOCAL_LVMPOLLD ${LVM_VALGRIND_LVMPOLLD:-0}
+
+ echo -n .
+
kill_sleep_kill_ LOCAL_CLVMD ${LVM_VALGRIND_CLVMD:-0}
echo -n .
@@ -1094,16 +1139,57 @@ dmsetup_wrapped() {
dmsetup "$@"
}
+awk_parse_init_count_in_lvmpolld_dump() {
+ printf '%s' \
+ \
+ $'BEGINFILE { x=0; answ=0; FS="="; key="[[:space:]]*"vkey }' \
+ $'{' \
+ $'if (/.*{$/) { x++ }' \
+ $'else if (/.*}$/) { x-- }' \
+ $'else if ( x == 2 && $1 ~ key) { value=substr($2, 2); value=substr(value, 1, length(value) - 1); }' \
+ $'if ( x == 2 && value == vvalue && $1 ~ /[[:space:]]*init_requests_count/) { answ=$2 }' \
+ $'if (answ > 0) { exit 0 }' \
+ $'}' \
+ $'END { printf "%d", answ }'
+}
+
+check_lvmpolld_init_rq_count() {
+ local ret=$(awk -v vvalue="$2" -v vkey=${3:-lvname} "$(awk_parse_init_count_in_lvmpolld_dump)" lvmpolld_dump.txt)
+ test $ret -eq $1 || {
+ echo "check_lvmpolld_init_rq_count failed. Expected $1, got $ret"
+ return 1
+ }
+}
+
wait_pvmove_lv_ready() {
# given sleep .1 this is about 60 secs of waiting
local retries=${2:-300}
- while : ; do
- test $retries -le 0 && die "Waiting for pvmove LV to get activated has timed out"
- dmsetup info -c -o tables_loaded $1 > out 2>/dev/null|| true;
- not grep Live out >/dev/null || break
- sleep .1
- retries=$((retries-1))
- done
+
+ if [ -e LOCAL_LVMPOLLD ]; then
+ local lvid
+ while : ; do
+ test $retries -le 0 && die "Waiting for lvmpolld timed out"
+ test -n "$lvid" || {
+ lvid=$(get lv_field ${1//-/\/} vg_uuid,lv_uuid -a 2>/dev/null)
+ lvid=${lvid//\ /}
+ lvid=${lvid//-/}
+ }
+ test -z "$lvid" || {
+ lvmpolld_dump > lvmpolld_dump.txt
+ ! check_lvmpolld_init_rq_count 1 $lvid lvid || break;
+ }
+ sleep .1
+ retries=$((retries-1))
+ done
+ else
+ while : ; do
+ test $retries -le 0 && die "Waiting for pvmove LV to get activated has timed out"
+ dmsetup info -c -o tables_loaded $1 > out 2>/dev/null|| true;
+ not grep Live out >/dev/null || break
+ sleep .1
+ retries=$((retries-1))
+ done
+ fi
}
# return total memory size in kB units
diff --git a/test/lib/flavour-ndev-cluster-lvmpolld.sh b/test/lib/flavour-ndev-cluster-lvmpolld.sh
new file mode 100644
index 000000000..fe31bb4a9
--- /dev/null
+++ b/test/lib/flavour-ndev-cluster-lvmpolld.sh
@@ -0,0 +1,2 @@
+export LVM_TEST_LOCKING=3
+export LVM_TEST_LVMPOLLD=1
diff --git a/test/lib/flavour-ndev-lvmetad-lvmpolld.sh b/test/lib/flavour-ndev-lvmetad-lvmpolld.sh
new file mode 100644
index 000000000..496b3bcff
--- /dev/null
+++ b/test/lib/flavour-ndev-lvmetad-lvmpolld.sh
@@ -0,0 +1,3 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMETAD=1
+export LVM_TEST_LVMPOLLD=1
diff --git a/test/lib/flavour-ndev-lvmpolld.sh b/test/lib/flavour-ndev-lvmpolld.sh
new file mode 100644
index 000000000..0a7070308
--- /dev/null
+++ b/test/lib/flavour-ndev-lvmpolld.sh
@@ -0,0 +1,2 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMPOLLD=1
diff --git a/test/lib/flavour-udev-cluster-lvmpolld.sh b/test/lib/flavour-udev-cluster-lvmpolld.sh
new file mode 100644
index 000000000..abf76e9af
--- /dev/null
+++ b/test/lib/flavour-udev-cluster-lvmpolld.sh
@@ -0,0 +1,3 @@
+export LVM_TEST_LOCKING=3
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-lvmetad-lvmpolld.sh b/test/lib/flavour-udev-lvmetad-lvmpolld.sh
new file mode 100644
index 000000000..64253d1fa
--- /dev/null
+++ b/test/lib/flavour-udev-lvmetad-lvmpolld.sh
@@ -0,0 +1,4 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMETAD=1
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-lvmpolld.sh b/test/lib/flavour-udev-lvmpolld.sh
new file mode 100644
index 000000000..c7f40b5a8
--- /dev/null
+++ b/test/lib/flavour-udev-lvmpolld.sh
@@ -0,0 +1,3 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index cd6471c05..1af050338 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -100,6 +100,13 @@ else
aux prepare_clvmd
fi
+echo "LVM_TEST_LVMPOLLD=$LVM_TEST_LVMPOLLD"
+test -n "$LVM_TEST_LVMPOLLD" && {
+ export LVM_LVMPOLLD_SOCKET="$TESTDIR/lvmpolld.socket"
+ export LVM_LVMPOLLD_PIDFILE="$TESTDIR/lvmpolld.pid"
+ aux prepare_lvmpolld
+}
+
echo "<======== Processing test: \"$TESTNAME\" ========>"
set -vx