mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_06-tests-extend-lvm-on-md.patch

26e710
 test/shell/lvm-on-md.sh | 257 ++++++++++++++++++++++++++++++++++++++++++++----
26e710
 1 file changed, 237 insertions(+), 20 deletions(-)
26e710
26e710
diff --git a/test/shell/lvm-on-md.sh b/test/shell/lvm-on-md.sh
26e710
index 22cbee8..c848083 100644
26e710
--- a/test/shell/lvm-on-md.sh
26e710
+++ b/test/shell/lvm-on-md.sh
26e710
@@ -42,7 +42,7 @@ aux lvmconf 'devices/obtain_device_list_from_udev = 0'
26e710
 
26e710
 aux extend_filter_LVMTEST "a|/dev/md|"
26e710
 
26e710
-aux prepare_devs 2
26e710
+aux prepare_devs 3
26e710
 
26e710
 # create 2 disk MD raid1 array
26e710
 # by default using metadata format 1.0 with data at the end of device
26e710
@@ -55,6 +55,9 @@ pvdev=$(< MD_DEV_PV)
26e710
 
26e710
 vgcreate $vg "$mddev"
26e710
 
26e710
+PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
26e710
+echo $PVIDMD
26e710
+
26e710
 lvcreate -n $lv1 -l 2 $vg
26e710
 lvcreate -n $lv2 -l 2 -an $vg
26e710
 
26e710
@@ -87,7 +90,8 @@ pvs > out
26e710
 not grep "$dev1" out
26e710
 not grep "$dev2" out
26e710
 
26e710
-pvs -vvvv
26e710
+pvs 2>&1|tee out
26e710
+not grep "Not using device" out
26e710
 
26e710
 # should not activate from the md legs
26e710
 not vgchange -ay $vg
26e710
@@ -105,42 +109,62 @@ _clear_online_files
26e710
 pvscan --cache -aay "$dev1"
26e710
 pvscan --cache -aay "$dev2"
26e710
 
26e710
+not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+not ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
 # should not show an active lv
26e710
 rm out
26e710
 lvs -o active $vg |tee out || true
26e710
 not grep "active" out
26e710
 
26e710
-# start the md dev
26e710
 mdadm --assemble "$mddev" "$dev1" "$dev2"
26e710
 aux udev_wait
26e710
 
26e710
-# Now that the md dev is online, pvs can see it
26e710
-# and check for components even if
26e710
-# md_component_checks is "start" (which disables
26e710
-# most default end-of-device scans)
26e710
-aux lvmconf 'devices/md_component_checks = "start"'
26e710
-
26e710
 not pvs "$dev1"
26e710
 not pvs "$dev2"
26e710
 pvs > out
26e710
 not grep "$dev1" out
26e710
 not grep "$dev2" out
26e710
 
26e710
+lvs $vg
26e710
+vgchange -an $vg
26e710
+
26e710
+# should not activate from the md legs
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$dev1"
26e710
+pvscan --cache -aay "$dev2"
26e710
+
26e710
+not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+not ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+# should not show an active lv
26e710
+rm out
26e710
+lvs -o active $vg |tee out || true
26e710
+not grep "active" out
26e710
 
26e710
 vgchange -ay $vg
26e710
 
26e710
 check lv_field $vg/$lv1 lv_active "active"
26e710
 
26e710
 vgchange -an $vg
26e710
+
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$mddev"
26e710
+
26e710
+ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+lvs -o active $vg |tee out || true
26e710
+grep "active" out
26e710
+
26e710
+vgchange -an $vg
26e710
+
26e710
 aux udev_wait
26e710
 
26e710
 vgremove -f $vg
26e710
 
26e710
 aux cleanup_md_dev
26e710
 
26e710
-# Put this setting back to the default
26e710
-aux lvmconf 'devices/md_component_checks = "auto"'
26e710
-
26e710
 # create 2 disk MD raid0 array
26e710
 # by default using metadata format 1.0 with data at the end of device
26e710
 # When a raid0 md array is stopped, the components will not look like
26e710
@@ -154,7 +178,8 @@ pvdev=$(< MD_DEV_PV)
26e710
 
26e710
 vgcreate $vg "$mddev"
26e710
 
26e710
-lvs $vg
26e710
+PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
26e710
+echo $PVIDMD
26e710
 
26e710
 lvcreate -n $lv1 -l 2 $vg
26e710
 lvcreate -n $lv2 -l 2 -an $vg
26e710
@@ -188,7 +213,8 @@ pvs > out
26e710
 not grep "$dev1" out
26e710
 not grep "$dev2" out
26e710
 
26e710
-pvs -vvvv
26e710
+pvs 2>&1|tee out
26e710
+not grep "Not using device" out
26e710
 
26e710
 # should not activate from the md legs
26e710
 not vgchange -ay $vg
26e710
@@ -206,6 +232,9 @@ _clear_online_files
26e710
 pvscan --cache -aay "$dev1"
26e710
 pvscan --cache -aay "$dev2"
26e710
 
26e710
+not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+not ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
 # should not show an active lv
26e710
 rm out
26e710
 lvs -o active $vg |tee out || true
26e710
@@ -215,23 +244,211 @@ not grep "active" out
26e710
 mdadm --assemble "$mddev" "$dev1" "$dev2"
26e710
 aux udev_wait
26e710
 
26e710
-# Now that the md dev is online, pvs can see it
26e710
-# and check for components even if
26e710
-# md_component_checks is "start" (which disables
26e710
-# most default end-of-device scans)
26e710
-aux lvmconf 'devices/md_component_checks = "start"'
26e710
+not pvs "$dev1"
26e710
+not pvs "$dev2"
26e710
+pvs > out
26e710
+not grep "$dev1" out
26e710
+not grep "$dev2" out
26e710
+
26e710
+lvs $vg
26e710
+vgchange -an $vg
26e710
+
26e710
+# should not activate from the md legs
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$dev1"
26e710
+pvscan --cache -aay "$dev2"
26e710
+
26e710
+not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+not ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+# should not show an active lv
26e710
+rm out
26e710
+lvs -o active $vg |tee out || true
26e710
+not grep "active" out
26e710
+
26e710
+vgchange -ay $vg
26e710
+
26e710
+check lv_field $vg/$lv1 lv_active "active"
26e710
+
26e710
+vgchange -an $vg
26e710
+
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$mddev"
26e710
+
26e710
+ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+lvs -o active $vg |tee out || true
26e710
+grep "active" out
26e710
+
26e710
+vgchange -an $vg
26e710
+
26e710
+aux udev_wait
26e710
+
26e710
+vgremove -f $vg
26e710
+
26e710
+aux cleanup_md_dev
26e710
+
26e710
+# Repeat tests using the default config settings
26e710
+
26e710
+aux lvmconf 'devices/hints = "all"'
26e710
+aux lvmconf 'devices/obtain_device_list_from_udev = 1'
26e710
+
26e710
+# create 2 disk MD raid0 array
26e710
+# by default using metadata format 1.0 with data at the end of device
26e710
+# When a raid0 md array is stopped, the components will not look like
26e710
+# duplicate PVs as they do with raid1.
26e710
+aux prepare_md_dev 0 64 2 "$dev1" "$dev2"
26e710
+
26e710
+cat /proc/mdstat
26e710
+
26e710
+mddev=$(< MD_DEV)
26e710
+pvdev=$(< MD_DEV_PV)
26e710
+
26e710
+# Create an unused PV so that there is at least one PV in the hints
26e710
+# when the MD dev is stopped.  If there are no PVs, the hints are
26e710
+# empty, and the code falls back to scanning all, and we do not end
26e710
+# up testing the code with hints actively used.
26e710
+pvcreate "$dev3"
26e710
+
26e710
+vgcreate $vg "$mddev"
26e710
+
26e710
+PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
26e710
+echo $PVIDMD
26e710
+
26e710
+lvcreate -n $lv1 -l 2 $vg
26e710
+lvcreate -n $lv2 -l 2 -an $vg
26e710
+
26e710
+lvchange -ay $vg/$lv2
26e710
+check lv_field $vg/$lv1 lv_active "active"
26e710
+
26e710
+# lvm does not show md components as PVs
26e710
+pvs "$mddev"
26e710
+not pvs "$dev1"
26e710
+not pvs "$dev2"
26e710
+pvs > out
26e710
+not grep "$dev1" out
26e710
+not grep "$dev2" out
26e710
+
26e710
+grep "$mddev" /run/lvm/hints
26e710
+grep "$dev3" /run/lvm/hints
26e710
+not grep "$dev1" /run/lvm/hints
26e710
+not grep "$dev2" /run/lvm/hints
26e710
+
26e710
+sleep 1
26e710
+
26e710
+vgchange -an $vg
26e710
+sleep 1
26e710
+
26e710
+# When the md device is started, lvm will see that and know to
26e710
+# scan for md components, so stop the md device to remove this
26e710
+# advantage so we will test the fallback detection.
26e710
+mdadm --stop "$mddev"
26e710
+aux udev_wait
26e710
+
26e710
+# A WARNING indicating duplicate PVs is printed by 'pvs' in this
26e710
+# case.  It's printed during the scan, but after the scan, the
26e710
+# md component detection is run on the devs and they are dropped
26e710
+# when we see they are md components. So, we ignore the warning
26e710
+# containing the word duplicate, and look for the "Not using device"
26e710
+# message, which shouldn't appear, as it would indicate that
26e710
+# we didn't drop the md components.
26e710
+# FIXME: we should avoid printing the premature warning indicating
26e710
+# duplicate PVs which are eventually recognized as md components
26e710
+# and dropped.
26e710
+pvs 2>&1|tee out1
26e710
+grep -v WARNING out1 > out2
26e710
+not grep "Not using device" out2
26e710
+not grep "$mddev" out2
26e710
+not grep "$dev1" out2
26e710
+not grep "$dev2" out2
26e710
+grep "$dev3" out2
26e710
+cat /run/lvm/hints
26e710
+
26e710
+pvs 2>&1|tee out1
26e710
+grep -v WARNING out1 > out2
26e710
+not grep "Not using device" out2
26e710
+not grep "$mddev" out2
26e710
+not grep "$dev1" out2
26e710
+not grep "$dev2" out2
26e710
+grep "$dev3" out2
26e710
+cat /run/lvm/hints
26e710
 
26e710
+# The md components should still be detected and excluded.
26e710
 not pvs "$dev1"
26e710
 not pvs "$dev2"
26e710
 pvs > out
26e710
 not grep "$dev1" out
26e710
 not grep "$dev2" out
26e710
+grep "$dev3" out
26e710
 
26e710
-vgchange -ay $vg 2>&1 |tee out
26e710
+# should not activate from the md legs
26e710
+not vgchange -ay $vg
26e710
+
26e710
+# should not show an active lv
26e710
+rm out
26e710
+lvs -o active $vg |tee out || true
26e710
+not grep "active" out
26e710
+
26e710
+# should not allow updating vg
26e710
+not lvcreate -l1 $vg
26e710
+
26e710
+# should not activate from the md legs
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$dev1"
26e710
+pvscan --cache -aay "$dev2"
26e710
+
26e710
+not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+not ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+# should not show an active lv
26e710
+rm out
26e710
+lvs -o active $vg |tee out || true
26e710
+not grep "active" out
26e710
+
26e710
+# start the md dev
26e710
+mdadm --assemble "$mddev" "$dev1" "$dev2"
26e710
+aux udev_wait
26e710
+
26e710
+not pvs "$dev1"
26e710
+not pvs "$dev2"
26e710
+pvs > out
26e710
+not grep "$dev1" out
26e710
+not grep "$dev2" out
26e710
+
26e710
+lvs $vg
26e710
+vgchange -an $vg
26e710
+
26e710
+# should not activate from the md legs
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$dev1"
26e710
+pvscan --cache -aay "$dev2"
26e710
+
26e710
+not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+not ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+# should not show an active lv
26e710
+rm out
26e710
+lvs -o active $vg |tee out || true
26e710
+not grep "active" out
26e710
+
26e710
+vgchange -ay $vg
26e710
 
26e710
 check lv_field $vg/$lv1 lv_active "active"
26e710
 
26e710
 vgchange -an $vg
26e710
+
26e710
+_clear_online_files
26e710
+pvscan --cache -aay "$mddev"
26e710
+
26e710
+ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
26e710
+ls "$RUNDIR/lvm/vgs_online/$vg"
26e710
+
26e710
+lvs -o active $vg |tee out || true
26e710
+grep "active" out
26e710
+
26e710
+vgchange -an $vg
26e710
+
26e710
 aux udev_wait
26e710
 
26e710
 vgremove -f $vg