1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: wait for running dmeventd

Add slight delay for waiting until 'started' dmeventd is
responsing to other 'dmeventd -i' command.

TODO: race observed here is somewhat unclear, might need some more
details
This commit is contained in:
Zdenek Kabelac 2024-05-10 17:48:47 +02:00
parent b678decfca
commit cd6e1d0475

View File

@ -15,27 +15,34 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest . lib/inittest
_restart_dmeventd() { _wait_for_dmeventd() {
local local=${1-}
local pid= local pid=
for i in {1..50}; do
if test -n "$local" ; then
pid=$(pgrep -o dmeventd) || break;
fi
# Check pid and dmeventd readiness to communicate
test "$pid" = "$local" && dmeventd -i && break
sleep .2
done
}
_restart_dmeventd() {
#rm -f debug.log* #rm -f debug.log*
dmeventd -R -fldddd -e "$PWD/test_nologin" > debug.log_DMEVENTD_$RANDOM 2>&1 & dmeventd -R -fldddd -e "$PWD/test_nologin" > debug.log_DMEVENTD_$RANDOM 2>&1 &
local local=$! local local=$!
echo "$local" >LOCAL_DMEVENTD echo "$local" >LOCAL_DMEVENTD
for i in {1..50}; do _wait_for_dmeventd "$local"
pid=$(pgrep -o dmeventd) || break
# Check pid and dmeventd readiness to communicate
test "$pid" = "$local" && dmeventd -i && break
sleep .2
done
if [ "$i" -eq 50 ]; then if [ "$i" -eq 50 ]; then
# Unexpected - we waited over 10 seconds and # Unexpected - we waited over 10 seconds and
# dmeventd has not managed to restart # dmeventd has not managed to restart
cat /run/dmeventd.pid || true cat /run/dmeventd.pid || true
pgrep dmeventd || true pgrep dmeventd || true
die "dmeventd restart is too slow" die "dmeventd restart is too slow: $(ps aux)"
fi fi
} }
@ -51,6 +58,7 @@ lvchange --monitor y $vg/3way
lvcreate -aey -l1 -n $lv1 $vg lvcreate -aey -l1 -n $lv1 $vg
lvcreate -s -l1 -n $lv2 $vg/$lv1 lvcreate -s -l1 -n $lv2 $vg/$lv1
_wait_for_dmeventd
_restart_dmeventd _restart_dmeventd
check lv_field $vg/3way seg_monitor "monitored" check lv_field $vg/3way seg_monitor "monitored"