Skip to contentSkip to conversation

master - tests: use standard md devices

PATCH David Teigland 1 participant 1 message Sep 12, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1fe04f89efa97bf25b7b5ca6f382e957a9adf43d
Commit:        1fe04f89efa97bf25b7b5ca6f382e957a9adf43d
Parent:        772dbb1e39d007c770dd7ddb5ca912009658f8a0
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Sep 11 13:26:41 2019 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Thu Sep 12 10:11:27 2019 -0500

tests: use standard md devices

---
 test/lib/aux.sh                     |   27 ++++++++++-
 test/shell/duplicate-pvs-md0.sh     |   74 +++++++++++++++------------
 test/shell/duplicate-pvs-md1.sh     |   95 +++++++++++++++++------------------
 test/shell/lvm-on-md.sh             |   50 +++++++++++--------
 test/shell/pvcreate-operation-md.sh |   37 ++++++++++----
 5 files changed, 169 insertions(+), 114 deletions(-)
test/lib/aux.sh +26 -1
index 32d5a0b..b7207eb 100644
@@ -775,6 +775,20 @@ cleanup_md_dev() {
 	rm -f MD_DEV MD_DEVICES MD_DEV_PV
 }
 
+wait_md_create() {
+	local md=$1
+
+	while :; do
+		if ! grep `basename $md` /proc/mdstat; then
+			echo "$md not ready"
+			cat /proc/mdstat
+			sleep 2
+		else
+			break
+		fi
+	done
+}
+
 prepare_backing_dev() {
 	local size=${1=32}
 	shift
@@ -1093,6 +1107,17 @@ extend_filter() {
 	lvmconf "$filter" "devices/scan_lvs = 1"
 }
 
+extend_filter_md() {
+	local filter
+
+	filter=$(grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
+	for rx in "$@"; do
+		filter=$(echo "$filter" | sed -e "s:\\[:[ \"$rx\", :")
+	done
+	lvmconf "$filter"
+	lvmconf "devices/scan = [ \"$DM_DEV_DIR\", \"/dev\" ]"
+}
+
 extend_filter_LVMTEST() {
 	extend_filter "a|$DM_DEV_DIR/$PREFIX|" "$@"
 }
@@ -1165,7 +1190,7 @@ devices/dir = "$DM_DEV_DIR"
 devices/filter = "a|.*|"
 devices/global_filter = [ "a|$DM_DEV_DIR/mapper/${PREFIX}.*pv[0-9_]*$|", "r|.*|" ]
 devices/md_component_detection = 0
-devices/scan = "$DM_DEV_DIR"
+devices/scan = [ "$DM_DEV_DIR" ]
 devices/sysfs_scan = 1
 devices/write_cache_state = 0
 global/abort_on_internal_errors = 1
test/shell/duplicate-pvs-md0.sh +41 -33

173 lines not on this page · raw message

test/shell/duplicate-pvs-md1.sh +47 -48

185 lines not on this page · raw message

test/shell/lvm-on-md.sh +29 -21

103 lines not on this page · raw message

test/shell/pvcreate-operation-md.sh +26 -11
index 4b51932..12cf891 100644
@@ -20,17 +20,19 @@ which sfdisk || skip
 
 test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
 	modprobe raid0 || skip
+not grep md0 /proc/mdstat
 
 aux lvmconf 'devices/md_component_detection = 1'
-aux extend_filter_LVMTEST "a|/dev/md|"
+aux extend_filter_md "a|/dev/md|"
 
 aux prepare_devs 2
 
 # create 2 disk MD raid0 array (stripe_width=128K)
-aux prepare_md_dev 0 64 2 "$dev1" "$dev2"
+mddev="/dev/md0"
+mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+aux wait_md_create "$mddev"
 
-mddev=$(< MD_DEV)
-pvdev=$(< MD_DEV_PV)
+pvdev="$mddev"
 
 # Test alignment of PV on MD without any MD-aware or topology-aware detection
 # - should treat $mddev just like any other block device
@@ -82,7 +84,7 @@ EOF
     if aux kernel_at_least 2 6 33 ; then
 	# in case the system is running without devtmpfs /dev
 	# wait here for created device node on tmpfs
-	test "$DM_DEV_DIR" = "/dev" || cp -LR "${mddev}p1" "${pvdev%/*}"
+	# test "$DM_DEV_DIR" = "/dev" || cp -LR "${mddev}p1" "${pvdev%/*}"
 
 	pvcreate --metadatasize 128k "${pvdev}p1"
 
@@ -105,17 +107,23 @@ EOF
 	check pv_field "${pvdev}p1" pe_start $pv_align --units b --nosuffix
 
 	pvremove "${pvdev}p1"
-	test "$DM_DEV_DIR" = "/dev" || rm -f "${pvdev}p1"
+	# test "$DM_DEV_DIR" = "/dev" || rm -f "${pvdev}p1"
     fi
 fi
 
+mdadm --stop "$mddev"
+aux udev_wait
+wipefs -a "$dev1"
+wipefs -a "$dev2"
+aux udev_wait
+
 # Test newer topology-aware alignment detection w/ --dataalignment override
 if aux kernel_at_least 2 6 33 ; then
-    # make sure we're clean for another test
-    dd if=/dev/zero of="$mddev" bs=512 count=4 conv=fdatasync
-    partprobe -s "$mddev"
-    aux prepare_md_dev 0 1024 2 "$dev1" "$dev2"
-    pvdev=$(< MD_DEV_PV)
+
+    mddev="/dev/md0"
+    mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=1024 --raid-devices=2 "$dev1" "$dev2"
+    aux wait_md_create "$mddev"
+    pvdev="$mddev"
 
     # optimal_io_size=2097152, minimum_io_size=1048576
     pvcreate --metadatasize 128k \
@@ -130,4 +138,11 @@ if aux kernel_at_least 2 6 33 ; then
     pvcreate --dataalignment 64k --metadatasize 128k \
 	--config 'devices { md_chunk_alignment=0 }' "$pvdev"
     check pv_field "$pvdev" pe_start "192.00k"
+
+    mdadm --stop "$mddev"
+    aux udev_wait
+    wipefs -a "$dev1"
+    wipefs -a "$dev2"
+    aux udev_wait
+
 fi