mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
tests: aux.sh common pattern for starting daemons
This commit is contained in:
parent
4fc0166ca9
commit
f612fdd1dd
@ -21,6 +21,14 @@ expect_failure() {
|
|||||||
echo "TEST EXPECT FAILURE"
|
echo "TEST EXPECT FAILURE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_daemon_in_builddir() {
|
||||||
|
# skip if we don't have our own deamon...
|
||||||
|
if test -z "${installed_testsuite+varset}"; then
|
||||||
|
(which "$1" 2>/dev/null | grep -q "$abs_builddir") || skip "$1 is not in executed path."
|
||||||
|
fi
|
||||||
|
rm -f debug.log strace.log
|
||||||
|
}
|
||||||
|
|
||||||
create_corosync_conf() {
|
create_corosync_conf() {
|
||||||
COROSYNC_CONF="/etc/corosync/corosync.conf"
|
COROSYNC_CONF="/etc/corosync/corosync.conf"
|
||||||
COROSYNC_NODE=$(hostname)
|
COROSYNC_NODE=$(hostname)
|
||||||
@ -147,89 +155,84 @@ prepare_lvmlockd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare_clvmd() {
|
prepare_clvmd() {
|
||||||
rm -f debug.log strace.log
|
|
||||||
test "${LVM_TEST_LOCKING:-0}" -ne 3 && return # not needed
|
test "${LVM_TEST_LOCKING:-0}" -ne 3 && return # not needed
|
||||||
|
|
||||||
if pgrep clvmd ; then
|
if pgrep clvmd ; then
|
||||||
echo "Cannot use fake cluster locking with real clvmd ($(pgrep clvmd)) running."
|
skip "Cannot use fake cluster locking with real clvmd ($(pgrep clvmd)) running."
|
||||||
skip
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# skip if we don't have our own clvmd...
|
check_daemon_in_builddir clvmd
|
||||||
if test -z "${installed_testsuite+varset}"; then
|
|
||||||
(which clvmd 2>/dev/null | grep -q "$abs_builddir") || skip
|
|
||||||
fi
|
|
||||||
|
|
||||||
test -e "$DM_DEV_DIR/control" || dmsetup table >/dev/null # create control node
|
test -e "$DM_DEV_DIR/control" || dmsetup table >/dev/null # create control node
|
||||||
# skip if singlenode is not compiled in
|
# skip if singlenode is not compiled in
|
||||||
(clvmd --help 2>&1 | grep "Available cluster managers" | grep -q "singlenode") || skip
|
(clvmd --help 2>&1 | grep "Available cluster managers" | grep -q "singlenode") || \
|
||||||
|
skip "Compiled clvmd does not support singlenode for testing."
|
||||||
|
|
||||||
# lvmconf "activation/monitoring = 1"
|
# lvmconf "activation/monitoring = 1"
|
||||||
local run_valgrind=
|
local run_valgrind=""
|
||||||
test "${LVM_VALGRIND_CLVMD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
test "${LVM_VALGRIND_CLVMD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
||||||
rm -f "$CLVMD_PIDFILE"
|
rm -f "$CLVMD_PIDFILE"
|
||||||
echo "<======== Starting CLVMD ========>"
|
echo "<======== Starting CLVMD ========>"
|
||||||
|
echo -n "## preparing clvmd..."
|
||||||
# lvs is executed from clvmd - use our version
|
# lvs is executed from clvmd - use our version
|
||||||
LVM_LOG_FILE_EPOCH=CLVMD LVM_LOG_FILE_MAX_LINES=1000000 LVM_BINARY=$(which lvm) $run_valgrind clvmd -Isinglenode -d 1 -f &
|
LVM_LOG_FILE_EPOCH=CLVMD LVM_LOG_FILE_MAX_LINES=1000000 LVM_BINARY=$(which lvm) $run_valgrind clvmd -Isinglenode -d 1 -f &
|
||||||
echo $! > LOCAL_CLVMD
|
echo $! > LOCAL_CLVMD
|
||||||
|
|
||||||
for i in {1..100} ; do
|
for i in {1..100} ; do
|
||||||
test $i -eq 100 && die "Startup of clvmd is too slow."
|
test "$i" -eq 100 && die "Startup of clvmd is too slow."
|
||||||
test -e "$CLVMD_PIDFILE" -a -e "${CLVMD_PIDFILE%/*}/lvm/clvmd.sock" && break
|
test -e "$CLVMD_PIDFILE" && test -e "${CLVMD_PIDFILE%/*}/lvm/clvmd.sock" && break
|
||||||
sleep .2
|
echo -n .
|
||||||
|
sleep .1
|
||||||
done
|
done
|
||||||
|
echo ok
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_dmeventd() {
|
prepare_dmeventd() {
|
||||||
rm -f debug.log strace.log
|
|
||||||
if pgrep dmeventd ; then
|
if pgrep dmeventd ; then
|
||||||
echo "Cannot test dmeventd with real dmeventd ($(pgrep dmeventd)) running."
|
skip "Cannot test dmeventd with real dmeventd ($(pgrep dmeventd)) running."
|
||||||
skip
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# skip if we don't have our own dmeventd...
|
check_daemon_in_builddir dmeventd
|
||||||
if test -z "${installed_testsuite+varset}"; then
|
|
||||||
(which dmeventd 2>/dev/null | grep -q "$abs_builddir") || skip
|
|
||||||
fi
|
|
||||||
lvmconf "activation/monitoring = 1"
|
lvmconf "activation/monitoring = 1"
|
||||||
|
|
||||||
local run_valgrind=
|
local run_valgrind
|
||||||
test "${LVM_VALGRIND_DMEVENTD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
test "${LVM_VALGRIND_DMEVENTD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
||||||
|
echo -n "## preparing dmeventd..."
|
||||||
# LVM_LOG_FILE_EPOCH=DMEVENTD $run_valgrind dmeventd -fddddl "$@" 2>&1 &
|
# LVM_LOG_FILE_EPOCH=DMEVENTD $run_valgrind dmeventd -fddddl "$@" 2>&1 &
|
||||||
LVM_LOG_FILE_EPOCH=DMEVENTD $run_valgrind dmeventd -fddddl "$@" >debug.log_DMEVENTD_out 2>&1 &
|
LVM_LOG_FILE_EPOCH=DMEVENTD $run_valgrind dmeventd -fddddl "$@" >debug.log_DMEVENTD_out 2>&1 &
|
||||||
echo $! > LOCAL_DMEVENTD
|
echo $! > LOCAL_DMEVENTD
|
||||||
|
|
||||||
# FIXME wait for pipe in /var/run instead
|
# FIXME wait for pipe in /var/run instead
|
||||||
for i in {1..100} ; do
|
for i in {1..100} ; do
|
||||||
test $i -eq 100 && die "Startup of dmeventd is too slow."
|
test "$i" -eq 100 && die "Startup of dmeventd is too slow."
|
||||||
test -e "${DMEVENTD_PIDFILE}" && break
|
test -e "${DMEVENTD_PIDFILE}" && break
|
||||||
sleep .2
|
echo -n .
|
||||||
|
sleep .1
|
||||||
done
|
done
|
||||||
echo ok
|
echo ok
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_lvmetad() {
|
prepare_lvmetad() {
|
||||||
rm -f debug.log strace.log
|
check_daemon_in_builddir lvmetad
|
||||||
# skip if we don't have our own lvmetad...
|
|
||||||
if test -z "${installed_testsuite+varset}"; then
|
|
||||||
(which lvmetad 2>/dev/null | grep -q "$abs_builddir") || skip
|
|
||||||
fi
|
|
||||||
|
|
||||||
local run_valgrind=
|
local run_valgrind
|
||||||
test "${LVM_VALGRIND_LVMETAD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
test "${LVM_VALGRIND_LVMETAD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
||||||
|
|
||||||
kill_sleep_kill_ LOCAL_LVMETAD "${LVM_VALGRIND_LVMETAD:-0}"
|
kill_sleep_kill_ LOCAL_LVMETAD "${LVM_VALGRIND_LVMETAD:-0}"
|
||||||
|
|
||||||
# Avoid reconfiguring, if already set to use_lvmetad
|
lvmconf "global/use_lvmetad = 1" "devices/md_component_detection = 0"
|
||||||
(grep use_lvmetad CONFIG_VALUES 2>/dev/null | tail -n 1 | grep -q 1) || \
|
|
||||||
aux lvmconf "global/use_lvmetad = 1" "devices/md_component_detection = 0"
|
|
||||||
# Default debug is "-l all" and could be override
|
# Default debug is "-l all" and could be override
|
||||||
# by setting LVM_TEST_LVMETAD_DEBUG_OPTS before calling inittest.
|
# by setting LVM_TEST_LVMETAD_DEBUG_OPTS before calling inittest.
|
||||||
echo "preparing lvmetad..."
|
echo -n "## preparing lvmetad..."
|
||||||
$run_valgrind lvmetad -f "$@" -s "$TESTDIR/lvmetad.socket" \
|
$run_valgrind lvmetad -f "$@" -s "$TESTDIR/lvmetad.socket" \
|
||||||
"${LVM_TEST_LVMETAD_DEBUG_OPTS--l all}" "$@" &
|
"${LVM_TEST_LVMETAD_DEBUG_OPTS--l all}" "$@" &
|
||||||
echo $! > LOCAL_LVMETAD
|
echo $! > LOCAL_LVMETAD
|
||||||
while ! test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket
|
for i in {1..100} ; do
|
||||||
|
test "$i" -eq 100 && die "Startup of lvmetad is too slow."
|
||||||
|
test -e "$TESTDIR/lvmetad.socket" && break
|
||||||
|
echo -n .
|
||||||
|
sleep .1;
|
||||||
|
done
|
||||||
echo ok
|
echo ok
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +242,7 @@ lvmetad_talk() {
|
|||||||
use=socat
|
use=socat
|
||||||
elif echo | not nc -U "$TESTDIR/lvmetad.socket" ; then
|
elif echo | not nc -U "$TESTDIR/lvmetad.socket" ; then
|
||||||
echo "WARNING: Neither socat nor nc -U seems to be available." 1>&2
|
echo "WARNING: Neither socat nor nc -U seems to be available." 1>&2
|
||||||
echo "# failed to contact lvmetad"
|
echo "## failed to contact lvmetad."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -263,21 +266,23 @@ notify_lvmetad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare_lvmpolld() {
|
prepare_lvmpolld() {
|
||||||
rm -f debug.log
|
check_daemon_in_builddir lvmetad
|
||||||
# skip if we don't have our own lvmpolld...
|
|
||||||
(which lvmpolld 2>/dev/null | grep "$abs_builddir") || skip
|
|
||||||
|
|
||||||
lvmconf "global/use_lvmpolld = 1"
|
lvmconf "global/use_lvmpolld = 1"
|
||||||
|
|
||||||
local run_valgrind=
|
local run_valgrind
|
||||||
test "${LVM_VALGRIND_LVMPOLLD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
test "${LVM_VALGRIND_LVMPOLLD:-0}" -eq 0 || run_valgrind="run_valgrind"
|
||||||
|
|
||||||
kill_sleep_kill_ LOCAL_LVMPOLLD "${LVM_VALGRIND_LVMPOLLD:-0}"
|
kill_sleep_kill_ LOCAL_LVMPOLLD "${LVM_VALGRIND_LVMPOLLD:-0}"
|
||||||
|
|
||||||
echo "preparing lvmpolld..."
|
echo -n "## preparing lvmpolld..."
|
||||||
$run_valgrind lvmpolld -f "$@" -s "$TESTDIR/lvmpolld.socket" -B "$TESTDIR/lib/lvm" -l all &
|
$run_valgrind lvmpolld -f "$@" -s "$TESTDIR/lvmpolld.socket" -B "$TESTDIR/lib/lvm" -l all &
|
||||||
echo $! > LOCAL_LVMPOLLD
|
echo $! > LOCAL_LVMPOLLD
|
||||||
while ! test -e "$TESTDIR/lvmpolld.socket"; do echo -n .; sleep .1; done # wait for the socket
|
for i in {1..100} ; do
|
||||||
|
test "$i" -eq 100 && die "Startup of lvmpolld is too slow."
|
||||||
|
test -e "$TESTDIR/lvmpolld.socket" && break
|
||||||
|
echo -n .;
|
||||||
|
sleep .1;
|
||||||
|
done # wait for the socket
|
||||||
echo ok
|
echo ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user