1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: direct control of lvm1 usage in tests

Using lvm1 metadata with lvmetad is not generally allowed,
but nothing has prevented creating new lvm1 metadata with
lvmetad (missing error checking in pvcreate/vgcreate.)
Various tests are using lvm1 with lvmetad and happen to
work because of the missing error checks.

This commit fixes the tests so they won't fail when the
lvm1/lvmetad error checking is fixed.  A new variable
LVM_TEST_LVM1 is defined and is used in the scripts to
decide if lvm1 metadata should be tested.  LVM_TEST_LVM1
is not defined when lvmetad is being tested, and the
combination of LVM_TEST_LVM1 and LVM_TEST_LVMETAD can
be used to verify the desired lvmetad+lvm1 behavior.
This commit is contained in:
David Teigland 2016-03-02 16:49:32 -06:00
parent 5764c484ea
commit ad9cbe2714
14 changed files with 94 additions and 20 deletions

View File

@ -1 +1,2 @@
export LVM_TEST_LOCKING=3
export LVM_TEST_LVM1=1

View File

@ -1 +1,2 @@
export LVM_TEST_LOCKING=1
export LVM_TEST_LVM1=1

View File

@ -1,2 +1,3 @@
export LVM_TEST_LOCKING=3
export LVM_TEST_DEVDIR=/dev
export LVM_TEST_LVM1=1

View File

@ -1,2 +1,3 @@
export LVM_TEST_LOCKING=1
export LVM_TEST_DEVDIR=/dev
export LVM_TEST_LVM1=1

35
test/shell/format-lvm1.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/sh
# Copyright (C) 2008 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
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
test_description='Test lvm1 format'
. lib/inittest
aux prepare_devs 1
if test -n "$LVM_TEST_LVM1" ; then
pvcreate -M1 "$dev1"
vgcreate -M1 $vg "$dev1"
check vg_field $vg fmt "lvm1"
fi
# TODO: if we decide to make using lvm1 with lvmetad an error,
# then if lvmetad is being used, then verify:
# not pvcreate -M1 "$dev1"
# not vgcreate -M1 $vg "$dev1"
#
# TODO: if we decide to allow using lvm1 with lvmetad, but disable lvmetad
# when it happens, then verify:
# pvcreate -M1 "$dev1" | tee err
# grep "disabled" err
# vgcreate -M1 $vg "$dev1" | tee err
# grep "disabled" err

View File

@ -46,7 +46,9 @@ for mdacp in 1 0; do
done
not grep "Cached VG .* incorrect PV list" out0
# some M1 metadata tests
# begin M1 metadata tests
if test -n "$LVM_TEST_LVM1" ; then
pvcreate -M1 "$dev1" "$dev2" "$dev3"
pv3_uuid=$(get pv_field "$dev3" pv_uuid)
vgcreate -M1 $vg "$dev1" "$dev2" "$dev3"
@ -60,9 +62,6 @@ check pv_field "$dev3" pe_start $pv_align
pvs --units k -o name,pe_start,vg_mda_size,vg_name $(cat DEVICES)
# vgconvert -M does not work with lvmetad
test -e LOCAL_LVMETAD && exit 0
# upgrade from v1 to v2 metadata
vgconvert -M2 $vg
@ -80,3 +79,7 @@ vgcfgrestore -f $TESTDIR/bak-$vg $vg
# verify pe_start of $dev3
check pv_field "$dev3" pe_start $pv_align
fi
# end M1 metadata tests

View File

@ -113,7 +113,10 @@ vgremove -f $vg1
fail pvchange "$dev1" --addtag test
fail pvchange "$dev1" --deltag test
if test -n "$LVM_TEST_LVM1" ; then
# cannot add PV tag to lvm1 format
pvcreate -M1 "$dev1"
vgcreate -M1 $vg1 "$dev1"
fail pvchange "$dev1" --addtag test
fi

View File

@ -17,7 +17,13 @@ aux lvmconf 'devices/md_component_detection = 1'
aux prepare_devs 4
for mdatype in 1 2
if test -n "$LVM_TEST_LVM1" ; then
mdatypes='1 2'
else
mdatypes='2'
fi
for mdatype in $mdatypes
do
# pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330)
test ! -d mnt && mkdir mnt

View File

@ -93,8 +93,10 @@ not pvcreate --labelsector 1000000000000 "$dev1"
#COMM 'pvcreate basic dataalignment sanity checks'
not pvcreate --dataalignment -1 "$dev1"
not pvcreate -M 1 --dataalignment 1 "$dev1"
not pvcreate --dataalignment 1e "$dev1"
if test -n "$LVM_TEST_LVM1" ; then
not pvcreate -M1 --dataalignment 1 "$dev1"
fi
#COMM 'pvcreate always rounded up to page size for start of device'
#pvcreate --metadatacopies 0 --dataalignment 1 "$dev1"
@ -142,7 +144,7 @@ check pv_field "$dev1" pv_mda_count 2
#COMM 'pv with LVM1 compatible data alignment can be convereted'
#compatible == LVM1_PE_ALIGN == 64k
if test ! -e LOCAL_LVMETAD; then
if test -n "$LVM_TEST_LVM1" ; then
pvcreate --dataalignment 256k "$dev1"
vgcreate -s 1m $vg "$dev1"
vgconvert -M1 $vg
@ -152,21 +154,13 @@ vgremove $vg
fi
#COMM 'pv with LVM1 incompatible data alignment cannot be convereted'
if test ! -e LOCAL_LVMETAD; then
if test -n "$LVM_TEST_LVM1" ; then
pvcreate --dataalignment 10k "$dev1"
vgcreate -s 1m $vg "$dev1"
not vgconvert -M1 $vg
vgremove $vg
fi
#COMM 'vgconvert -M is disallowed with lvmetad'
if test -e LOCAL_LVMETAD; then
pvcreate "$dev1"
vgcreate $vg "$dev1"
not vgconvert -M1 $vg
vgremove $vg
fi
#COMM 'vgcfgrestore allows pe_start=0'
#basically it produces nonsense, but it tests vgcfgrestore,
#not that final cfg is usable...

View File

@ -78,6 +78,7 @@ vgremove -f $vg
# vgcfgbackup correctly stores metadata LVM1 with missing PVs
# FIXME: clvmd seems to have problem with metadata format change here
# fix it and remove this vgscan
if test -n "$LVM_TEST_LVM1" ; then
vgscan
pvcreate -M1 $(cat DEVICES)
vgcreate -M1 -c n $vg $(cat DEVICES)
@ -85,3 +86,5 @@ lvcreate -l1 -n $lv1 $vg "$dev1"
pvremove -ff -y "$dev2"
not lvcreate -l1 -n $lv1 $vg "$dev3"
vgcfgbackup -f "backup.$$" $vg
fi

View File

@ -142,8 +142,14 @@ check pv_field "$dev1" pe_start ${pv_align}B --units b
vgremove -f $vg
pvremove -f "$dev1"
if test -n "$LVM_TEST_LVM1" ; then
mdatypes='1 2'
else
mdatypes='2'
fi
# metadatatype
for i in 1 2
for i in $mdatypes
do
vgcreate -M $i $vg "$dev1"
check vg_field $vg vg_fmt lvm$i

View File

@ -20,7 +20,13 @@ SKIP_WITH_LVMPOLLD=1
aux prepare_devs 5
for mdatype in 1 2
if test -n "$LVM_TEST_LVM1" ; then
mdatypes='1 2'
else
mdatypes='2'
fi
for mdatype in $mdatypes
do
# Explicit pvcreate

View File

@ -16,7 +16,13 @@ SKIP_WITH_LVMPOLLD=1
aux prepare_devs 4
for mdatype in 1 2
if test -n "$LVM_TEST_LVM1" ; then
mdatypes='1 2'
else
mdatypes='2'
fi
for mdatype in $mdatypes
do
# setup PVs
pvcreate -M$mdatype "$dev1" "$dev2"

View File

@ -18,7 +18,13 @@ SKIP_WITH_LVMPOLLD=1
aux prepare_devs 5
for mdatype in 1 2
if test -n "$LVM_TEST_LVM1" ; then
mdatypes='1 2'
else
mdatypes='2'
fi
for mdatype in $mdatypes
do
pvcreate -M$mdatype $(cat DEVICES)
@ -162,6 +168,7 @@ check pvlv_counts $vg1 2 1 0
vgremove -f $vg1
# vgsplit rejects split because metadata types differ
if test -n "$LVM_TEST_LVM1" ; then
pvcreate -ff -M1 "$dev3" "$dev4"
pvcreate -ff "$dev1" "$dev2"
vgcreate -M1 $vg1 "$dev3" "$dev4"
@ -169,3 +176,4 @@ vgcreate $vg2 "$dev1" "$dev2"
not vgsplit $vg1 $vg2 "$dev3" 2>err;
grep "Metadata types differ" err
vgremove -f $vg1 $vg2
fi