1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-19 14:04:17 +03:00

tests: update pvmove tests

Put in pvmove background process into list quickly.
Update API for aux add_to_kill_list()/kill_listed_processes().
Run on 'background' (&) only non-background pvmoves.
This commit is contained in:
Zdenek Kabelac 2015-04-14 13:29:19 +02:00
parent 75454c2b32
commit d1a770107d
3 changed files with 44 additions and 26 deletions

View File

@ -232,25 +232,29 @@ kill_sleep_kill_() {
# $1 cmd line # $1 cmd line
# $2 optional parms for pgrep # $2 optional parms for pgrep
add_to_kill_list() { add_to_kill_list() {
local p=$(pgrep $2 -f "$1" 2>/dev/null) local p=$(pgrep ${@:2} -f "$1" 2>/dev/null)
test -z $p || echo $p:$1 >> kill_list test -z "$p" || echo "$p:$1" >> kill_list
} }
kill_remaining_processes() { kill_listed_processes() {
local line local tmp
while read line; do local pid
local pid=$(echo $line | awk -F':' '{ print $1 }') local cmd
local cmd=$(echo $line | awk -F':' '{ print $2 }') test -f kill_list || return 0
while read tmp; do
pid=${tmp%%:*}
cmd=${tmp##*:}
for tmp in $(pgrep -f "$cmd" -d ' '); do for tmp in $(pgrep -f "$cmd" -d ' '); do
test $tmp = $pid && kill -9 $tmp test "$tmp" = "$pid" && kill -9 "$tmp"
done
done done
done < kill_list
rm -f kill_list
} }
teardown() { teardown() {
echo -n "## teardown..." echo -n "## teardown..."
test -f kill_list && kill_remaining_processes < kill_list kill_listed_processes
kill_sleep_kill_ LOCAL_LVMETAD ${LVM_VALGRIND_LVMETAD:-0} kill_sleep_kill_ LOCAL_LVMETAD ${LVM_VALGRIND_LVMETAD:-0}

View File

@ -38,14 +38,23 @@ lvcreate -an -Zn -l30 -n $lv1 $vg1 "$dev4"
lvextend -l+30 -n $vg1/$lv1 "$dev5" lvextend -l+30 -n $vg1/$lv1 "$dev5"
cmd1=$(echo pvmove -i1 $backgroundarg "$dev1" "$dev3" $mode) cmd1=$(echo pvmove -i1 $backgroundarg "$dev1" "$dev3" $mode)
$cmd1 &
aux wait_pvmove_lv_ready "$vg-pvmove0"
cmd2=$(echo pvmove -i1 $backgroundarg "$dev2" "$dev3" $mode) cmd2=$(echo pvmove -i1 $backgroundarg "$dev2" "$dev3" $mode)
$cmd2 & cmd3=$(echo pvmove -i1 $backgroundarg -n $vg1/$lv1 "$dev4" "$dev6" $mode)
aux wait_pvmove_lv_ready "$vg-pvmove1" if test -z "$backgroundarg" ; then
$cmd1 &
pvmove -i1 $backgroundarg -n $vg1/$lv1 "$dev4" "$dev6" $mode & aux wait_pvmove_lv_ready "$vg-pvmove0"
aux wait_pvmove_lv_ready "$vg1-pvmove0" $cmd2 &
aux wait_pvmove_lv_ready "$vg-pvmove1"
$cmd3 &
aux wait_pvmove_lv_ready "$vg1-pvmove0"
else
$cmd1
aux add_to_kill_list "$cmd1" -P 1
$cmd2
aux add_to_kill_list "$cmd2" -P 1
$cmd3
aux add_to_kill_list "$cmd3" -P 1
fi
# test removal of all pvmove LVs # test removal of all pvmove LVs
pvmove --abort pvmove --abort
@ -59,8 +68,7 @@ not grep "^\[pvmove" out
lvremove -ff $vg $vg1 lvremove -ff $vg $vg1
wait wait
aux add_to_kill_list "$cmd1" "-P 1" aux kill_listed_processes
aux add_to_kill_list "$cmd2" "-P 1"
done done
done done

View File

@ -32,11 +32,18 @@ lvcreate -an -Zn -l30 -n $lv1 $vg "$dev1"
lvcreate -an -Zn -l30 -n $lv2 $vg "$dev2" lvcreate -an -Zn -l30 -n $lv2 $vg "$dev2"
cmd1=$(echo pvmove -i1 $backgroundarg "$dev1" "$dev3" $mode) cmd1=$(echo pvmove -i1 $backgroundarg "$dev1" "$dev3" $mode)
$cmd1 &
aux wait_pvmove_lv_ready "$vg-pvmove0"
cmd2=$(echo pvmove -i1 $backgroundarg "$dev2" "$dev3" $mode) cmd2=$(echo pvmove -i1 $backgroundarg "$dev2" "$dev3" $mode)
$cmd2 & if test -z "$backgroundarg" ; then
aux wait_pvmove_lv_ready "$vg-pvmove1" $cmd1 &
aux wait_pvmove_lv_ready "$vg-pvmove0"
$cmd2 &
aux wait_pvmove_lv_ready "$vg-pvmove1"
else
$cmd1
aux add_to_kill_list "$cmd1" -P 1
$cmd2
aux add_to_kill_list "$cmd2" -P 1
fi
# remove specific device # remove specific device
pvmove --abort "$dev1" pvmove --abort "$dev1"
@ -52,8 +59,7 @@ pvmove --abort
lvremove -ff $vg lvremove -ff $vg
wait wait
aux add_to_kill_list "$cmd1" "-P 1" aux kill_listed_processes
aux add_to_kill_list "$cmd2" "-P 1"
done done
done done