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

tests: improve wait for open

Add loop to detect open device from 'sleep <'
This commit is contained in:
Zdenek Kabelac 2014-03-07 19:26:37 +01:00
parent fa23234e71
commit d913fcbd46

View File

@ -20,6 +20,16 @@ fill() {
dd if=/dev/zero of="$DM_DEV_DIR/$vg1/lvol0" bs=$1 count=1 dd if=/dev/zero of="$DM_DEV_DIR/$vg1/lvol0" bs=$1 count=1
} }
# give some short time to lock file above
wait_for_open_() {
for i in $(seq 1 50) ; do
test $(dmsetup info --noheadings -c -o open $1) -ne 0 && return
sleep 0.1
done
die "$1 expected to be openned, but it's not!"
}
cleanup_tail() cleanup_tail()
{ {
test -z "$SLEEP_PID" || kill $SLEEP_PID test -z "$SLEEP_PID" || kill $SLEEP_PID
@ -52,6 +62,7 @@ if aux target_at_least dm-snapshot 1 10 0 ; then
fi fi
fi fi
# Automatically activates exclusively in cluster
lvcreate -s -l 100%FREE -n $lv $vg --virtualsize $TSIZE lvcreate -s -l 100%FREE -n $lv $vg --virtualsize $TSIZE
aux extend_filter_LVMTEST aux extend_filter_LVMTEST
@ -77,8 +88,7 @@ trap 'cleanup_tail' EXIT
sleep 120 < "$DM_DEV_DIR/$vg1/$lv1" & sleep 120 < "$DM_DEV_DIR/$vg1/$lv1" &
SLEEP_PID=$! SLEEP_PID=$!
# give some short time to lock file above wait_for_open_ "$vg1-$lv1"
sleep 0.1
# Opened virtual snapshot device is not removable # Opened virtual snapshot device is not removable
# it should retry device removal for a few seconds # it should retry device removal for a few seconds
@ -173,7 +183,7 @@ lvcreate -s -l100%FREE -n $lv2 $vg1/$lv1
check lv_field $vg1/$lv2 size "7.50p" check lv_field $vg1/$lv2 size "7.50p"
lvremove -ff $vg1 lvremove -ff $vg1
lvcreate -aey -V15E -l1 -n $lv1 -s $vg1 lvcreate -V15E -l1 -n $lv1 -s $vg1
check lv_field $vg1/$lv1 origin_size "15.00e" check lv_field $vg1/$lv1 origin_size "15.00e"
vgremove -ff $vg1 vgremove -ff $vg1