Skip to contentSkip to conversation

master - tests: add helper routine for pvmove status check

PATCH okozina 1 participant 1 message Mar 30, 2015

lore
Share & tools
lore

okozina

author
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7c66850ce506d9a8bdae74f999a658507943d57c
Commit:        7c66850ce506d9a8bdae74f999a658507943d57c
Parent:        c8caa04b1c58e1590654b405d1a6d34cd30c7b4f
Author:        Ondrej Kozina <[email protected]>
AuthorDate:    Fri Mar 27 14:24:16 2015 +0100
Committer:     Ondrej Kozina <[email protected]>
CommitterDate: Mon Mar 30 18:38:50 2015 +0200

tests: add helper routine for pvmove status check

---
 test/lib/aux.sh              |   12 ++++++++++++
 test/shell/pvmove-restart.sh |    7 ++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
test/lib/aux.sh +12 -0
index cdd9a2d..b9f63b5 100644
@@ -902,6 +902,18 @@ dmsetup_wrapped() {
 	dmsetup "$@"
 }
 
+wait_pvmove_lv_ready() {
+	# given sleep .1 this is about 60 secs of waiting
+	local retries=${2:-600}
+	while : ; do
+		test $retries -le 0 && die "Waiting for pvmove LV to get activated has timed out"
+		dmsetup info -c -o tables_loaded $1 > out || true;
+		not grep Live out || break
+		sleep .1
+		retries=$((retries-1))
+	done
+}
+
 test -z "$LVM_TEST_AUX_TRACE" || set -x
 
 test -f DEVICES && devs=$(< DEVICES)
test/shell/pvmove-restart.sh +2 -5
index 06455f5..ca26779 100644
@@ -34,11 +34,8 @@ aux delay_dev "$dev3" 0 200
 pvmove -i0 -n $vg/$lv1 "$dev1" "$dev3" $mode &
 PVMOVE=$!
 # Let's wait a bit till pvmove starts and kill it
-while : ; do
-	dmsetup info -c -o tables_loaded "$vg-pvmove0" > out || true;
-	not grep Live out || break
-	sleep .1
-done
+aux wait_pvmove_lv_ready "$vg-pvmove0" 300
+
 kill -9 $PVMOVE
 wait