1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

tests: better handling for dmeventd restart

Handle the case, where we  'kill -9' running dmeventd,
and restarting 'dmeventd -R' manages to still contact this
'zombie' damone and manages to get list of monitored devices
out of this and eventually 'run' new and in this case
unexpected instance of dmeventd.
This commit is contained in:
Zdenek Kabelac 2024-04-11 23:43:27 +02:00
parent aae7c98aaa
commit 8ce8e33a44

View File

@ -20,21 +20,22 @@ _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 &
echo $! >LOCAL_DMEVENTD local local=$!
echo "$local" >LOCAL_DMEVENTD
for i in {1..10}; do for i in {1..50}; do
pid=$(pgrep -o dmeventd || true) pid=$(pgrep -o dmeventd) || break
test -n "$pid" || break; # no dmeventd running # Check pid and dmeventd readiness to communicate
test "$pid" = "$(< LOCAL_DMEVENTD)" && break test "$pid" = "$local" && dmeventd -i && break
sleep .2 sleep .2
done done
# wait a bit, so we talk to the new dmeventd later if [ "$i" -eq 50 ]; then
if test -n "$pid" ; then # Unexpected - we waited over 10 seconds and
for i in {1..10}; do # dmeventd has not managed to restart
dmeventd -i && break; cat /run/dmeventd.pid || true
sleep .1 pgrep dmeventd || true
done die "dmeventd restart is too slow"
fi fi
} }
@ -61,7 +62,20 @@ lvchange --monitor y --verbose $vg/4way 2>&1 | tee lvchange.out
test -e LOCAL_CLVMD || grep 'already monitored' lvchange.out test -e LOCAL_CLVMD || grep 'already monitored' lvchange.out
# now try what happens if no dmeventd is running # now try what happens if no dmeventd is running
kill -9 "$(< LOCAL_DMEVENTD)" pid=$(< LOCAL_DMEVENTD)
kill -9 "$pid"
# TODO/FIXME: it would be surely better, if the wait loop bellow would
# not be need however ATM the API for communication is not welldetecting
# this highly unusual race case - and things will simply timeout on
# reading failure within 4 seconds.
# Fixing would require to add some handling for losing FIFO connection
for i in {1..10}; do
# wait here for a while until dmeventd dies....
# suprisingly it's not instant and we can actually
# obtain list of monitored devices...
test -z $(ps -p "$pid" -o comm=) && break
sleep .1
done
rm LOCAL_DMEVENTD debug.log* rm LOCAL_DMEVENTD debug.log*
_restart_dmeventd _restart_dmeventd