LVM2/test check.sh t-lvconvert-mirror.sh t-lvc ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2010-05-12 10:08:36
Modified files:
test : check.sh t-lvconvert-mirror.sh
t-lvcreate-mirror.sh t-vgcreate-usage.sh test-utils.sh
Added files:
test : t-lvconvert-mirror-basic.sh
Removed files:
test : t-mirror-lvconvert.sh
Log message:
A fairly extensive refactor of the mirror testing code. The exhaustive lvconvert testing is now in its own test, t-lvconvert-mirror-basic ... it doesn't do anything fancy but it does run lvconvert through a lot of combinations.
I have also merged the remaining t-mirror-lvconvert tests into t-lvconvert-mirror and abolished the former. The latter will be split again later into more thematic divisions. (The previous split was rather arbitrary, may I even say random...)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/check.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-mirror.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgcreate-usage.sh.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-mirror-lvconvert.sh.diff?cvsroot=lvm2&r1=1.27&r2=NONE
/cvs/lvm2/LVM2/test/t-lvconvert-mirror-basic.sh,v --> standard output revision 1.1
- renamed from test/t-lvconvert-mirror-basic.sh +139 -0
@@ -0,0 +1,139 @@ +. ./test-utils.sh + +log_name_to_count() +{ + if [ $1 == "mirrored" ]; then + echo 2 + elif [ $1 == "disk" ]; then + echo 1 + else + echo 0 + fi +} + +# FIXME: For test_[up|down]convert, I'd still like to be able +# to specifiy devices - especially if I can do partial PV +# specification for down-converts. It may even be wise to +# do one round through these tests without specifying the PVs +# to use and one round where we do. + +# test_lvconvert +# start_mirror_count: The '-m' argument to create with +# start_log_type: core|disk|mirrored +# final_mirror_count: The '-m' argument to convert to +# final_log_type: core|disk|mirrored +# active: Whether the LV should be active when the convert happens +# +# Exmaple: Convert 3-way disk-log mirror to +# 2-way disk-log mirror while not active +# -> test_lvconvert 2 disk 3 disk 0 + +test_lvconvert() +{ + local start_count=$1 + local start_count_p1=$(($start_count + 1)) + local start_log_type=$2 + local finish_count=$3 + local finish_count_p1=$(($finish_count + 1)) + local finish_log_type=$4 + local dev_array=($dev1 $dev2 $dev3 $dev4 $dev5) + local start_log_count + local finish_log_count + local max_log_count + local alloc="" + local active=true + local i + + if [ $start_log_type == "disk" ] && + [ $finish_log_type == "mirrored" ]; then + echo "FIXME: disk -> mirrored log conversion not yet supported by LVM" + return 0 + fi + + test "$5" = "active" && active=false + #test $finish_count -gt $start_count && up=true + + # Do we have enough devices for the mirror images? + if [ $start_count_p1 -gt ${#dev_array[@]} ]; then + echo "Action requires too many devices" + return 1 + fi + + # Do we have enough devices for the mirror images? + if [ $finish_count_p1 -gt ${#dev_array[@]} ]; then + echo "Action requires too many devices" + return 1 + fi + + start_log_count=`log_name_to_count $start_log_type` + finish_log_count=`log_name_to_count $finish_log_type` + if [ $finish_log_count -gt $start_log_count ]; then + max_log_count=$finish_log_count + else + max_log_count=$start_log_count + fi + + prepare_vg 5 + + if [ $start_count -gt 0 ]; then + # Are there extra devices for the log or do we overlap + if [ $(($start_count_p1 + $start_log_count)) -gt ${#dev_array[@]} ]; then + alloc="--alloc anywhere" + fi + + lvcreate -l2 -m $start_count --mirrorlog $start_log_type \ + -n $lv1 $vg $alloc + check mirror_legs $vg $lv1 $start_count_p1 + # FIXME: check mirror log + else + lvcreate -l2 -n $lv1 $vg + fi + + lvs -a -o name,copy_percent,devices $vg + if ! $active; then + lvchange -an $vg/$lv1 + fi + + # Are there extra devices for the log or do we overlap + if [ $(($finish_count_p1 + $finish_log_count)) -gt ${#dev_array[@]} ]; then + alloc="--alloc anywhere" + fi + + echo y | lvconvert -m $finish_count --mirrorlog $finish_log_type \ + $vg/$lv1 $alloc + + if ! $active; then + lvchange -ay $vg/$lv1 + fi + + check mirror_no_temporaries $vg $lv1 + if [ "$finish_count_p1" -eq 1 ]; then + check linear $vg $lv1 + else + if test -n "$alloc"; then + check mirror_nonredundant $vg $lv1 + else + check mirror $vg $lv1 + fi + check mirror_legs $vg $lv1 $finish_count_p1 + fi +} + +aux prepare_vg 5 + +# Test conversion combinations from linear <-> 4-way mirrors +for i in $(seq 0 4); do + for j in $(seq 0 4); do + for k in core disk mirrored; do + for l in core disk mirrored; do + if test "$i" -eq "$j" && test "$k" = "$l"; then continue; fi + : ---------------------------------------------------- + : "Testing mirror conversion -m$i/$k -> -m$j/$l" + : ---------------------------------------------------- + test_lvconvert $i $k $j $l 0 + test_lvconvert $i $k $j $l 1 + done + done + done +done +
test/check.sh +50 -12
112 lines not on this page · raw message
test/t-lvconvert-mirror.sh +168 -10
231 lines not on this page · raw message
test/t-lvcreate-mirror.sh +2 -2
@@ -20,13 +20,13 @@ # 2-way mirror with disklog, 3 PVs lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 check mirror_images_redundant $vg $lv1 -check mirror_log_on $vg/$lv1 $dev3 +check mirror_log_on $vg $lv1 $dev3 lvremove -ff $vg # 3-way mirror with disklog, 4 PVs lvcreate -l2 -m2 --mirrorlog disk -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0-1 check mirror_images_redundant $vg $lv1 -check mirror_log_on $vg/$lv1 $dev3 +check mirror_log_on $vg $lv1 $dev3 lvremove -ff $vg # lvcreate --nosync is in 100% sync after creation (bz429342)
test/t-vgcreate-usage.sh +2 -0
@@ -17,6 +17,8 @@ pvcreate $dev1 $dev2 pvcreate --metadatacopies 0 $dev3 +vg=${PREFIX}vg + #COMM 'vgcreate accepts 8.00m physicalextentsize for VG' vgcreate -c n $vg --physicalextentsize 8.00m $dev1 $dev2 check_vg_field_ $vg vg_extent_size 8.00m
test/test-utils.sh +17 -13
@@ -94,7 +94,7 @@ trap_teardown TESTDIR=$($abs_srcdir/mkdtemp ${LVM_TEST_DIR-$(pwd)} $PREFIX.XXXXXXXXXX) \ - || { echo "failed to create temporary directory in $test_dir_"; exit 1; } + || { echo "failed to create temporary directory in ${LVM_TEST_DIR-$(pwd)}"; exit 1; } export LVM_SYSTEM_DIR=$TESTDIR/etc export DM_DEV_DIR=$TESTDIR/dev
@@ -131,6 +131,7 @@ test -n "$LOOPFILE" && rm -f $LOOPFILE fi unset devs # devs is set in prepare_devs() + unset LOOP } teardown() {
@@ -178,7 +179,7 @@ trap_teardown for i in 0 1 2 3 4 5 6 7; do - mknod $DM_DEV_DIR/loop$i b 7 $i + test -e $DM_DEV_DIR/loop$i || mknod $DM_DEV_DIR/loop$i b 7 $i done LOOPFILE="$PWD/test.img"
@@ -291,16 +292,6 @@ local name="${PREFIX}$pvname$i" dmsetup table $name done - - # set up some default names - vg=${PREFIX}vg - vg1=${PREFIX}vg1 - vg2=${PREFIX}vg2 - lv=LV - lv1=LV1 - lv2=LV2 - lv3=LV3 - lv4=LV4 } disable_dev() {
@@ -346,10 +337,13 @@ prepare_pvs() { prepare_devs "$@" - pvcreate $devs + pvcreate -ff $devs } prepare_vg() { + vgremove -ff $vg || true + teardown_devs + prepare_pvs "$@" vgcreate -c n $vg $devs pvs -v
@@ -400,6 +394,16 @@ prepare_testroot prepare_lvmconf prepare_clvmd + + # set up some default names + vg=${PREFIX}vg + vg1=${PREFIX}vg1 + vg2=${PREFIX}vg2 + lv=LV + lv1=LV1 + lv2=LV2 + lv3=LV3 + lv4=LV4 } LANG=C