master - tests: play better with mdadm
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7a5a4f952e567e...
Commit: 7a5a4f952e567ebb32e61414db62292eab81b6c7
Parent: 88421c883ebe20730e31e601d209f48b64b14ad0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 13:07:33 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 13:11:41 2015 +0200
tests: play better with mdadm
Manage mdadm devices on older distros is a challange.
---
test/lib/aux.sh | 14 +++++++++++++-
test/shell/pvcreate-operation-md.sh | 7 +++++++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index d0a5173..80792f5 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -427,7 +427,19 @@ prepare_md_dev() {
mddev=/dev/md/md_lvm_test0 || \
mddev=/dev/md_lvm_test0
- mdadm --create --metadata=1.0 "$mddev" --auto=md --level $level --chunk $rchunk --raid-devices=$rdevs "${@:4}"
+ mdadm --create --metadata=1.0 "$mddev" --auto=md --level $level --chunk $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
diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh
index 52a2c37..8291215 100644
--- a/test/shell/pvcreate-operation-md.sh
+++ b/test/shell/pvcreate-operation-md.sh
@@ -50,6 +50,7 @@ if aux kernel_at_least 2 6 33 ; then
pvcreate --metadatasize 128k \
--config 'devices { md_chunk_alignment=0 }' "$pvdev"
check pv_field "$pvdev" pe_start "1.00m"
+ pvremove "$pvdev"
fi
# partition MD array directly, depends on blkext in Linux >= 2.6.28
@@ -58,6 +59,12 @@ if aux kernel_at_least 2 6 28 ; then
sfdisk "$mddev" <<EOF
,,83
EOF
+ # Wait till all partition links in udev are created
+ aux udev_wait
+
+ # Skip test if udev rule has not created proper links for partitions
+ test -b "${mddev}p1" || { ls -laR /dev ; skip "Missing partition link" ; }
+
pvscan
# make sure partition on MD is _not_ removed
# - tests partition -> parent lookup via sysfs paths
9 years
master - raid: reread status when 0 is reported
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88421c883ebe20...
Commit: 88421c883ebe20730e31e601d209f48b64b14ad0
Parent: 2d10a6f6aef9eb013986c40a8bd83db6f571472f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 11:25:00 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 13:09:05 2015 +0200
raid: reread status when 0 is reported
When kernel target reports sync status as 0% it might as well mean
it's 100% in sync, just the target is in some race inconsistent
state - so reread once again and take a more optimistic value ;)
Patch tries to work around:
https://bugzilla.redhat.com/show_bug.cgi?id=1210637
---
lib/metadata/raid_manip.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index c786e89..0428eb0 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -93,6 +93,20 @@ static int _raid_in_sync(struct logical_volume *lv)
lv->vg->name, lv->name);
return 0;
}
+ if (sync_percent == DM_PERCENT_0) {
+ /*
+ * Repeat read of status once more - since buggy kernel target
+ * sometimes reports 0 even though the array is in 100% sync
+ */
+ if (!lv_raid_percent(lv, &sync_percent)) {
+ log_error("Unable to determine sync status of %s/%s.",
+ lv->vg->name, lv->name);
+ return 0;
+ }
+ if (sync_percent == DM_PERCENT_100)
+ log_warn("WARNING: Sync status for %s is inconsistent.",
+ display_lvname(lv));
+ }
return (sync_percent == DM_PERCENT_100) ? 1 : 0;
}
9 years
master - tests: check for open_count
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2d10a6f6aef9eb...
Commit: 2d10a6f6aef9eb013986c40a8bd83db6f571472f
Parent: 7a588bce7bd032175d56a1a10af528d61e1c554b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 10:18:44 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 10:18:44 2015 +0200
tests: check for open_count
Instead of checking /proc/mounts check for open_count of snap device.
Parallel umount has race, so check for open_count.
---
test/shell/snapshot-autoumount-dmeventd.sh | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/test/shell/snapshot-autoumount-dmeventd.sh b/test/shell/snapshot-autoumount-dmeventd.sh
index e059684..860d170 100644
--- a/test/shell/snapshot-autoumount-dmeventd.sh
+++ b/test/shell/snapshot-autoumount-dmeventd.sh
@@ -30,14 +30,17 @@ lvchange --monitor y $vg/snap
mkdir "$mntdir"
mount "$DM_DEV_DIR/mapper/$vg-snap" "$mntdir"
-mount
+
cat /proc/mounts | grep "$mntdir"
not dd if=/dev/zero of="$mntdir/file$1" bs=1M count=5 oflag=direct
-#dmeventd only checks every 10 seconds :(
-for i in {1..10}; do
- cat /proc/mounts | grep "$mntdir" || break
- sleep 1
+# Should be nearly instant check of dmeventd for invalid snapshot.
+# Wait here for umount and open_count drops to 0 as it may
+# take a while to finalize umount operation (it might be already
+# removed from /proc/mounts, but still opened).
+for i in {1..100}; do
+ test $(dmsetup info -c --noheadings -o open $vg-snap) -eq 0 && break
+ sleep .1
done
cat /proc/mounts | not grep "$mntdir"
9 years
master - tests: drop extra scsi init
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7a588bce7bd032...
Commit: 7a588bce7bd032175d56a1a10af528d61e1c554b
Parent: c90ee0414d74ddbaabf270c306acd4fef76718b5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 10:17:48 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 10:17:48 2015 +0200
tests: drop extra scsi init
Use first test also for checking the support is there -
avoid one extra unnecessary scsi_debug reload.
---
test/shell/topology-support.sh | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/test/shell/topology-support.sh b/test/shell/topology-support.sh
index f465ab7..f1e42a8 100644
--- a/test/shell/topology-support.sh
+++ b/test/shell/topology-support.sh
@@ -43,21 +43,17 @@ NUM_DEVS=1
PER_DEV_SIZE=34
DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE))
-# Test that kernel supports topology
-aux prepare_scsi_debug_dev $DEV_SIZE || skip
-
-if [ ! -e /sys/block/$(basename $(< SCSI_DEBUG_DEV))/alignment_offset ] ; then
- aux cleanup_scsi_debug_dev
- skip
-fi
-aux cleanup_scsi_debug_dev
-
# ---------------------------------------------
# Create "desktop-class" 4K drive
# (logical_block_size=512, physical_block_size=4096, alignment_offset=0):
LOGICAL_BLOCK_SIZE=512
aux prepare_scsi_debug_dev $DEV_SIZE \
sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3
+# Test that kernel supports topology
+if [ ! -e /sys/block/$(basename $(< SCSI_DEBUG_DEV))/alignment_offset ] ; then
+ aux cleanup_scsi_debug_dev
+ skip
+fi
check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
get_devs
9 years
master - tests: check for clvmd process entry
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c90ee0414d74dd...
Commit: c90ee0414d74ddbaabf270c306acd4fef76718b5
Parent: 3f05e662bbb0a02315e3ef806543fd3e092f40f0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 10:16:33 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 10:16:33 2015 +0200
tests: check for clvmd process entry
Instead of checking just for pid file - rather check
for process - since there could be slight race, the
pid file is gone, but process still exists.
---
test/shell/pvmove-restart.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index db87d52..e1408bf 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -69,7 +69,7 @@ if test -e LOCAL_CLVMD ; then
kill $(< LOCAL_CLVMD)
for i in $(seq 1 100) ; do
test $i -eq 100 && die "Shutdown of clvmd is too slow."
- test -e "$CLVMD_PIDFILE" || break
+ pgrep clvmd || break
sleep .1
done # wait for the pid removal
aux prepare_clvmd
9 years
master - tests: validate passed LVM_TEST_DEVDIR
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3f05e662bbb0a0...
Commit: 3f05e662bbb0a02315e3ef806543fd3e092f40f0
Parent: b09ac72624031a7d6d0b6416a067aa60584e0d6c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 10:15:56 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 10:15:56 2015 +0200
tests: validate passed LVM_TEST_DEVDIR
Quit test early if passed LVM_TEST_DEVDIR dir does not exists.
---
test/lib/inittest.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index b577389..cd6471c 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -60,6 +60,7 @@ DM_DEV_DIR="$TESTDIR/dev"
LVM_SYSTEM_DIR="$TESTDIR/etc"
mkdir "$LVM_SYSTEM_DIR" "$DM_DEV_DIR"
if test -n "$LVM_TEST_DEVDIR" ; then
+ test -d "$LVM_TEST_DEVDIR" || die "Test device directory LVM_TEST_DEVDIR=\"$LVM_TEST_DEVDIR\" is not valid."
DM_DEV_DIR=$LVM_TEST_DEVDIR
else
mknod "$DM_DEV_DIR/testnull" c 1 3 || die "mknod failed"
9 years
master - tests: wait for scsi device to appear
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b09ac72624031a...
Commit: b09ac72624031a7d6d0b6416a067aa60584e0d6c
Parent: 75aa3e951f2e22a790fe2425f3b3ef71f292be2e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 4 10:14:52 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon May 4 10:14:52 2015 +0200
tests: wait for scsi device to appear
Continue with test as soon as device appear (avoid 2s delay)
---
test/lib/aux.sh | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index c01fb80..d0a5173 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -48,7 +48,7 @@ prepare_clvmd() {
LVM_LOG_FILE_EPOCH=CLVMD LVM_BINARY=$(which lvm) $run_valgrind clvmd -Isinglenode -d 1 -f &
echo $! > LOCAL_CLVMD
- for i in $(seq 1 100) ; do
+ for i in {1..100} ; do
test $i -eq 100 && die "Startup of clvmd is too slow."
test -e "$CLVMD_PIDFILE" && break
sleep .2
@@ -74,7 +74,7 @@ prepare_dmeventd() {
echo $! > LOCAL_DMEVENTD
# FIXME wait for pipe in /var/run instead
- for i in $(seq 1 100) ; do
+ for i in {1..100} ; do
test $i -eq 100 && die "Startup of dmeventd is too slow."
test -e "${DMEVENTD_PIDFILE}" && break
sleep .2
@@ -369,6 +369,7 @@ prepare_loop() {
prepare_scsi_debug_dev() {
local DEV_SIZE=$1
local SCSI_DEBUG_PARAMS=${@:2}
+ local DEBUG_DEV
rm -f debug.log strace.log
test ! -f "SCSI_DEBUG_DEV" || return 0
@@ -384,9 +385,12 @@ prepare_scsi_debug_dev() {
# last param wins.. so num_tgts=1 is imposed
touch SCSI_DEBUG_DEV
modprobe scsi_debug dev_size_mb=$DEV_SIZE $SCSI_DEBUG_PARAMS num_tgts=1 || skip
- sleep 2 # allow for async Linux SCSI device registration
-
- local DEBUG_DEV="/dev/$(grep -H scsi_debug /sys/block/*/device/model | cut -f4 -d /)"
+
+ for i in {1..20} ; do
+ DEBUG_DEV="/dev/$(grep -H scsi_debug /sys/block/*/device/model | cut -f4 -d /)"
+ test -b "$DEBUG_DEV" && break
+ sleep .1 # allow for async Linux SCSI device registration
+ done
test -b "$DEBUG_DEV" || return 1 # should not happen
# Create symlink to scsi_debug device in $DM_DEV_DIR
9 years
master - tests: dd needs to fail in this case
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=75aa3e951f2e22...
Commit: 75aa3e951f2e22a790fe2425f3b3ef71f292be2e
Parent: 224e30a4b18e66f3c269ed97a1ab14229d3e7ec7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun May 3 01:06:20 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun May 3 01:06:20 2015 +0200
tests: dd needs to fail in this case
---
test/shell/snapshot-autoumount-dmeventd.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/snapshot-autoumount-dmeventd.sh b/test/shell/snapshot-autoumount-dmeventd.sh
index db4062e..e059684 100644
--- a/test/shell/snapshot-autoumount-dmeventd.sh
+++ b/test/shell/snapshot-autoumount-dmeventd.sh
@@ -32,7 +32,7 @@ mkdir "$mntdir"
mount "$DM_DEV_DIR/mapper/$vg-snap" "$mntdir"
mount
cat /proc/mounts | grep "$mntdir"
-dd if=/dev/zero of="$mntdir/file$1" bs=1M count=5 oflag=direct
+not dd if=/dev/zero of="$mntdir/file$1" bs=1M count=5 oflag=direct
#dmeventd only checks every 10 seconds :(
for i in {1..10}; do
9 years
master - tests: more waits on restart
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=224e30a4b18e66...
Commit: 224e30a4b18e66f3c269ed97a1ab14229d3e7ec7
Parent: 31f1375d23fcc23a35e67bd8780d1ba82db4be56
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun May 3 00:29:06 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun May 3 00:43:15 2015 +0200
tests: more waits on restart
Check for socket presence (hardcoded for now)
---
test/shell/clvmd-restart.sh | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/test/shell/clvmd-restart.sh b/test/shell/clvmd-restart.sh
index 4a9f12e..cb06bf6 100644
--- a/test/shell/clvmd-restart.sh
+++ b/test/shell/clvmd-restart.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2011-2015 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
@@ -19,9 +19,23 @@ export LVM_BINARY=lvm
test -e LOCAL_CLVMD || skip
read LOCAL_CLVMD < LOCAL_CLVMD
-aux prepare_pvs 1
+# TODO read from build, for now hardcoded
+CLVMD_SOCKET="/var/run/lvm/clvmd.sock"
-vgcreate --clustered y $vg $(cat DEVICES)
+restart_clvmd_() {
+ "$LVM_CLVMD_BINARY" -S
+ ls -la $CLVMD_SOCKET || true
+
+ for i in $(seq 1 20) ; do
+ test -S "$CLVMD_SOCKET" && break
+ sleep .1
+ done
+ # restarted clvmd has the same PID (no fork, only execvp)
+ NEW_LOCAL_CLVMD=$(pgrep clvmd)
+ test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD"
+}
+
+aux prepare_vg
lvcreate -an --zero n -n $lv1 -l1 $vg
lvcreate -an --zero n -n $lv2 -l1 $vg
@@ -30,19 +44,10 @@ lvcreate -l1 $vg
lvchange -aey $vg/$lv1
lvchange -aey $vg/$lv2
-"$LVM_CLVMD_BINARY" -S
-sleep .2
-# restarted clvmd has the same PID (no fork, only execvp)
-NEW_LOCAL_CLVMD=$(pgrep clvmd)
-test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD"
+restart_clvmd_
# try restart once more
-
-"$LVM_CLVMD_BINARY" -S
-sleep .2
-# restarted clvmd has the same PID (no fork, only execvp)
-NEW_LOCAL_CLVMD=$(pgrep clvmd)
-test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD"
+restart_clvmd_
# FIXME: Hmm - how could we test exclusivity is preserved in singlenode ?
lvchange -an $vg/$lv1
@@ -55,7 +60,7 @@ vgchange -an $vg
# Test what happens after 'reboot'
kill "$LOCAL_CLVMD"
-while test -e "/var/run/clvmd.pid"; do echo -n .; sleep .1; done # wait for the pid removal
+while test -e "$CLVMD_PIDFILE"; do echo -n .; sleep .1; done # wait for the pid removal
aux prepare_clvmd
vgchange -ay $vg
9 years
master - tests: use 800ms write delay
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=31f1375d23fcc2...
Commit: 31f1375d23fcc23a35e67bd8780d1ba82db4be56
Parent: 4f6660db7df704d8ba5d855b369b6dfdff4eed1c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat May 2 22:03:19 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun May 3 00:43:15 2015 +0200
tests: use 800ms write delay
Since this value magically worked for pvmove-abort*
use it here as well.
Also prepate_lvmetad has better kill&reload mechanism.
---
test/shell/pvmove-restart.sh | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index 011e6ee..db87d52 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -21,7 +21,7 @@ vgextend $vg "$dev3"
# Slowdown writes
# (FIXME: generates interesting race when not used)
-aux delay_dev "$dev3" 100 100 $(get first_extent_sector "$dev3"):
+aux delay_dev "$dev3" 0 800 $(get first_extent_sector "$dev3"):
for mode in "--atomic" ""
do
@@ -44,7 +44,7 @@ wait
# First take down $lv1 then it's pvmove0
j=0
-for i in $lv1 pvmove0 pvmove0_mimage_1 pvmove0_mimage_0 ; do
+for i in $lv1 pvmove0 pvmove0_mimage_0 pvmove0_mimage_1 ; do
while dmsetup status "$vg-$i"; do
dmsetup remove "$vg-$i" || {
j=$(($j + 1))
@@ -76,8 +76,7 @@ if test -e LOCAL_CLVMD ; then
fi
if test -e LOCAL_LVMETAD ; then
- # Restart lvmetad
- kill $(< LOCAL_LVMETAD)
+ # Restart lvmetad (kill is built-in)
aux prepare_lvmetad
fi
@@ -92,8 +91,6 @@ dmsetup table
pvmove --abort
-pvmove --abort
-
lvs -a -o+devices $vg
lvremove -ff $vg
9 years