mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +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:
parent
75454c2b32
commit
d1a770107d
@ -232,25 +232,29 @@ kill_sleep_kill_() {
|
||||
# $1 cmd line
|
||||
# $2 optional parms for pgrep
|
||||
add_to_kill_list() {
|
||||
local p=$(pgrep $2 -f "$1" 2>/dev/null)
|
||||
test -z $p || echo $p:$1 >> kill_list
|
||||
local p=$(pgrep ${@:2} -f "$1" 2>/dev/null)
|
||||
test -z "$p" || echo "$p:$1" >> kill_list
|
||||
}
|
||||
|
||||
kill_remaining_processes() {
|
||||
local line
|
||||
while read line; do
|
||||
local pid=$(echo $line | awk -F':' '{ print $1 }')
|
||||
local cmd=$(echo $line | awk -F':' '{ print $2 }')
|
||||
kill_listed_processes() {
|
||||
local tmp
|
||||
local pid
|
||||
local cmd
|
||||
test -f kill_list || return 0
|
||||
while read tmp; do
|
||||
pid=${tmp%%:*}
|
||||
cmd=${tmp##*:}
|
||||
for tmp in $(pgrep -f "$cmd" -d ' '); do
|
||||
test $tmp = $pid && kill -9 $tmp
|
||||
done
|
||||
test "$tmp" = "$pid" && kill -9 "$tmp"
|
||||
done
|
||||
done < kill_list
|
||||
rm -f kill_list
|
||||
}
|
||||
|
||||
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}
|
||||
|
||||
|
@ -38,14 +38,23 @@ lvcreate -an -Zn -l30 -n $lv1 $vg1 "$dev4"
|
||||
lvextend -l+30 -n $vg1/$lv1 "$dev5"
|
||||
|
||||
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 &
|
||||
aux wait_pvmove_lv_ready "$vg-pvmove1"
|
||||
|
||||
pvmove -i1 $backgroundarg -n $vg1/$lv1 "$dev4" "$dev6" $mode &
|
||||
aux wait_pvmove_lv_ready "$vg1-pvmove0"
|
||||
cmd3=$(echo pvmove -i1 $backgroundarg -n $vg1/$lv1 "$dev4" "$dev6" $mode)
|
||||
if test -z "$backgroundarg" ; then
|
||||
$cmd1 &
|
||||
aux wait_pvmove_lv_ready "$vg-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
|
||||
pvmove --abort
|
||||
@ -59,8 +68,7 @@ not grep "^\[pvmove" out
|
||||
lvremove -ff $vg $vg1
|
||||
|
||||
wait
|
||||
aux add_to_kill_list "$cmd1" "-P 1"
|
||||
aux add_to_kill_list "$cmd2" "-P 1"
|
||||
aux kill_listed_processes
|
||||
done
|
||||
done
|
||||
|
||||
|
@ -32,11 +32,18 @@ lvcreate -an -Zn -l30 -n $lv1 $vg "$dev1"
|
||||
lvcreate -an -Zn -l30 -n $lv2 $vg "$dev2"
|
||||
|
||||
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 &
|
||||
aux wait_pvmove_lv_ready "$vg-pvmove1"
|
||||
if test -z "$backgroundarg" ; then
|
||||
$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
|
||||
pvmove --abort "$dev1"
|
||||
@ -52,8 +59,7 @@ pvmove --abort
|
||||
lvremove -ff $vg
|
||||
|
||||
wait
|
||||
aux add_to_kill_list "$cmd1" "-P 1"
|
||||
aux add_to_kill_list "$cmd2" "-P 1"
|
||||
aux kill_listed_processes
|
||||
done
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user