Skip to contentSkip to conversation

dev-next - tests: improve check raid_leg_status

PATCH David Teigland 1 participant 1 message Mar 31, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c1f5ca6751eeda5925638447b561b05bdf8a250c
Commit:        c1f5ca6751eeda5925638447b561b05bdf8a250c
Parent:        0783c661b9eb407b0b436559b6950deefc906b4f
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Wed Mar 24 16:05:03 2021 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Wed Mar 24 16:38:12 2021 +0100

tests: improve check raid_leg_status

Enhance function to wait until raid status gets consisten (shifts from 0/xxxxx to something else)

If it would took too long fail the check.

---
 test/lib/check.sh | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
test/lib/check.sh +13 -4
index 4deb78a74..5b119430d 100644
@@ -436,10 +436,19 @@ sysfs() {
 raid_leg_status() {
 	local st
 	local val
-	st=$(dmsetup status "$1-$2")
-	val=$(echo "$st" | cut -d ' ' -f 6)
-	test "$val" = "$3" || \
-		die "$1-$2 status $val != $3  ($st)"
+
+	# Ignore inconsisten raid status 0/xxxxx idle
+	for i in {100..0} ; do
+		st=( $(dmsetup status $1-$2) ) || die "Unable to get status of $vg/$lv1"
+		b=( $(echo "${st[6]}" | sed s:/:' ':) )
+		[ "${b[0]}" = "0" ] || {
+			test "${st[5]}" = "$3" || break
+			return 0
+		}
+		sleep .1
+	done
+
+	die "$1-$2 status ${st[5]} != $3  ($st)"
 }
 
 grep_dmsetup() {