mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
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.)
This commit is contained in:
parent
9e072e7072
commit
a59c3731c3
@ -197,7 +197,7 @@ POTFILES = $(SOURCES:%.c=%.pot)
|
|||||||
.PHONY: verity install_verity $(SUBDIRS.install_verity)
|
.PHONY: verity install_verity $(SUBDIRS.install_verity)
|
||||||
.PHONY: install install_cluster install_device-mapper install_lvm2
|
.PHONY: install install_cluster install_device-mapper install_lvm2
|
||||||
.PHONY: install_lib_shared install_dm_plugin install_lvm2_plugin
|
.PHONY: install_lib_shared install_dm_plugin install_lvm2_plugin
|
||||||
.PHONY: install_ocf
|
.PHONY: install_ocf help
|
||||||
.PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
|
.PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
|
||||||
.PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
|
.PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
|
||||||
.PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
|
.PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
|
||||||
@ -401,7 +401,8 @@ distclean: cleandir $(SUBDIRS.distclean)
|
|||||||
sed "s/^/ /;s/$$/;/" < $<; \
|
sed "s/^/ /;s/$$/;/" < $<; \
|
||||||
echo " local:"; echo " *;"; echo "};") > $@
|
echo " local:"; echo " *;"; echo "};") > $@
|
||||||
|
|
||||||
ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov))
|
ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov \
|
||||||
|
help check check_local check_cluster check_lvmetad))
|
||||||
ifdef SOURCES
|
ifdef SOURCES
|
||||||
-include $(SOURCES:.c=.d)
|
-include $(SOURCES:.c=.d)
|
||||||
endif
|
endif
|
||||||
|
@ -45,6 +45,27 @@ endif
|
|||||||
|
|
||||||
all: check
|
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: check_local check_cluster check_lvmetad
|
||||||
|
|
||||||
check_cluster: .tests-stamp
|
check_cluster: .tests-stamp
|
||||||
|
@ -89,7 +89,7 @@ teardown_devs_prefixed() {
|
|||||||
local dm
|
local dm
|
||||||
|
|
||||||
# Resume suspended devices first
|
# 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:}\""
|
echo "dmsetup resume \"${dm#Suspended:}\""
|
||||||
dmsetup resume "${dm#Suspended:}" || true
|
dmsetup resume "${dm#Suspended:}" || true
|
||||||
done
|
done
|
||||||
@ -106,7 +106,7 @@ teardown_devs_prefixed() {
|
|||||||
local remfail=no
|
local remfail=no
|
||||||
local need_udev_wait=0
|
local need_udev_wait=0
|
||||||
init_udev_transaction
|
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
|
dmsetup remove "$dm" &>/dev/null || remfail=yes
|
||||||
need_udev_wait=1
|
need_udev_wait=1
|
||||||
done
|
done
|
||||||
@ -116,10 +116,10 @@ teardown_devs_prefixed() {
|
|||||||
if test $remfail = yes; then
|
if test $remfail = yes; then
|
||||||
local num_devs
|
local num_devs
|
||||||
local num_remaining_devs=999
|
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 $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: "
|
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
|
dmsetup remove -f "$dm" || true
|
||||||
done
|
done
|
||||||
num_remaining_devs=$num_devs
|
num_remaining_devs=$num_devs
|
||||||
@ -139,7 +139,7 @@ teardown_devs() {
|
|||||||
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
|
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
|
||||||
# prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop()
|
# prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop()
|
||||||
if test -f SCSI_DEBUG_DEV; then
|
if test -f SCSI_DEBUG_DEV; then
|
||||||
modprobe -r scsi_debug
|
test ${LVM_TEST_PARALLEL:-0} -eq 1 || modprobe -r scsi_debug
|
||||||
else
|
else
|
||||||
test ! -f LOOP || losetup -d $(cat LOOP) || true
|
test ! -f LOOP || losetup -d $(cat LOOP) || true
|
||||||
test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
|
test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
|
||||||
@ -148,7 +148,7 @@ teardown_devs() {
|
|||||||
rm -f LOOP
|
rm -f LOOP
|
||||||
|
|
||||||
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
|
# 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
|
teardown_devs_prefixed "$COMMON_PREFIX" 1
|
||||||
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
|
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
|
||||||
test ${#stray_loops[@]} -eq 0 || {
|
test ${#stray_loops[@]} -eq 0 || {
|
||||||
@ -161,9 +161,9 @@ teardown_devs() {
|
|||||||
teardown() {
|
teardown() {
|
||||||
echo -n "## 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
|
# 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 \
|
vgremove -ff $cfg \
|
||||||
$vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log
|
$vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ teardown() {
|
|||||||
|
|
||||||
echo "ok"
|
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() {
|
make_ioerror() {
|
||||||
|
@ -153,12 +153,11 @@ linear() {
|
|||||||
|
|
||||||
active() {
|
active() {
|
||||||
local lv=$1/$2
|
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:" \
|
die "$lv expected active, but lvs says it's not:" \
|
||||||
$(lvl $lv -o+devices)
|
$(lvl $lv -o+devices)
|
||||||
(dmsetup table | egrep "$1-$2: *[^ ]+" >/dev/null) || \
|
dmsetup info $1-$2 >/dev/null ||
|
||||||
die "$lv expected active, lvs thinks it is but there are no mappings!" \
|
die "$lv expected active, lvs thinks it is but there are no mappings!"
|
||||||
$(dmsetup table | grep $1-$2:)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inactive() {
|
inactive() {
|
||||||
@ -166,9 +165,8 @@ inactive() {
|
|||||||
(get lv_field $lv attr | grep "^....[-isd]...$" >/dev/null) || \
|
(get lv_field $lv attr | grep "^....[-isd]...$" >/dev/null) || \
|
||||||
die "$lv expected inactive, but lvs says it's not:" \
|
die "$lv expected inactive, but lvs says it's not:" \
|
||||||
$(lvl $lv -o+devices)
|
$(lvl $lv -o+devices)
|
||||||
(dmsetup table | not egrep "$1-$2: *[^ ]+" >/dev/null) || \
|
not dmsetup info $1-$2 2>/dev/null || \
|
||||||
die "$lv expected inactive, lvs thinks it is but there are mappings!" \
|
die "$lv expected inactive, lvs thinks it is but there are mappings!"
|
||||||
$(dmsetup table | grep $1-$2:)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for list of LVs from given VG
|
# Check for list of LVs from given VG
|
||||||
|
@ -109,7 +109,7 @@ STACKTRACE() {
|
|||||||
i=$(($i + 1))
|
i=$(($i + 1))
|
||||||
done
|
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 && \
|
pgrep dmeventd &>/dev/null && \
|
||||||
die "** During test dmeventd has been started!"
|
die "** During test dmeventd has been started!"
|
||||||
}
|
}
|
||||||
@ -157,6 +157,14 @@ teardown_udev_cookies() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dm_info() {
|
||||||
|
should dmsetup info --noheadings -c -o "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
dm_table() {
|
||||||
|
should dmsetup table "$@"
|
||||||
|
}
|
||||||
|
|
||||||
skip() {
|
skip() {
|
||||||
touch SKIP_THIS_TEST
|
touch SKIP_THIS_TEST
|
||||||
exit 200
|
exit 200
|
||||||
|
@ -15,10 +15,8 @@
|
|||||||
|
|
||||||
cleanup_lvs() {
|
cleanup_lvs() {
|
||||||
lvremove -ff $vg
|
lvremove -ff $vg
|
||||||
if dmsetup table|grep $vg; then
|
(dm_table | not grep $vg) || \
|
||||||
echo "ERROR: lvremove did leave some some mappings in DM behind!"
|
die "ERROR: lvremove did leave some some mappings in DM behind!"
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aux prepare_pvs 2
|
aux prepare_pvs 2
|
||||||
|
@ -29,7 +29,7 @@ for i in "$dev1" "$dev2" "$dev3" ; do
|
|||||||
vgreduce --removemissing --force $vg
|
vgreduce --removemissing --force $vg
|
||||||
|
|
||||||
# check if reduced device was removed
|
# 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
|
lvcreate -l1 -n $lv2 $vg
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ name=$(basename "$dev1")
|
|||||||
dmsetup rename "$name" "$PREFIX$pv_ugly"
|
dmsetup rename "$name" "$PREFIX$pv_ugly"
|
||||||
dev1=$(dirname "$dev1")/"$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'
|
# 'pvcreate, vgcreate on filename with backslashed chars'
|
||||||
created="$dev1"
|
created="$dev1"
|
||||||
|
@ -43,21 +43,11 @@ lv_convert_lv_() {
|
|||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
# Common environment setup/cleanup for each sub testcases
|
# 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_() {
|
check_and_cleanup_lvs_() {
|
||||||
lvs -a -o+devices $vg
|
lvs -a -o+devices $vg
|
||||||
lvremove -ff $vg
|
lvremove -ff $vg
|
||||||
(dmsetup table | not grep $vg) || {
|
(dm_table | not grep $vg) || \
|
||||||
echo "ERROR: lvremove did leave some some mappings in DM behind!"
|
die "ERROR: lvremove did leave some some mappings in DM behind!"
|
||||||
return 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
@ -65,14 +55,12 @@ check_and_cleanup_lvs_() {
|
|||||||
|
|
||||||
aux prepare_vg 5 80
|
aux prepare_vg 5 80
|
||||||
|
|
||||||
prepare_lvs_
|
|
||||||
check_and_cleanup_lvs_
|
check_and_cleanup_lvs_
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
# basic
|
# basic
|
||||||
|
|
||||||
#COMM "init: lvcreate"
|
#COMM "init: lvcreate"
|
||||||
prepare_lvs_
|
|
||||||
|
|
||||||
#COMM "mirror images are ${lv1}_mimage_x"
|
#COMM "mirror images are ${lv1}_mimage_x"
|
||||||
lvcreate -l2 -m1 -n $lv1 $vg
|
lvcreate -l2 -m1 -n $lv1 $vg
|
||||||
@ -94,7 +82,6 @@ check_and_cleanup_lvs_
|
|||||||
# lvrename
|
# lvrename
|
||||||
|
|
||||||
#COMM "init: lvrename"
|
#COMM "init: lvrename"
|
||||||
prepare_lvs_
|
|
||||||
|
|
||||||
#COMM "renamed mirror names: $lv1 to $lv2"
|
#COMM "renamed mirror names: $lv1 to $lv2"
|
||||||
lvcreate -l2 -m1 -n $lv1 $vg
|
lvcreate -l2 -m1 -n $lv1 $vg
|
||||||
@ -109,7 +96,6 @@ check_and_cleanup_lvs_
|
|||||||
# lvconvert
|
# lvconvert
|
||||||
|
|
||||||
#COMM "init: lvconvert"
|
#COMM "init: lvconvert"
|
||||||
prepare_lvs_
|
|
||||||
|
|
||||||
#COMM "converting mirror names is ${lv1}_mimagetmp_2"
|
#COMM "converting mirror names is ${lv1}_mimagetmp_2"
|
||||||
lvcreate -l2 -m1 -n $lv1 $vg
|
lvcreate -l2 -m1 -n $lv1 $vg
|
||||||
|
@ -93,20 +93,15 @@ aux prepare_vg 5
|
|||||||
|
|
||||||
prepare_lvs_()
|
prepare_lvs_()
|
||||||
{
|
{
|
||||||
lvremove -ff $vg;
|
lvremove -ff $vg
|
||||||
if (dmsetup table | grep -v -- "-missing_" | grep $vg); then
|
(dm_table | not grep $vg) || \
|
||||||
die "ERROR: lvremove did leave some some mappings in DM behind!"
|
die "ERROR: lvremove did leave some some mappings in DM behind!"
|
||||||
fi
|
|
||||||
:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_and_cleanup_lvs_()
|
check_and_cleanup_lvs_()
|
||||||
{
|
{
|
||||||
lvs -a -o+devices $vg
|
lvs -a -o+devices $vg
|
||||||
lvremove -ff $vg
|
prepare_lvs_
|
||||||
if (dmsetup table | grep $vg); then
|
|
||||||
die "ERROR: lvremove did leave some some mappings in DM behind!"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recover_vg_()
|
recover_vg_()
|
||||||
|
@ -93,10 +93,8 @@ check_and_cleanup_lvs_() {
|
|||||||
check_dev_sum_ $(lvdev_ $vg $lv3)
|
check_dev_sum_ $(lvdev_ $vg $lv3)
|
||||||
lvs -a -o name $vg > out && ! grep ^pvmove out
|
lvs -a -o name $vg > out && ! grep ^pvmove out
|
||||||
lvremove -ff $vg
|
lvremove -ff $vg
|
||||||
if ! dmsetup table|not grep $vg; then
|
(dm_table | not grep $vg) || \
|
||||||
echo "ERROR: lvremove did leave some some mappings in DM behind!" && \
|
die "ERROR: lvremove did leave some some mappings in DM behind!"
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#COMM "check environment setup/cleanup"
|
#COMM "check environment setup/cleanup"
|
||||||
|
@ -67,13 +67,13 @@ lvconvert --merge $vg/$(snap_lv_name_ $lv1)
|
|||||||
# verify 'snapshot-origin' target is still being used
|
# verify 'snapshot-origin' target is still being used
|
||||||
lvchange --refresh $vg/$lv1
|
lvchange --refresh $vg/$lv1
|
||||||
umount test_mnt
|
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),
|
# -- refresh LV to start merge (now that FS is unmounted),
|
||||||
# an active merge uses the 'snapshot-merge' target
|
# an active merge uses the 'snapshot-merge' target
|
||||||
lvchange --refresh $vg/$lv1
|
lvchange --refresh $vg/$lv1
|
||||||
# check whether it's still merging - or maybe got already merged (slow test)
|
# 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
|
# -- don't care if merge is still active; lvremove at this point
|
||||||
# may test stopping an active merge
|
# may test stopping an active merge
|
||||||
lvremove -f $vg/$lv1
|
lvremove -f $vg/$lv1
|
||||||
@ -89,7 +89,7 @@ lvconvert --merge $vg/$(snap_lv_name_ $lv1)
|
|||||||
# verify 'snapshot-origin' target is still being used
|
# verify 'snapshot-origin' target is still being used
|
||||||
lvchange --refresh $vg/$lv1
|
lvchange --refresh $vg/$lv1
|
||||||
umount test_mnt
|
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
|
lvremove -f $vg/$lv1
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user