summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-04-30 18:42:31 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2015-05-01 15:07:58 +0200
commit16e8006eb05a3fd18d1efeb58f79ffbb41ba61e2 (patch)
tree5abf8bad2b751344fa2ddaa2773f370feefda401
parentc18e969e30a44ec392f40414e1f134ff70cecb38 (diff)
downloadlvm2-16e8006eb05a3fd18d1efeb58f79ffbb41ba61e2.tar.gz
tests: rename kill_tagged_processes
Better name for aux function. First use normal -TERM, and only after a while use -KILL (leaving some time to correctly finish) Print INFO about killed processes.
-rw-r--r--test/lib/aux.sh31
-rw-r--r--test/shell/pvmove-abort-all.sh2
-rw-r--r--test/shell/pvmove-abort.sh2
-rw-r--r--test/shell/pvmove-restart.sh2
-rw-r--r--test/shell/pvmove-resume-1.sh2
-rw-r--r--test/shell/pvmove-resume-2.sh2
-rw-r--r--test/shell/pvmove-resume-multiseg.sh2
7 files changed, 31 insertions, 12 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index e20b6b054..716d596ed 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -233,17 +233,36 @@ kill_sleep_kill_() {
}
print_procs_by_tag_() {
- ps -o pid=,args= ehax 2>/dev/null | grep -weLVM_TEST_TAG=${1:-kill_me_$PREFIX} 2>/dev/null || true
+ (ps -o pid,args ehax | grep -we"LVM_TEST_TAG=${1:-kill_me_$PREFIX}") || true
}
count_processes_with_tag() {
print_procs_by_tag_ | wc -l
}
-kill_listed_processes() {
- while read pid b; do
- test -z "$pid" || kill -9 $pid
- done <<< $(print_procs_by_tag_ $@)
+kill_tagged_processes() {
+ local pid
+ local pids
+ local wait
+
+ # read uses all vars within pipe subshell
+ print_procs_by_tag_ "$@" | while read -r pid wait; do
+ if test -n "$pid" ; then
+ echo "Killing tagged process: $pid ${wait:0:120}..."
+ kill -TERM $pid 2>/dev/null || true
+ fi
+ pids="$pids $pid"
+ done
+
+ # wait if process exited and eventually -KILL
+ wait=0
+ for pid in $pids ; do
+ while ps $pid > /dev/null && test $wait -le 10; do
+ sleep .2
+ wait=$(($wait + 1))
+ done
+ test $wait -le 10 || kill -KILL $pid 2>/dev/null || true
+ done
}
teardown() {
@@ -252,7 +271,7 @@ teardown() {
if test -f TESTNAME ; then
- kill_listed_processes
+ kill_tagged_processes
kill_sleep_kill_ LOCAL_LVMETAD ${LVM_VALGRIND_LVMETAD:-0}
diff --git a/test/shell/pvmove-abort-all.sh b/test/shell/pvmove-abort-all.sh
index 5bca8a22f..da43da65f 100644
--- a/test/shell/pvmove-abort-all.sh
+++ b/test/shell/pvmove-abort-all.sh
@@ -67,7 +67,7 @@ not grep "^\[pvmove" out
lvremove -ff $vg $vg1
wait
-aux kill_listed_processes
+aux kill_tagged_processes
done
done
diff --git a/test/shell/pvmove-abort.sh b/test/shell/pvmove-abort.sh
index 233252176..6b807acd4 100644
--- a/test/shell/pvmove-abort.sh
+++ b/test/shell/pvmove-abort.sh
@@ -58,7 +58,7 @@ pvmove --abort
lvremove -ff $vg
wait
-aux kill_listed_processes
+aux kill_tagged_processes
done
done
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index b91f6244e..1496b359d 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -90,7 +90,7 @@ pvmove --abort
lvs -a -o+devices $vg
lvremove -ff $vg
-aux kill_listed_processes
+aux kill_tagged_processes
done
# Restore delayed device back
diff --git a/test/shell/pvmove-resume-1.sh b/test/shell/pvmove-resume-1.sh
index 9825e76d5..acf35eee2 100644
--- a/test/shell/pvmove-resume-1.sh
+++ b/test/shell/pvmove-resume-1.sh
@@ -98,7 +98,7 @@ test_pvmove_resume() {
i=$((i + 1))
done
- aux kill_listed_processes
+ aux kill_tagged_processes
lvremove -ff $vg $vg1
}
diff --git a/test/shell/pvmove-resume-2.sh b/test/shell/pvmove-resume-2.sh
index dee82cc7c..37a552d60 100644
--- a/test/shell/pvmove-resume-2.sh
+++ b/test/shell/pvmove-resume-2.sh
@@ -80,7 +80,7 @@ test_pvmove_resume() {
i=$((i + 1))
done
- aux kill_listed_processes
+ aux kill_tagged_processes
lvremove -ff $vg
}
diff --git a/test/shell/pvmove-resume-multiseg.sh b/test/shell/pvmove-resume-multiseg.sh
index d70662d35..be21d5602 100644
--- a/test/shell/pvmove-resume-multiseg.sh
+++ b/test/shell/pvmove-resume-multiseg.sh
@@ -92,7 +92,7 @@ test_pvmove_resume() {
i=$((i + 1))
done
- aux kill_listed_processes
+ aux kill_tagged_processes
lvremove -ff $vg
}