From cd6e1d04757fed4ce45e9e539a1c6422eb670fab Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 10 May 2024 17:48:47 +0200 Subject: [PATCH] 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 --- test/shell/dmeventd-restart.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/shell/dmeventd-restart.sh b/test/shell/dmeventd-restart.sh index c16537aa2..b7324cb33 100644 --- a/test/shell/dmeventd-restart.sh +++ b/test/shell/dmeventd-restart.sh @@ -15,27 +15,34 @@ SKIP_WITH_LVMPOLLD=1 . lib/inittest -_restart_dmeventd() { +_wait_for_dmeventd() { + local local=${1-} 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* dmeventd -R -fldddd -e "$PWD/test_nologin" > debug.log_DMEVENTD_$RANDOM 2>&1 & local local=$! echo "$local" >LOCAL_DMEVENTD - for i in {1..50}; do - pid=$(pgrep -o dmeventd) || break - # Check pid and dmeventd readiness to communicate - test "$pid" = "$local" && dmeventd -i && break - sleep .2 - done + _wait_for_dmeventd "$local" if [ "$i" -eq 50 ]; then # Unexpected - we waited over 10 seconds and # dmeventd has not managed to restart cat /run/dmeventd.pid || true pgrep dmeventd || true - die "dmeventd restart is too slow" + die "dmeventd restart is too slow: $(ps aux)" fi } @@ -51,6 +58,7 @@ lvchange --monitor y $vg/3way lvcreate -aey -l1 -n $lv1 $vg lvcreate -s -l1 -n $lv2 $vg/$lv1 +_wait_for_dmeventd _restart_dmeventd check lv_field $vg/3way seg_monitor "monitored"