summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2012-03-28 11:10:08 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2012-03-28 11:10:08 +0000
commita59c3731c3f68561b1b9aa015d59155976c7a6a3 (patch)
tree8a19c221b29f6c4df02442db518088c4406e6659 /test
parent9e072e70723544190b5fbfbfae9e6683fcf5f644 (diff)
downloadlvm2-a59c3731c3f68561b1b9aa015d59155976c7a6a3.tar.gz
lvm2-a59c3731c3f68561b1b9aa015d59155976c7a6a3.tar.xz
lvm2-a59c3731c3f68561b1b9aa015d59155976c7a6a3.zip
Improve test suite
Add make help target. Add LVM_TEST_PARALLEL to support parallel runs of tests Work around the problem the dmsetup table/info may return error by using dmtable and dminfo function that will use 'should'. (Error happens when some concurently running process removes table entry while dmsetup command resolves table entries inside the loop.)
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in21
-rw-r--r--test/lib/aux.sh18
-rw-r--r--test/lib/check.sh12
-rw-r--r--test/lib/utils.sh10
-rw-r--r--test/shell/lvcreate-operation.sh6
-rw-r--r--test/shell/lvcreate-repair.sh2
-rw-r--r--test/shell/mdata-strings.sh2
-rw-r--r--test/shell/mirror-names.sh18
-rw-r--r--test/shell/mirror-vgreduce-removemissing.sh11
-rw-r--r--test/shell/pvmove-basic.sh6
-rw-r--r--test/shell/snapshot-merge.sh6
11 files changed, 58 insertions, 54 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 1372e5ae..da97f2c4 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -45,6 +45,27 @@ endif
all: check
+help:
+ @echo -e "\nAvailable targets:"
+ @echo " all Default target, run check."
+ @echo " check Run all tests."
+ @echo " check_local Run tests without clvmd and lvmetad."
+ @echo " check_cluster Run tests with cluster daemon."
+ @echo " check_lvmetad Run tests with lvmetad daemon."
+ @echo " clean Clean dir."
+ @echo " help Display callable targets."
+ @echo -e "\nSupported variables:"
+ @echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev."
+ @echo " LVM_TEST_DIR Where to create test files [TMPDIR]."
+ @echo " LVM_TEST_LOCKING Normal (1), Cluster (3)."
+ @echo " LVM_TEST_LVMETAD Start lvmetad (1)."
+ @echo " LVM_TEST_NODEBUG Do not debug lvm commands."
+ @echo " LVM_TEST_PARALLEL May skip agresive wipe of LVMTEST resources."
+ @echo " LVM_VERIFY_UDEV Default verify state for lvm.conf."
+ @echo " S Skip given test (regex)."
+ @echo " T Run given test (regex)."
+ @echo " VERBOSE Verbose output (1), timing (2)."
+
check: check_local check_cluster check_lvmetad
check_cluster: .tests-stamp
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index a2579701..49df9dd6 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -89,7 +89,7 @@ teardown_devs_prefixed() {
local dm
# Resume suspended devices first
- for dm in $(dmsetup info -c -o suspended,name --noheadings | grep "^Suspended:.*$prefix"); do
+ for dm in $(dm_info suspended,name | grep "^Suspended:.*$prefix"); do
echo "dmsetup resume \"${dm#Suspended:}\""
dmsetup resume "${dm#Suspended:}" || true
done
@@ -106,7 +106,7 @@ teardown_devs_prefixed() {
local remfail=no
local need_udev_wait=0
init_udev_transaction
- for dm in $(dmsetup info -c -o name --sort open --noheadings | grep "$prefix"); do
+ for dm in $(dm_info name --sort open | grep "$prefix"); do
dmsetup remove "$dm" &>/dev/null || remfail=yes
need_udev_wait=1
done
@@ -116,10 +116,10 @@ teardown_devs_prefixed() {
if test $remfail = yes; then
local num_devs
local num_remaining_devs=999
- while num_devs=$(dmsetup table | grep "$prefix" | wc -l) && \
+ while num_devs=$(dm_table | grep "$prefix" | wc -l) && \
test $num_devs -lt $num_remaining_devs -a $num_devs -ne 0; do
test "$stray" -eq 0 || echo "Removing $num_devs stray mapped devices with names beginning with $prefix: "
- for dm in $(dmsetup info -c -o name --sort open --noheadings | grep "$prefix") ; do
+ for dm in $(dm_info name --sort open | grep "$prefix") ; do
dmsetup remove -f "$dm" || true
done
num_remaining_devs=$num_devs
@@ -139,7 +139,7 @@ teardown_devs() {
# 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
- modprobe -r scsi_debug
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 || modprobe -r scsi_debug
else
test ! -f LOOP || losetup -d $(cat LOOP) || true
test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
@@ -148,7 +148,7 @@ teardown_devs() {
rm -f LOOP
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
- test -z "$COMMON_PREFIX" || {
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -z "$COMMON_PREFIX" || {
teardown_devs_prefixed "$COMMON_PREFIX" 1
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
test ${#stray_loops[@]} -eq 0 || {
@@ -161,9 +161,9 @@ teardown_devs() {
teardown() {
echo -n "## teardown..."
- dmsetup table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || {
+ dm_table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || {
# Avoid activation of dmeventd if there is no pid
- cfg=$(test -s LOCAL_DMEVENTD || echo "--config 'activation { monitoring = 0 }'")
+ cfg=$(test -s LOCAL_DMEVENTD || echo "--config activation{monitoring=0}")
vgremove -ff $cfg \
$vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log
}
@@ -194,7 +194,7 @@ teardown() {
echo "ok"
- test -n "$RUNNING_DMEVENTD" || not pgrep dmeventd &>/dev/null
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -n "$RUNNING_DMEVENTD" || not pgrep dmeventd #&>/dev/null
}
make_ioerror() {
diff --git a/test/lib/check.sh b/test/lib/check.sh
index be1c11f9..9c787285 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -153,12 +153,11 @@ linear() {
active() {
local lv=$1/$2
- (get lv_field $lv attr $lv | grep "^....a...$" >/dev/null) || \
+ (get lv_field $lv attr | grep "^....a...$" >/dev/null) || \
die "$lv expected active, but lvs says it's not:" \
$(lvl $lv -o+devices)
- (dmsetup table | egrep "$1-$2: *[^ ]+" >/dev/null) || \
- die "$lv expected active, lvs thinks it is but there are no mappings!" \
- $(dmsetup table | grep $1-$2:)
+ dmsetup info $1-$2 >/dev/null ||
+ die "$lv expected active, lvs thinks it is but there are no mappings!"
}
inactive() {
@@ -166,9 +165,8 @@ inactive() {
(get lv_field $lv attr | grep "^....[-isd]...$" >/dev/null) || \
die "$lv expected inactive, but lvs says it's not:" \
$(lvl $lv -o+devices)
- (dmsetup table | not egrep "$1-$2: *[^ ]+" >/dev/null) || \
- die "$lv expected inactive, lvs thinks it is but there are mappings!" \
- $(dmsetup table | grep $1-$2:)
+ not dmsetup info $1-$2 2>/dev/null || \
+ die "$lv expected inactive, lvs thinks it is but there are mappings!"
}
# Check for list of LVs from given VG
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index a5f82bcf..70d9f66f 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -109,7 +109,7 @@ STACKTRACE() {
i=$(($i + 1))
done
- test -n "$RUNNING_DMEVENTD" -o -f LOCAL_DMEVENTD || {
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -n "$RUNNING_DMEVENTD" -o -f LOCAL_DMEVENTD || {
pgrep dmeventd &>/dev/null && \
die "** During test dmeventd has been started!"
}
@@ -157,6 +157,14 @@ teardown_udev_cookies() {
fi
}
+dm_info() {
+ should dmsetup info --noheadings -c -o "$@"
+}
+
+dm_table() {
+ should dmsetup table "$@"
+}
+
skip() {
touch SKIP_THIS_TEST
exit 200
diff --git a/test/shell/lvcreate-operation.sh b/test/shell/lvcreate-operation.sh
index c3d8c65a..0ef31384 100644
--- a/test/shell/lvcreate-operation.sh
+++ b/test/shell/lvcreate-operation.sh
@@ -15,10 +15,8 @@
cleanup_lvs() {
lvremove -ff $vg
- if dmsetup table|grep $vg; then
- echo "ERROR: lvremove did leave some some mappings in DM behind!"
- return 1
- fi
+ (dm_table | not grep $vg) || \
+ die "ERROR: lvremove did leave some some mappings in DM behind!"
}
aux prepare_pvs 2
diff --git a/test/shell/lvcreate-repair.sh b/test/shell/lvcreate-repair.sh
index 8dc66c93..8971536e 100644
--- a/test/shell/lvcreate-repair.sh
+++ b/test/shell/lvcreate-repair.sh
@@ -29,7 +29,7 @@ for i in "$dev1" "$dev2" "$dev3" ; do
vgreduce --removemissing --force $vg
# check if reduced device was removed
- test "$i" = "$dev1" && dmsetup table | not egrep "$vg-$lv1: *[^ ]+" >/dev/null
+ test "$i" = "$dev1" && dm_table | not egrep "$vg-$lv1: *[^ ]+"
lvcreate -l1 -n $lv2 $vg
diff --git a/test/shell/mdata-strings.sh b/test/shell/mdata-strings.sh
index addac107..574334cb 100644
--- a/test/shell/mdata-strings.sh
+++ b/test/shell/mdata-strings.sh
@@ -23,7 +23,7 @@ name=$(basename "$dev1")
dmsetup rename "$name" "$PREFIX$pv_ugly"
dev1=$(dirname "$dev1")/"$PREFIX$pv_ugly"
-dmsetup table | grep -F "$pv_ugly"
+dm_table | grep -F "$pv_ugly"
# 'pvcreate, vgcreate on filename with backslashed chars'
created="$dev1"
diff --git a/test/shell/mirror-names.sh b/test/shell/mirror-names.sh
index 980c11b7..d6c67ee6 100644
--- a/test/shell/mirror-names.sh
+++ b/test/shell/mirror-names.sh
@@ -43,21 +43,11 @@ lv_convert_lv_() {
# ---------------------------------------------------------------------
# Common environment setup/cleanup for each sub testcases
-prepare_lvs_() {
- lvremove -ff $vg
- (dmsetup table | not grep $vg) || {
- echo "ERROR: lvremove did leave some some mappings in DM behind!"
- return 1
- }
-}
-
check_and_cleanup_lvs_() {
lvs -a -o+devices $vg
lvremove -ff $vg
- (dmsetup table | not grep $vg) || {
- echo "ERROR: lvremove did leave some some mappings in DM behind!"
- return 1
- }
+ (dm_table | not grep $vg) || \
+ die "ERROR: lvremove did leave some some mappings in DM behind!"
}
# ---------------------------------------------------------------------
@@ -65,14 +55,12 @@ check_and_cleanup_lvs_() {
aux prepare_vg 5 80
-prepare_lvs_
check_and_cleanup_lvs_
# ---------------------------------------------------------------------
# basic
#COMM "init: lvcreate"
-prepare_lvs_
#COMM "mirror images are ${lv1}_mimage_x"
lvcreate -l2 -m1 -n $lv1 $vg
@@ -94,7 +82,6 @@ check_and_cleanup_lvs_
# lvrename
#COMM "init: lvrename"
-prepare_lvs_
#COMM "renamed mirror names: $lv1 to $lv2"
lvcreate -l2 -m1 -n $lv1 $vg
@@ -109,7 +96,6 @@ check_and_cleanup_lvs_
# lvconvert
#COMM "init: lvconvert"
-prepare_lvs_
#COMM "converting mirror names is ${lv1}_mimagetmp_2"
lvcreate -l2 -m1 -n $lv1 $vg
diff --git a/test/shell/mirror-vgreduce-removemissing.sh b/test/shell/mirror-vgreduce-removemissing.sh
index 5bab0c9d..232c2be3 100644
--- a/test/shell/mirror-vgreduce-removemissing.sh
+++ b/test/shell/mirror-vgreduce-removemissing.sh
@@ -93,20 +93,15 @@ aux prepare_vg 5
prepare_lvs_()
{
- lvremove -ff $vg;
- if (dmsetup table | grep -v -- "-missing_" | grep $vg); then
+ lvremove -ff $vg
+ (dm_table | not grep $vg) || \
die "ERROR: lvremove did leave some some mappings in DM behind!"
- fi
- :
}
check_and_cleanup_lvs_()
{
lvs -a -o+devices $vg
- lvremove -ff $vg
- if (dmsetup table | grep $vg); then
- die "ERROR: lvremove did leave some some mappings in DM behind!"
- fi
+ prepare_lvs_
}
recover_vg_()
diff --git a/test/shell/pvmove-basic.sh b/test/shell/pvmove-basic.sh
index bcb6abcc..e95fc364 100644
--- a/test/shell/pvmove-basic.sh
+++ b/test/shell/pvmove-basic.sh
@@ -93,10 +93,8 @@ check_and_cleanup_lvs_() {
check_dev_sum_ $(lvdev_ $vg $lv3)
lvs -a -o name $vg > out && ! grep ^pvmove out
lvremove -ff $vg
- if ! dmsetup table|not grep $vg; then
- echo "ERROR: lvremove did leave some some mappings in DM behind!" && \
- return 1
- fi
+ (dm_table | not grep $vg) || \
+ die "ERROR: lvremove did leave some some mappings in DM behind!"
}
#COMM "check environment setup/cleanup"
diff --git a/test/shell/snapshot-merge.sh b/test/shell/snapshot-merge.sh
index d10fe923..a42b6f8b 100644
--- a/test/shell/snapshot-merge.sh
+++ b/test/shell/snapshot-merge.sh
@@ -67,13 +67,13 @@ lvconvert --merge $vg/$(snap_lv_name_ $lv1)
# verify 'snapshot-origin' target is still being used
lvchange --refresh $vg/$lv1
umount test_mnt
-dmsetup table $vg-$lv1 | grep " snapshot-origin "
+dm_table $vg-$lv1 | grep " snapshot-origin "
# -- refresh LV to start merge (now that FS is unmounted),
# an active merge uses the 'snapshot-merge' target
lvchange --refresh $vg/$lv1
# check whether it's still merging - or maybe got already merged (slow test)
-dmsetup table $vg-$lv1 | grep " snapshot-merge " || dmsetup table $vg-$lv1 | grep " linear "
+dm_table $vg-$lv1 | grep " snapshot-merge " || dm_table $vg-$lv1 | grep " linear "
# -- don't care if merge is still active; lvremove at this point
# may test stopping an active merge
lvremove -f $vg/$lv1
@@ -89,7 +89,7 @@ lvconvert --merge $vg/$(snap_lv_name_ $lv1)
# verify 'snapshot-origin' target is still being used
lvchange --refresh $vg/$lv1
umount test_mnt
-dmsetup table $vg-$lv1 | grep " snapshot-origin " >/dev/null
+dm_table $vg-$lv1 | grep " snapshot-origin " >/dev/null
lvremove -f $vg/$lv1