main - tests: set known locking dir
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7575c7ae5c012c4a20b...
Commit: 7575c7ae5c012c4a20bd4c2563640880f522789c
Parent: f370cda716f14d0ba1ba97fa3dd5887d5165b140
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 23 01:15:29 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 23 01:15:29 2021 +0100
tests: set known locking dir
Tests running in the system may use locking dir of the system.
---
test/shell/lock-blocking.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/shell/lock-blocking.sh b/test/shell/lock-blocking.sh
index 06f1a7ab0..9defaf2c7 100644
--- a/test/shell/lock-blocking.sh
+++ b/test/shell/lock-blocking.sh
@@ -17,6 +17,9 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+# Make sure the placement of locking dir is known
+aux lvmconf "global/locking_dir = \"$TESTDIR/var/lock/lvm\""
+
aux prepare_devs 3
pvcreate "$dev1" "$dev2"
vgcreate $SHARED $vg "$dev1" "$dev2"
3 years
main - make: add few more predef symbols for cflow
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f370cda716f14d0ba1b...
Commit: f370cda716f14d0ba1ba97fa3dd5887d5165b140
Parent: 0993355300fa8490163579a320d1b289c7db59af
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 20 19:02:41 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:51:24 2021 +0100
make: add few more predef symbols for cflow
---
make.tmpl.in | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index d95d956fa..99998f9fd 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -404,7 +404,10 @@ ifneq ("$(CFLOW_CMD)", "")
CFLOW_FLAGS +=\
--cpp="$(CC) -E $(INCLUDES) $(VALGRIND_CFLAGS) $(BLKID_CFLAGS) $(DEFS)" \
--symbol _ISbit:wrapper \
+ --symbol __asm__:wrapper \
--symbol __attribute__:wrapper \
+ --symbol __inline:=inline \
+ --symbol __inline__:=inline \
--symbol __const:type \
--symbol __const__:wrapper \
--symbol __extension__:wrapper \
@@ -414,7 +417,7 @@ CFLOW_FLAGS +=\
--symbol __pure__:wrapper \
--symbol __REDIRECT:wrapper \
--symbol __REDIRECT_NTH:wrapper \
- --symbol __restrict:type \
+ --symbol __restrict:=restrict \
--symbol __wur:wrapper
$(CFLOW_TARGET).cflow: $(CFLOW_SOURCES)
3 years
main - configure: use rawhide version
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0993355300fa8490163...
Commit: 0993355300fa8490163579a320d1b289c7db59af
Parent: 077040199d98e939446d4b51597eeeae84ae28d5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 18:51:21 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:51:24 2021 +0100
configure: use rawhide version
---
configure | 25 ++++++++++++++++++-------
include/configure.h.in | 3 ---
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/configure b/configure
index 0be9f136c..ff363b046 100755
--- a/configure
+++ b/configure
@@ -868,6 +868,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1060,6 +1061,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1312,6 +1314,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1449,7 +1460,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1602,6 +1613,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -12946,12 +12958,12 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$EDITLINE_PKG_ERRORS" >&5
- as_fn_error $? "libedit could not be found which is required for the --enable-readline option." "$LINENO" 5
+ as_fn_error $? "libedit could not be found which is required for the --enable-editline option." "$LINENO" 5
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- as_fn_error $? "libedit could not be found which is required for the --enable-readline option." "$LINENO" 5
+ as_fn_error $? "libedit could not be found which is required for the --enable-editline option." "$LINENO" 5
else
EDITLINE_CFLAGS=$pkg_cv_EDITLINE_CFLAGS
@@ -13406,11 +13418,10 @@ $as_echo "$READLINE" >&6; }
if test "$EDITLINE" = yes; then
for ac_header in editline/readline.h
do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ ac_fn_c_check_header_mongrel "$LINENO" "editline/readline.h" "ac_cv_header_editline_readline_h" "$ac_includes_default"
+if test "x$ac_cv_header_editline_readline_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define HAVE_EDITLINE_READLINE_H 1
_ACEOF
else
diff --git a/include/configure.h.in b/include/configure.h.in
index 59b4da86f..b8d95833a 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -182,9 +182,6 @@
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
-/* Define to 1 if you have the <editline/history.h> header file. */
-#undef HAVE_EDITLINE_HISTORY_H
-
/* Define to 1 if you have the <editline/readline.h> header file. */
#undef HAVE_EDITLINE_READLINE_H
3 years
main - tests: remove unused wait_md_create
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=077040199d98e939446...
Commit: 077040199d98e939446d4b51597eeeae84ae28d5
Parent: 7166bbd9c26cf5d06067cfb85eb86352b4152c3c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 22:07:23 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:51:24 2021 +0100
tests: remove unused wait_md_create
---
test/lib/aux.sh | 80 ---------------------------------------------------------
1 file changed, 80 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index e406e47ce..e26aa9912 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -421,16 +421,9 @@ teardown_devs() {
teardown_udev_cookies
test ! -f MD_DEV || cleanup_md_dev
-
- test ! -f WAIT_MD_DEV || mddev=$(< WAIT_MD_DEV)
- udev_wait
- test ! -f WAIT_MD_DEV || mdadm --stop $mddev || true
- udev_wait
test ! -f DEVICES || teardown_devs_prefixed "$PREFIX"
test ! -f RAMDISK || { modprobe -r brd || true ; }
- test ! -f WAIT_MD_DEV || mdadm --stop $mddev || true
-
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
# prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop()
if test -f SCSI_DEBUG_DEV; then
@@ -716,64 +709,6 @@ cleanup_scsi_debug_dev() {
rm -f SCSI_DEBUG_DEV LOOP
}
-prepare_md_dev() {
- local level=$1
- local rchunk=$2
- local rdevs=$3
- local with_bitmap="--bitmap=internal"
- local coption="--chunk"
- local maj
- local mddev
- local mddir="md/"
- local mdname
- local mddevdir
- maj=$(mdadm --version 2>&1) || skip "mdadm tool is missing!"
-
- cleanup_md_dev
-
- rm -f debug.log strace.log
-
- case "$level" in
- "1") coption="--bitmap-chunk" ;;
- "0") with_bitmap="" ;;
- esac
- # Have MD use a non-standard name to avoid colliding with an existing MD device
- # - mdadm >= 3.0 requires that non-standard device names be in /dev/md/
- # - newer mdadm _completely_ defers to udev to create the associated device node
- maj=${maj##*- v}
- maj=${maj%%.*}
- [ "$maj" -ge 3 ] || mddir=""
-
- mdname="md_lvm_test0"
- mddev="/dev/${mddir}$mdname"
- mddevdir="$DM_DEV_DIR/$mddir"
-
- mdadm --create --metadata=1.0 "$mddev" --auto=md --level "$level" $with_bitmap "$coption"="$rchunk" --raid-devices="$rdevs" "${@:4}" || {
- # Some older 'mdadm' version managed to open and close devices internaly
- # and reporting non-exclusive access on such device
- # let's just skip the test if this happens.
- # Note: It's pretty complex to get rid of consequences
- # the following sequence avoid leaks on f19
- # TODO: maybe try here to recreate few times....
- mdadm --stop "$mddev" || true
- udev_wait
- mdadm --zero-superblock "${@:4}" || true
- udev_wait
- skip "Test skipped, unreliable mdadm detected!"
- }
- test -b "$mddev" || skip "mdadm has not created device!"
-
- # LVM/DM will see this device
- case "$DM_DEV_DIR" in
- "/dev") readlink -f "$mddev" > MD_DEV_PV ;;
- *) mkdir -p "$mddevdir"
- cp -LR "$mddev" "$mddevdir"
- echo "${mddevdir}${mdname}" > MD_DEV_PV ;;
- esac
- echo "$mddev" > MD_DEV
- printf "%s\n" "${@:4}" > MD_DEVICES
-}
-
mdadm_create() {
local mddev
local maj=
@@ -872,21 +807,6 @@ 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
- echo "$md" > WAIT_MD_DEV
-}
-
wipefs_a() {
local dev=$1
shift
3 years
main - tests: avoid sleep on kill path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7166bbd9c26cf5d0606...
Commit: 7166bbd9c26cf5d06067cfb85eb86352b4152c3c
Parent: a7d7471906501eebb6cf418ab3d0d9326805449f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 22:05:22 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:51:24 2021 +0100
tests: avoid sleep on kill path
Before sleeping, check if pid is still there.
---
test/lib/aux.sh | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 2bc3da2c9..e406e47ce 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -466,12 +466,10 @@ kill_sleep_kill_() {
pid=$(< "$pidfile")
rm -f "$pidfile"
kill -TERM "$pid" 2>/dev/null || return 0
- if test "$slow" -eq 0 ; then sleep .1 ; else sleep 1 ; fi
- kill -KILL "$pid" 2>/dev/null || true
- local wait=0
- while ps "$pid" > /dev/null && test "$wait" -le 10; do
- sleep .5
- wait=$(( wait + 1 ))
+ for i in {0..10} ; do
+ ps "$pid" >/dev/null || return 0
+ if test "$slow" -eq 0 ; then sleep .2 ; else sleep 1 ; fi
+ kill -KILL "$pid" 2>/dev/null || true
done
fi
}
3 years
main - tests: convert to use mdadm_create
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a7d7471906501eebb6c...
Commit: a7d7471906501eebb6cf418ab3d0d9326805449f
Parent: b1483dcbac0ffbc3e449e6fb8b17988203f45c57
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 22:23:53 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:50:36 2021 +0100
tests: convert to use mdadm_create
Flip usage from prepare_md_dev to mdadm_create.
---
test/shell/pvcreate-md-fake-hdr.sh | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/test/shell/pvcreate-md-fake-hdr.sh b/test/shell/pvcreate-md-fake-hdr.sh
index 82dd8d4bb..1550bc4c0 100644
--- a/test/shell/pvcreate-md-fake-hdr.sh
+++ b/test/shell/pvcreate-md-fake-hdr.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2018-2021 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -26,16 +26,17 @@ aux extend_filter_LVMTEST "a|/dev/md|"
aux prepare_devs 4
pvcreate "$dev2"
-aux prepare_md_dev 0 64 2 "$dev1" "$dev2"
-# Incorrectly shows $dev2 as PV for 'raid0'
-pvs -vvvv
+aux mdadm_create --metadata=1.0 --level=0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+
+pvs | tee out
+not grep pv2 out
vgcreate $SHARED $vg "$dev3" "$dev4"
# create 2 disk MD raid1 array
# by default using metadata format 1.0 with data at the end of device
-aux prepare_md_dev 1 64 2 "$dev1" "$dev2"
+aux mdadm_create --metadata=1.0 --level=1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
mddev=$(< MD_DEV)
pvdev=$(< MD_DEV_PV)
@@ -51,8 +52,8 @@ vgremove -f $vg
sleep 3
aux udev_wait
# too bad 'dd' wakes up md array reassembling
-should not mdadm --detail "$mddev"
-should not mdadm --stop "$mddev"
+mdadm --detail "$mddev" || true
+mdadm --stop "$mddev" || true
sleep 3
# print what blkid thinks about each PV
@@ -64,12 +65,12 @@ done
# expect open count for each PV to be 0
dmsetup info -c
-pvs -vvvv "$dev2" "$dev3" || true
+pvs "$dev2" "$dev3" || true
# still expect open count for each PV to be 0
dmsetup info -c
-pvs -vvvv "$dev3" "$dev2" || true
+pvs "$dev3" "$dev2" || true
# and again we expect open count for each PV to be 0
dmsetup info -c
@@ -97,5 +98,5 @@ if mdadm --action=repair "$mddev" ; then
sleep 1
pvscan -vvvv
# should be showing correctly PV3 & PV4
- pvs -vvvv "$dev3" "$dev4"
+ pvs "$dev3" "$dev4"
fi
3 years
main - tests: more usage of new aux mdadm_create
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b1483dcbac0ffbc3e44...
Commit: b1483dcbac0ffbc3e449e6fb8b17988203f45c57
Parent: 76d203517bc78508234706f3ee5ce8ce6d38bee4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 21:45:39 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:49:11 2021 +0100
tests: more usage of new aux mdadm_create
Condense tests and use the new mdadm_create.
---
test/shell/lvm-on-md.sh | 262 +++++++-----------------------------
test/shell/pvcreate-operation-md.sh | 23 +---
2 files changed, 59 insertions(+), 226 deletions(-)
diff --git a/test/shell/lvm-on-md.sh b/test/shell/lvm-on-md.sh
index 910ebc742..22d5b4ca4 100644
--- a/test/shell/lvm-on-md.sh
+++ b/test/shell/lvm-on-md.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2018-2021 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -22,166 +22,40 @@ HINTS="$RUNDIR/lvm/hints"
_clear_online_files() {
# wait till udev is finished
aux udev_wait
- rm -f "$PVS_ONLINE_DIR"/*
- rm -f "$VGS_ONLINE_DIR"/*
+ rm -f "$PVS_ONLINE_DIR"/* "$VGS_ONLINE_DIR"/*
}
. lib/inittest
-test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
- modprobe raid1 || skip
-
-mddev="/dev/md33"
-not grep $mddev /proc/mdstat || skip
-
-aux lvmconf 'devices/md_component_detection = 1'
# This stops lvm from taking advantage of hints which
# will have already excluded md components.
-aux lvmconf 'devices/hints = "none"'
# This stops lvm from asking udev if a dev is an md component.
# LVM will ask udev if a dev is an md component, but we don't
# want to rely on that ability in this test.
-aux lvmconf 'devices/obtain_device_list_from_udev = 0'
+aux lvmconf "devices/md_component_detection = 1" \
+ "devices/hints = \"none\"" \
+ "devices/obtain_device_list_from_udev = 0"
aux extend_filter_md "a|/dev/md|"
aux prepare_devs 3
-# create 2 disk MD raid1 array
-# by default using metadata format 1.0 with data at the end of device
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-vgcreate $vg "$mddev"
-
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-
-lvcreate -n $lv1 -l 2 $vg
-lvcreate -n $lv2 -l 2 -an $vg
-
-lvchange -ay $vg/$lv2
-check lv_field $vg/$lv1 lv_active "active"
-
-# lvm does not show md components as PVs
-pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep "$dev1" out
-not grep "$dev2" out
-
-sleep 1
-
-vgchange -an $vg
-sleep 1
-
-# When the md device is started, lvm will see that and know to
-# scan for md components, so stop the md device to remove this
-# advantage so we will test the fallback detection.
-mdadm --stop "$mddev"
-aux udev_wait
-
-# The md components should still be detected and excluded.
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep "$dev1" out
-not grep "$dev2" out
-
-pvs 2>&1|tee out
-not grep "Not using device" out
-
-# should not activate from the md legs
-not vgchange -ay $vg
-
-# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
-
-# should not allow updating vg
-not lvcreate -l1 $vg
-
-# should not activate from the md legs
-_clear_online_files
-pvscan --cache -aay "$dev1"
-pvscan --cache -aay "$dev2"
-
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
-
-mdadm --assemble "$mddev" "$dev1" "$dev2"
-aux udev_wait
+for level in 1 0 ; do
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep "$dev1" out
-not grep "$dev2" out
-
-lvs $vg
-vgchange -an $vg
-
-# should not activate from the md legs
-_clear_online_files
-pvscan --cache -aay "$dev1"
-pvscan --cache -aay "$dev2"
-
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
-
-vgchange -ay $vg
-
-check lv_field $vg/$lv1 lv_active "active"
-
-vgchange -an $vg
-
-_clear_online_files
-pvscan --cache -aay "$mddev"
-
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-
-lvs -o active $vg |tee out || true
-grep "active" out
-
-vgchange -an $vg
-
-aux udev_wait
-
-vgremove -f $vg
-
-mdadm --stop "$mddev"
-aux udev_wait
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
-
-
-# create 2 disk MD raid0 array
+# create 2 disk MD raid1 array
# by default using metadata format 1.0 with data at the end of device
+#
# When a raid0 md array is stopped, the components will not look like
# duplicate PVs as they do with raid1.
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
+aux mdadm_create --metadata=1.0 --level=$level --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+mddev=$(< MD_DEV)
+
vgcreate $vg "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
+PVIDMD=$(get pv_field "$mddev" uuid | tr -d - )
lvcreate -n $lv1 -l 2 $vg
lvcreate -n $lv2 -l 2 -an $vg
@@ -193,14 +67,11 @@ check lv_field $vg/$lv1 lv_active "active"
pvs "$mddev"
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
+pvs | tee out
not grep "$dev1" out
not grep "$dev2" out
-sleep 1
-
vgchange -an $vg
-sleep 1
# When the md device is started, lvm will see that and know to
# scan for md components, so stop the md device to remove this
@@ -211,7 +82,7 @@ aux udev_wait
# The md components should still be detected and excluded.
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
+pvs | tee out
not grep "$dev1" out
not grep "$dev2" out
@@ -222,9 +93,7 @@ not grep "Not using device" out
not vgchange -ay $vg
# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
+not dmsetup table $vg-$lv1
# should not allow updating vg
not lvcreate -l1 $vg
@@ -234,21 +103,18 @@ _clear_online_files
pvscan --cache -aay "$dev1"
pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
+not dmsetup table $vg-$lv1
-# start the md dev
mdadm --assemble "$mddev" "$dev1" "$dev2"
aux udev_wait
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
+pvs | tee out
not grep "$dev1" out
not grep "$dev2" out
@@ -260,13 +126,11 @@ _clear_online_files
pvscan --cache -aay "$dev1"
pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
+not dmsetup table $vg-$lv1
vgchange -ay $vg
@@ -277,37 +141,34 @@ vgchange -an $vg
_clear_online_files
pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
+test -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test -f "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
+check active $vg $lv1
vgchange -an $vg
-
-aux udev_wait
-
vgremove -f $vg
-mdadm --stop "$mddev"
-aux udev_wait
+aux cleanup_md_dev
aux wipefs_a "$dev1"
aux wipefs_a "$dev2"
aux udev_wait
+done
+
# Repeat tests using the default config settings
-aux lvmconf 'devices/hints = "all"'
-aux lvmconf 'devices/obtain_device_list_from_udev = 1'
+aux lvmconf "devices/hints = \"all\"" \
+ "devices/obtain_device_list_from_udev = 1"
# create 2 disk MD raid0 array
# by default using metadata format 1.0 with data at the end of device
# When a raid0 md array is stopped, the components will not look like
# duplicate PVs as they do with raid1.
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
+aux mdadm_create --metadata=1.0 --level=0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+mddev=$(< MD_DEV)
# Create an unused PV so that there is at least one PV in the hints
# when the MD dev is stopped. If there are no PVs, the hints are
@@ -317,8 +178,7 @@ pvcreate "$dev3"
vgcreate $vg "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
+PVIDMD=$(get pv_field "$mddev" uuid | tr -d - )
lvcreate -n $lv1 -l 2 $vg
lvcreate -n $lv2 -l 2 -an $vg
@@ -334,15 +194,12 @@ pvs > out
not grep "$dev1" out
not grep "$dev2" out
-grep "$mddev" $HINTS
-grep "$dev3" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-sleep 1
+grep "$mddev" "$HINTS"
+grep "$dev3" "$HINTS"
+not grep "$dev1" "$HINTS"
+not grep "$dev2" "$HINTS"
vgchange -an $vg
-sleep 1
# When the md device is started, lvm will see that and know to
# scan for md components, so stop the md device to remove this
@@ -367,7 +224,7 @@ not grep "$mddev" out2
not grep "$dev1" out2
not grep "$dev2" out2
grep "$dev3" out2
-cat $HINTS
+cat "$HINTS"
pvs 2>&1|tee out1
grep -v WARNING out1 > out2
@@ -376,12 +233,12 @@ not grep "$mddev" out2
not grep "$dev1" out2
not grep "$dev2" out2
grep "$dev3" out2
-cat $HINTS
+cat "$HINTS"
# The md components should still be detected and excluded.
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
+pvs | tee out
not grep "$dev1" out
not grep "$dev2" out
grep "$dev3" out
@@ -390,9 +247,7 @@ grep "$dev3" out
not vgchange -ay $vg
# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
+not dmsetup table $vg-$lv1
# should not allow updating vg
not lvcreate -l1 $vg
@@ -402,13 +257,11 @@ _clear_online_files
pvscan --cache -aay "$dev1"
pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
+not dmsetup table $vg-$lv1
# start the md dev
mdadm --assemble "$mddev" "$dev1" "$dev2"
@@ -416,7 +269,7 @@ aux udev_wait
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
+pvs | tee out
not grep "$dev1" out
not grep "$dev2" out
@@ -428,13 +281,11 @@ _clear_online_files
pvscan --cache -aay "$dev1"
pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
# should not show an active lv
-rm out
-lvs -o active $vg |tee out || true
-not grep "active" out
+not dmsetup table $vg-$lv1
vgchange -ay $vg
@@ -445,21 +296,12 @@ vgchange -an $vg
_clear_online_files
pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
+test -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test -f "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
+check active $vg $lv1
vgchange -an $vg
-
-aux udev_wait
-
vgremove -f $vg
-mdadm --stop "$mddev"
-aux udev_wait
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
-
+aux cleanup_md_dev
diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh
index f4b2a0d92..fa76eb459 100644
--- a/test/shell/pvcreate-operation-md.sh
+++ b/test/shell/pvcreate-operation-md.sh
@@ -18,19 +18,14 @@ SKIP_WITH_LVMPOLLD=1
# skip this test if mdadm or sfdisk (or others) aren't available
which sfdisk || skip
-test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
- modprobe raid0 || skip
-mddev="/dev/md33"
-not grep $mddev /proc/mdstat || skip
-
aux lvmconf 'devices/md_component_detection = 1'
aux extend_filter_md "a|/dev/md|"
aux prepare_devs 2
# create 2 disk MD raid0 array (stripe_width=128K)
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
+aux mdadm_create --metadata=1.0 --level=0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+mddev=$(< MD_DEV)
pvdev="$mddev"
@@ -111,17 +106,16 @@ EOF
fi
fi
-mdadm --stop "$mddev"
-aux udev_wait
+aux cleanup_md_dev
aux wipefs_a "$dev1"
aux wipefs_a "$dev2"
-aux udev_wait
# Test newer topology-aware alignment detection w/ --dataalignment override
if aux kernel_at_least 2 6 33 ; then
- mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=1024 --raid-devices=2 "$dev1" "$dev2"
- aux wait_md_create "$mddev"
+ aux mdadm_create --metadata=1.0 --level 0 --chunk=1024 --raid-devices=2 "$dev1" "$dev2"
+ mddev=$(< MD_DEV)
+
pvdev="$mddev"
# optimal_io_size=2097152, minimum_io_size=1048576
@@ -138,10 +132,7 @@ if aux kernel_at_least 2 6 33 ; then
--config 'devices { md_chunk_alignment=0 }' "$pvdev"
check pv_field "$pvdev" pe_start "192.00k"
- mdadm --stop "$mddev"
- aux udev_wait
+ aux cleanup_md_dev
aux wipefs_a "$dev1"
aux wipefs_a "$dev2"
- aux udev_wait
-
fi
3 years
main - tests: use mdadm support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=76d203517bc78508234...
Commit: 76d203517bc78508234706f3ee5ce8ce6d38bee4
Parent: ada99f939fe24e23994244fdbe960014b355fd44
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 18:55:07 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:46:21 2021 +0100
tests: use mdadm support
Use for testing new mdadm_create aux wrapper.
Place functionality into a 2 pass loop - one for 'auto' other for 'start'.
Share same tests between raid level 0 and level 1 version of raid.
---
test/shell/duplicate-pvs-md0.sh | 381 +++++++++------------------
test/shell/duplicate-pvs-md1.sh | 570 +---------------------------------------
2 files changed, 129 insertions(+), 822 deletions(-)
diff --git a/test/shell/duplicate-pvs-md0.sh b/test/shell/duplicate-pvs-md0.sh
index 6ff9ba245..82a179915 100644
--- a/test/shell/duplicate-pvs-md0.sh
+++ b/test/shell/duplicate-pvs-md0.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2012-2021 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -22,28 +22,14 @@ HINTS="$RUNDIR/lvm/hints"
_clear_online_files() {
# wait till udev is finished
aux udev_wait
- rm -f "$PVS_ONLINE_DIR"/*
- rm -f "$VGS_ONLINE_DIR"/*
+ rm -f "$PVS_ONLINE_DIR"/* "$VGS_ONLINE_DIR"/*
}
. lib/inittest
-test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
- modprobe raid0 || skip
+MD_LEVEL=${MD_LEVEL-0}
-mddev="/dev/md33"
-not grep $mddev /proc/mdstat || skip
-
-aux lvmconf 'devices/md_component_detection = 1'
-
-# This stops lvm from asking udev if a dev is an md component.
-# LVM will ask udev if a dev is an md component, but we don't
-# want to rely on that ability in this test.
-aux lvmconf 'devices/obtain_device_list_from_udev = 0'
-
-aux extend_filter_md "a|/dev/md|"
-
-aux prepare_devs 4
+aux prepare_devs 4 10
# Create an unused PV so that there is at least one PV in the hints
# when the MD dev is stopped. If there are no PVs, the hints are
@@ -55,92 +41,28 @@ pvcreate "$dev3"
# PV on md raid1|raid0, md_component_checks auto|start, mddev start|stopped,
# one raid dev disabled when mddev is stopped.
+# LVM will ask udev if a dev is an md component, but we don't
+# want to rely on that ability in this test so stops lvm from
+# asking udev if a dev is an md component.
+aux lvmconf "devices/obtain_device_list_from_udev = 0" \
+ "devices/md_component_detection = 1" \
+ "devices/md_component_checks = \"auto\""
-##########################################
-# PV on an md raid0 device, auto+started
-# md_component_checks: auto (not start)
-# mddev: started (not stopped)
-#
-
-aux lvmconf 'devices/md_component_checks = "auto"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-# pvs shows only the md dev as PV
-pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# normal activation works
-lvchange -ay $vg/$lv1
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation all works
-_clear_online_files
-pvscan --cache -aay
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation from mddev works
-_clear_online_files
-pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation from md components does nothing
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-not grep "active" out
-
-vgchange -an $vg
-vgremove -f $vg
-mdadm --stop "$mddev"
-aux udev_wait
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
+aux extend_filter_md "a|/dev/md|"
+# Run in 2 passes - 1st. with "auto" 2nd. with "start" component checks
+for pass in "auto" "start" ; do
##########################################
-# PV on an md raid0 device, start+started
-# md_component_checks: start (not auto)
-# mddev: started (not stopped)
+# PV on an md raidX device
+# md_component_checks: auto|start (not start)
+# mddev: started (not stopped)
#
+aux mdadm_create --metadata=1.0 --level="$MD_LEVEL" --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+mddev=$(< MD_DEV)
-aux lvmconf 'devices/md_component_checks = "start"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
+PVIDMD=$(get pv_field "$mddev" uuid | tr -d - )
vgcreate $vg "$mddev"
lvcreate -n $lv1 -l 2 -an $vg
@@ -148,71 +70,68 @@ lvcreate -n $lv1 -l 2 -an $vg
pvs "$mddev"
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
-grep $mddev out
+pvs | tee out
+grep "$mddev" out
not grep "$dev1" out
not grep "$dev2" out
# N.B. in this case hints are disabled for duplicate pvs seen by scan
# it would be preferrable if this didn't happen as in auto mode, but it's ok.
-# grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
+test "$pass" = "auto" && grep "$mddev" "$HINTS"
+not grep "$dev1" "$HINTS"
+not grep "$dev2" "$HINTS"
# normal activation works
lvchange -ay $vg/$lv1
-lvs -o active $vg |tee out || true
-grep "active" out
+check active $vg $lv1
vgchange -an $vg
# pvscan activation all works
_clear_online_files
pvscan --cache -aay
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
+test -e "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test -e "$RUNDIR/lvm/vgs_online/$vg"
+check active $vg $lv1
vgchange -an $vg
# pvscan activation from mddev works
_clear_online_files
pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
+test -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test -f "$RUNDIR/lvm/vgs_online/$vg"
+check active $vg $lv1
vgchange -an $vg
-# N.B. with raid0 the component because the PV/size difference
-# triggers and md component check, whereas with raid1 it doesn't.
+# pvscan activation from md components does nothing
_clear_online_files
pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-not grep "active" out
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
+
+if [ "$pass" = "auto" ] ; then
+ pvscan --cache -aay "$dev2"
+ test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+ test ! -f "$RUNDIR/lvm/vgs_online/$vg"
+fi
+# N.B. with raid0 the component because the PV/size difference
+# triggers and md component check, whereas with raid1 it doesn't.
+check inactive $vg $lv1
vgchange -an $vg
vgremove -f $vg
-mdadm --stop "$mddev"
-aux udev_wait
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
+aux cleanup_md_dev
##########################################
-# PV on an md raid0 device, auto+stopped
-# md_component_checks: auto (not start)
-# mddev: stopped (not started)
+# PV on an md raidX device
+# md_component_checks: auto|start
+# mddev: stopped (not started)
#
-aux lvmconf 'devices/md_component_checks = "auto"'
+aux mdadm_create --metadata=1.0 --level="$MD_LEVEL" --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+mddev=$(< MD_DEV)
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
+PVIDMD=$(get pv_field "$mddev" uuid | tr -d - )
vgcreate $vg "$mddev"
lvcreate -n $lv1 -l 2 -an $vg
@@ -223,14 +142,16 @@ cat /proc/mdstat
not pvs "$mddev"
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
-not grep $mddev out
+pvs | tee out
+not grep "$mddev" out
+# N.B. it would be preferrable if dev1 did not appear in hints but it's ok
+# not grep "$dev1" $HINTS
not grep "$dev1" out
not grep "$dev2" out
pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
+not grep "$mddev" "$HINTS"
+not grep "$dev1" "$HINTS"
+not grep "$dev2" "$HINTS"
# the vg is not seen, normal activation does nothing
not lvchange -ay $vg/$lv1
@@ -239,176 +160,120 @@ not lvs $vg
# pvscan activation all does nothing
_clear_online_files
pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
# pvscan activation from md components does nothing
_clear_online_files
pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
-
-##########################################
-# PV on an md raid0 device, start+stopped
-# md_component_checks: start (not auto)
-# mddev: stopped (not started)
-#
-
-aux lvmconf 'devices/md_component_checks = "start"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# pvs does not show the PV
-not pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-pvscan --cache
-not grep "$mddev" $HINTS
-# N.B. it would be preferrable if dev1 did not appear in hints but it's ok
-# not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# the vg is not seen, normal activation does nothing
-not lvchange -ay $vg/$lv1
-not lvs $vg
-
-# pvscan activation all does nothing
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
-# pvscan activation from md components does nothing
-_clear_online_files
-pvscan --cache -aay "$dev1" || true
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev2" || true
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-not grep "active" out
+#lvs -o active $vg |tee out || true
+#not grep "active" out
aux wipefs_a "$dev1"
aux wipefs_a "$dev2"
aux udev_wait
-
##########################################
-# PV on an md raid0 device, start+stopped
-# md_component_checks: start (not auto)
-# mddev: stopped (not started)
+# PV on an md raidX device
+# md_component_checks: auto|start
+# mddev: stopped (not started)
# only one raid dev online
#
-aux lvmconf 'devices/md_component_checks = "start"'
+aux mdadm_create --metadata=1.0 --level="$MD_LEVEL" --chunk=64 --raid-devices=2 "$dev1" "$dev2"
+mddev=$(< MD_DEV)
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
+PVIDMD=$(get pv_field "$mddev" uuid | tr -d - )
vgcreate $vg "$mddev"
lvcreate -n $lv1 -l 2 -an $vg
mdadm --stop "$mddev"
cat /proc/mdstat
-# disable one dev of the md device
+# disable one leg
aux disable_dev "$dev2"
# pvs does not show the PV
not pvs "$mddev"
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
-not grep $mddev out
+pvs | tee out
+not grep "$mddev" out
not grep "$dev1" out
not grep "$dev2" out
pvscan --cache
-not grep "$mddev" $HINTS
+not grep "$mddev" "$HINTS"
# N.B. would be preferrable for this md component to not be in hints
# grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
+not grep "$dev1" "$HINTS"
+not grep "$dev2" "$HINTS"
+# the vg is not seen, normal activation does nothing
not lvchange -ay $vg/$lv1
not lvs $vg
+# pvscan activation all does nothing
_clear_online_files
pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
+# pvscan activation from md components does nothing
_clear_online_files
pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
+pvscan --cache -aay "$dev2"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
aux enable_dev "$dev2"
-aux aux udev_wait
-cat /proc/mdstat
-# for some reason enabling dev2 starts an odd md dev
-mdadm --stop $(lsblk -al -o NAME --noheadings "$dev2" | grep '^md') || true
-cat /proc/mdstat
-aux wipefs_a "$dev1" || true
-aux wipefs_a "$dev2" || true
+aux cleanup_md_dev
+
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
aux udev_wait
+if [ "$MD_LEVEL" = "1" ] ; then
##########################################
-# PV on an md raid0 device, auto+stopped
-# md_component_checks: auto (not start)
-# mddev: stopped (not started)
-# only one raid dev online
+# PV on an md raid1 device, auto+stopped
+# md_component_checks: auto|start
+# mddev: stopped (not started)
+# three raid images
#
+aux mdadm_create --metadata=1.0 --level="$MD_LEVEL" --chunk=64 --raid-devices=3 "$dev1" "$dev2" "$dev4"
+mddev=$(< MD_DEV)
-aux lvmconf 'devices/md_component_checks = "auto"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 0 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
+PVIDMD=$(get pv_field "$mddev" uuid | tr -d - )
vgcreate $vg "$mddev"
lvcreate -n $lv1 -l 2 -an $vg
mdadm --stop "$mddev"
cat /proc/mdstat
-# disable one leg
-aux disable_dev "$dev2"
-
# pvs does not show the PV
not pvs "$mddev"
not pvs "$dev1"
not pvs "$dev2"
-pvs > out
-not grep $mddev out
+not pvs "$dev4"
+pvs | tee out
+not grep "$mddev" out
not grep "$dev1" out
not grep "$dev2" out
+not grep "$dev4" out
pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
+not grep "$mddev" "$HINTS"
+not grep "$dev1" "$HINTS"
+not grep "$dev2" "$HINTS"
+not grep "$dev4" "$HINTS"
# the vg is not seen, normal activation does nothing
not lvchange -ay $vg/$lv1
@@ -417,24 +282,28 @@ not lvs $vg
# pvscan activation all does nothing
_clear_online_files
pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
# pvscan activation from md components does nothing
_clear_online_files
pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
+pvscan --cache -aay "$dev4"
+test ! -f "$RUNDIR/lvm/pvs_online/$PVIDMD"
+test ! -f "$RUNDIR/lvm/vgs_online/$vg"
-aux enable_dev "$dev2"
-aux aux udev_wait
-cat /proc/mdstat
-# for some reason enabling dev2 starts an odd md dev
-mdadm --stop $(lsblk -al -o NAME --noheadings "$dev2" | grep '^md') || true
-cat /proc/mdstat
-aux wipefs_a "$dev1" || true
-aux wipefs_a "$dev2" || true
+aux wipefs_a "$dev1"
+aux wipefs_a "$dev2"
+aux wipefs_a "$dev4"
aux udev_wait
+fi # MD_LEVEL == 1
+
+# next loop with 'start'
+test "$pass" != "auto" || aux lvmconf "devices/md_component_checks = \"start\""
+
+done
diff --git a/test/shell/duplicate-pvs-md1.sh b/test/shell/duplicate-pvs-md1.sh
index d0016f166..e896c106a 100644
--- a/test/shell/duplicate-pvs-md1.sh
+++ b/test/shell/duplicate-pvs-md1.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2012-2021 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -15,569 +15,7 @@
# . dm wrapper around a PV
# . a single PV/VG cloned plus a dm wrapper (two separate dups of a PV)
-SKIP_WITH_LVMPOLLD=1
-SKIP_WITH_LVMLOCKD=1
-
-RUNDIR="/run"
-test -d "$RUNDIR" || RUNDIR="/var/run"
-PVS_ONLINE_DIR="$RUNDIR/lvm/pvs_online"
-VGS_ONLINE_DIR="$RUNDIR/lvm/vgs_online"
-HINTS="$RUNDIR/lvm/hints"
-
-_clear_online_files() {
- # wait till udev is finished
- aux udev_wait
- rm -f "$PVS_ONLINE_DIR"/*
- rm -f "$VGS_ONLINE_DIR"/*
-}
-
-. lib/inittest
-
-test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
- modprobe raid1 || skip
-
-mddev="/dev/md33"
-not grep $mddev /proc/mdstat || skip
-
-aux lvmconf 'devices/md_component_detection = 1'
-
-# This stops lvm from asking udev if a dev is an md component.
-# LVM will ask udev if a dev is an md component, but we don't
-# want to rely on that ability in this test.
-aux lvmconf 'devices/obtain_device_list_from_udev = 0'
-
-aux extend_filter_md "a|/dev/md|"
-
-aux prepare_devs 4
-
-# Create an unused PV so that there is at least one PV in the hints
-# when the MD dev is stopped. If there are no PVs, the hints are
-# empty, and the code falls back to scanning all, and we do not end
-# up testing the code with hints actively used.
-pvcreate "$dev3"
-
-## Test variations:
-# PV on md raid1|raid0, md_component_checks auto|start, mddev start|stopped,
-# one leg disabled when mddev is stopped.
-
-
-##########################################
-# PV on an md raid1 device, auto+started
-# md_component_checks: auto (not start)
-# mddev: started (not stopped)
-#
-
-aux lvmconf 'devices/md_component_checks = "auto"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-# pvs shows only the md dev as PV
-pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# normal activation works
-lvchange -ay $vg/$lv1
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation all works
-_clear_online_files
-pvscan --cache -aay
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation from mddev works
-_clear_online_files
-pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation from md components does nothing
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-not grep "active" out
-
-vgchange -an $vg
-vgremove -f $vg
-mdadm --stop "$mddev"
-aux udev_wait
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
-
-
-
-##########################################
-# PV on an md raid1 device, start+started
-# md_component_checks: start (not auto)
-# mddev: started (not stopped)
-#
-
-aux lvmconf 'devices/md_component_checks = "start"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-# pvs shows only the md dev as PV
-pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-# N.B. in this case hints are disabled for duplicate pvs seen by scan
-# it would be preferrable if this didn't happen as in auto mode, but it's ok.
-# grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# normal activation works
-lvchange -ay $vg/$lv1
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation all works
-_clear_online_files
-pvscan --cache -aay
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation from mddev works
-_clear_online_files
-pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-vgchange -an $vg
-
-# pvscan activation from component should do nothing
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-not grep "active" out
-
-# pvscan activation from mddev first, then try from component which fails
-_clear_online_files
-pvscan --cache -aay "$mddev"
-ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-ls "$RUNDIR/lvm/vgs_online/$vg"
-lvs -o active $vg |tee out || true
-grep "active" out
-rm "$RUNDIR/lvm/pvs_online/$PVIDMD"
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-
-
-vgchange -an $vg
-vgremove -f $vg
-mdadm --stop "$mddev"
-aux udev_wait
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
-
-
-##########################################
-# PV on an md raid1 device, auto+stopped
-# md_component_checks: auto (not start)
-# mddev: stopped (not started)
-#
-
-aux lvmconf 'devices/md_component_checks = "auto"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# pvs does not show the PV
-not pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# the vg is not seen, normal activation does nothing
-not lvchange -ay $vg/$lv1
-not lvs $vg
-
-# pvscan activation all does nothing
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-# pvscan activation from md components does nothing
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux udev_wait
-
-
-##########################################
-# PV on an md raid1 device, start+stopped
-# md_component_checks: start (not auto)
-# mddev: stopped (not started)
-#
-
-aux lvmconf 'devices/md_component_checks = "start"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# pvs does not show the PV
-not pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# the vg is not seen, normal activation does nothing
-rm $HINTS
-not lvs $vg
-not lvchange -ay $vg/$lv1
-
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux wipefs_a "$dev1" || true
-aux wipefs_a "$dev2" || true
-
-
-##########################################
-# PV on an md raid1 device, start+stopped
-# md_component_checks: start (not auto)
-# mddev: stopped (not started)
-# only one raid image online
-#
-
-aux lvmconf 'devices/md_component_checks = "start"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# disable one leg of the md device, with raid1 this means duplicates
-# will not be seen for the legs. duplicate handling can trigger
-# md component detection, so no duplicates means md components may
-# not be detected as easily.
-aux disable_dev "$dev2"
-
-# pvs does not show the PV
-rm $HINTS
-not pvs "$mddev"
-rm $HINTS
-not pvs "$dev1"
-rm $HINTS
-not pvs "$dev2"
-rm $HINTS
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-rm $HINTS
-pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-not lvs $vg
-
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-not lvs $vg
-
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux enable_dev "$dev2"
-aux udev_wait
-cat /proc/mdstat
-# for some reason enabling dev2 starts an odd md dev
-mdadm --stop $(lsblk -al -o NAME --noheadings "$dev2" | grep '^md') || true
-cat /proc/mdstat
-aux wipefs_a "$dev1" || true
-aux wipefs_a "$dev2" || true
-
-##########################################
-# PV on an md raid1 device, auto+stopped
-# md_component_checks: auto (not start)
-# mddev: stopped (not started)
-# only one raid image online
-#
-
-aux lvmconf 'devices/md_component_checks = "auto"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=2 "$dev1" "$dev2"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# disable one leg
-aux disable_dev "$dev2"
-
-# pvs does not show the PV
-not pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-
-# the vg is not seen, normal activation does nothing
-not lvchange -ay $vg/$lv1
-not lvs $vg
-
-# pvscan activation all does nothing
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-# pvscan activation from md components does nothing
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux enable_dev "$dev2"
-aux udev_wait
-cat /proc/mdstat
-# for some reason enabling dev2 starts an odd md dev
-mdadm --stop $(lsblk -al -o NAME --noheadings "$dev2" | grep '^md') || true
-cat /proc/mdstat
-aux wipefs_a "$dev1" || true
-aux wipefs_a "$dev2" || true
-
-
-##########################################
-# PV on an md raid1 device, auto+stopped
-# md_component_checks: auto (not start)
-# mddev: stopped (not started)
-# three raid images
-#
-
-aux lvmconf 'devices/md_component_checks = "auto"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=3 "$dev1" "$dev2" "$dev4"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# pvs does not show the PV
-not pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-not pvs "$dev4"
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-not grep "$dev4" out
-pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-not grep "$dev4" $HINTS
-
-# the vg is not seen, normal activation does nothing
-not lvchange -ay $vg/$lv1
-not lvs $vg
-
-# pvscan activation all does nothing
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-# pvscan activation from md components does nothing
-_clear_online_files
-pvscan --cache -aay "$dev1"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev2"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-pvscan --cache -aay "$dev4"
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux wipefs_a "$dev1"
-aux wipefs_a "$dev2"
-aux wipefs_a "$dev4"
-aux udev_wait
-
-
-
-##########################################
-# PV on an md raid1 device, start+stopped
-# md_component_checks: start (not auto)
-# mddev: stopped (not started)
-# three raid images
-
-aux lvmconf 'devices/md_component_checks = "start"'
-
-mdadm --create --metadata=1.0 "$mddev" --level 1 --chunk=64 --raid-devices=3 "$dev1" "$dev2" "$dev4"
-aux wait_md_create "$mddev"
-pvcreate "$mddev"
-PVIDMD=`pvs $mddev --noheading -o uuid | tr -d - | awk '{print $1}'`
-echo $PVIDMD
-vgcreate $vg "$mddev"
-lvcreate -n $lv1 -l 2 -an $vg
-
-mdadm --stop "$mddev"
-cat /proc/mdstat
-
-# pvs does not show the PV
-not pvs "$mddev"
-not pvs "$dev1"
-not pvs "$dev2"
-not pvs "$dev4"
-pvs > out
-not grep $mddev out
-not grep "$dev1" out
-not grep "$dev2" out
-not grep "$dev4" out
-pvscan --cache
-not grep "$mddev" $HINTS
-not grep "$dev1" $HINTS
-not grep "$dev2" $HINTS
-not grep "$dev4" $HINTS
-
-# the vg is not seen, normal activation does nothing
-not lvchange -ay $vg/$lv1
-not lvs $vg
-
-# pvscan activation all does nothing
-_clear_online_files
-pvscan --cache -aay
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-_clear_online_files
-pvscan --cache -aay "$dev1" || true
-not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
-not ls "$RUNDIR/lvm/vgs_online/$vg"
-
-aux enable_dev "$dev2"
-aux enable_dev "$dev4"
-aux udev_wait
-cat /proc/mdstat
-# for some reason enabling dev2 starts an odd md dev
-mdadm --stop $(lsblk -al -o NAME --noheadings "$dev2" | grep '^md') || true
-cat /proc/mdstat
-aux wipefs_a "$dev1" || true
-aux wipefs_a "$dev2" || true
-aux wipefs_a "$dev4" || true
+# Reuse same test just use raid level 1
+export MD_LEVEL=1
+. ./shell/duplicate-pvs-md0.sh
3 years
main - tests: new aux mdadm_create
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ada99f939fe24e23994...
Commit: ada99f939fe24e23994244fdbe960014b355fd44
Parent: 77432ee13742d09af5e8b1f8813d65bda3556a1d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 18:54:54 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:42:52 2021 +0100
tests: new aux mdadm_create
Add generic wrapper for mdadm --create which takes
normal 'mdadm' args - but allows us to handle differences of
mdadm usage across various version of mdadm tool.
Resulting MD device is availalble in $(< MD_DEV).
Automatic cleaning is made through cleanup_md_dev
Calling of mdadm_create cleans previous MD dev if it exists.
---
test/lib/aux.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 81 insertions(+), 10 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index ae173b8da..2bc3da2c9 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -776,8 +776,80 @@ prepare_md_dev() {
printf "%s\n" "${@:4}" > MD_DEVICES
}
+mdadm_create() {
+ local mddev
+ local maj=
+ local mdname="md_lvm_test0"
+ local mddir="md/"
+ local mddevdir="$DM_DEV_DIR/$mddir"
+
+ maj=$(mdadm --version 2>&1) || skip "mdadm tool is missing!"
+
+ cleanup_md_dev
+ rm -f debug.log strace.log
+
+ # Have MD use a non-standard name to avoid colliding with an existing MD device
+ # - mdadm >= 3.0 requires that non-standard device names be in /dev/md/
+ # - newer mdadm _completely_ defers to udev to create the associated device node
+ maj=${maj##*- v}
+ maj=${maj%%.*}
+ [ "$maj" -ge 3 ] || mddir=""
+
+ mddev="/dev/${mddir}$mdname"
+ name=$1
+
+ mdadm --create "$mddev" "$@" || {
+ # Some older 'mdadm' version managed to open and close devices internaly
+ # and reporting non-exclusive access on such device
+ # let's just skip the test if this happens.
+ # Note: It's pretty complex to get rid of consequences
+ # the following sequence avoid leaks on f19
+ # TODO: maybe try here to recreate few times....
+ mdadm --stop "$mddev" || true
+ udev_wait
+ while [ "$#" -ne 0 ] ; do
+ case "$1" in
+ *"$PREFIX"*) mdadm --zero-superblock "$1" || true ;;
+ esac
+ shift
+ done
+ udev_wait
+ skip "Test skipped, unreliable mdadm detected!"
+ }
+
+ for i in {10..0} ; do
+ test -e "$mddev" && break
+ echo "Waiting for $mddev."
+ sleep .5
+ done
+
+ # LVM/DM will see this device
+ case "$DM_DEV_DIR" in
+ "/dev") readlink -f "$mddev" > MD_DEV_PV ;;
+ *) mkdir -p "$mddevdir"
+ rm -f "$mddevdir/$mdname"
+ cp -LR "$mddev" "$mddevdir"
+ echo "${mddevdir}${mdname}" > MD_DEV_PV ;;
+ esac
+
+ mddev=$(readlink -f "$mddev")
+ test -b "$mddev" || skip "mdadm has not created device!"
+ echo "$mddev" > MD_DEV
+ rm -f MD_DEVICES
+ while [ "$#" -ne 0 ] ; do
+ case "$1" in
+ *"$PREFIX"*) echo "$1" >> MD_DEVICES ;;
+ esac
+ shift
+ done
+}
+
cleanup_md_dev() {
test -f MD_DEV || return 0
+ grep -q "$(basename $(< MD_DEV) )" /proc/mdstat || {
+ rm -f MD_DEV
+ return 0
+ }
local IFS=$IFS_NL
local dev
@@ -785,21 +857,20 @@ cleanup_md_dev() {
local mddev_pv
mddev=$(< MD_DEV)
mddev_pv=$(< MD_DEV_PV)
- udev_wait
- mdadm --stop "$mddev" || true
- udev_wait # wait till events are process, not zeroing to early
+
+ for i in {10..0} ; do
+ udev_wait
+ mdadm --stop "$mddev" || true
+ udev_wait # wait till events are process, not zeroing to early
+ grep -q "$(basename $(< MD_DEV) )" /proc/mdstat || break
+ sleep .1
+ echo "$mddev is still present, stopping again"
+ done
test "$DM_DEV_DIR" != "/dev" && rm -rf "${mddev_pv%/*}"
for dev in $(< MD_DEVICES); do
mdadm --zero-superblock "$dev" || true
done
udev_wait
- if [ -b "$mddev" ]; then
- # mdadm doesn't always cleanup the device node
- # sleeps offer hack to defeat: 'md: md127 still in use'
- # see: https://bugzilla.redhat.com/show_bug.cgi?id=509908#c25
- sleep 2
- rm -f "$mddev"
- fi
rm -f MD_DEV MD_DEVICES MD_DEV_PV
}
3 years
main - tests: remove local changes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=77432ee13742d09af5e...
Commit: 77432ee13742d09af5e8b1f8813d65bda3556a1d
Parent: daca6e2c225889a8ee4bfe4f4724d92481df2558
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 22 10:15:08 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 22 22:36:37 2021 +0100
tests: remove local changes
Use aux for preparing profile.
Avoid playing with LVM_BINARY localy - we already
preset this variable in lib/utils.
---
test/api/dbustest.sh | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/test/api/dbustest.sh b/test/api/dbustest.sh
index f7d2e91a8..d922d903f 100644
--- a/test/api/dbustest.sh
+++ b/test/api/dbustest.sh
@@ -28,18 +28,7 @@ aux extend_filter_LVMTEST
# We need the lvmdbusd.profile for the daemon to utilize JSON
# output
-mkdir -p "$TESTDIR/etc/profile"
-cp -v "$TESTOLDPWD/lib/lvmdbusd.profile" "$TESTDIR/etc/profile/"
-
-# Need to set this up so that the lvmdbusd service knows which
-# binary to be running, which should be the one we just built
-LVM_BINARY=$(which lvm 2>/dev/null)
-export LVM_BINARY
-
-# skip if we don't have our own lvmetad...
-if test -z "${installed_testsuite+varset}"; then
- (echo "$LVM_BINARY" | grep -q "$abs_builddir") || skip
-fi
+aux prepare_profiles "lvmdbusd"
aux prepare_lvmdbusd
3 years