1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-25 01:34:38 +03:00
lvm2/test/t-vgcreate-usage.sh
Milan Broz de27790de8 add vgcreate rejects repeated invocation test
add vgcreate fails when the only pv has --metadatacopies 0 test
(by Jaroslav Stava)
2008-08-28 11:09:58 +00:00

116 lines
3.7 KiB
Bash
Executable File

#!/bin/sh
# Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
test_description='Exercise some vgcreate diagnostics'
privileges_required_=1
. ./test-lib.sh
cleanup_()
{
test -n "$d1" && losetup -d "$d1"
test -n "$d2" && losetup -d "$d2"
test -n "$d3" && losetup -d "$d3"
rm -f "$f1" "$f2" "$f3"
}
test_expect_success \
'set up temp files, loopback devices, PVs, vgname' \
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
vg=$(this_test_)-test-vg-$$ &&
pvcreate $d1 $d2 &&
pvcreate --metadatacopies 0 $d3
'
lv=vgcreate-usage-$$
test_expect_success \
'vgcreate accepts 8.00M physicalextentsize for VG' \
'vgcreate $vg --physicalextentsize 8.00M $d1 $d2 &&
check_vg_field_ $vg vg_extent_size 8.00M &&
vgremove $vg'
test_expect_success \
'vgcreate accepts smaller (128) maxlogicalvolumes for VG' \
'vgcreate $vg --maxlogicalvolumes 128 $d1 $d2 &&
check_vg_field_ $vg max_lv 128 &&
vgremove $vg'
test_expect_success \
'vgcreate accepts smaller (128) maxphysicalvolumes for VG' \
'vgcreate $vg --maxphysicalvolumes 128 $d1 $d2 &&
check_vg_field_ $vg max_pv 128 &&
vgremove $vg'
test_expect_success \
'vgcreate rejects a zero physical extent size' \
'vgcreate --physicalextentsize 0 $vg $d1 $d2 2>err;
status=$?; echo status=$status; test $status = 3 &&
grep "^ Physical extent size may not be zero\$" err'
test_expect_success \
'vgcreate rejects "inherit" allocation policy' \
'vgcreate --alloc inherit $vg $d1 $d2 2>err;
status=$?; echo status=$status; test $status = 3 &&
grep "^ Volume Group allocation policy cannot inherit from anything\$" err'
test_expect_success \
'vgcreate rejects vgname "."' \
'vg=.; vgcreate $vg $d1 $d2 2>err;
status=$?; echo status=$status; test $status = 3 &&
grep "New volume group name \"$vg\" is invalid\$" err'
test_expect_success \
'vgcreate rejects vgname greater than 128 characters' \
'vginvalid=thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome;
vgcreate $vginvalid $d1 $d2 2>err;
status=$?; echo status=$status; test $status = 3 &&
grep "New volume group name \"$vginvalid\" is invalid\$" err'
test_expect_success \
'vgcreate rejects already existing vgname "/tmp/$vg"' \
'touch /tmp/$vg; vgcreate $vg $d1 $d2 2>err;
status=$?; echo status=$status; test $status = 3 &&
grep "New volume group name \"$vg\" is invalid\$" err'
test_expect_success \
'cleanup vg name' '
vg=$(this_test_)-test-vg-$$
'
test_expect_success \
"vgcreate rejects repeated invocation (run 2 times)" '
vgcreate $vg $d1 $d2 && {
vgcreate $vg $d1 $d2;
status=$?; echo status=$status; test $status = 5 &&
vgremove -ff $vg
}
'
test_expect_success \
'vgcreate rejects MaxLogicalVolumes > 255' \
'vgcreate --metadatatype 1 --maxlogicalvolumes 1024 $vg $d1 $d2 2>err;
status=$?; echo status=$status; test $status = 3 &&
grep "^ Number of volumes may not exceed 255\$" err'
test_expect_success \
"vgcreate fails when the only pv has --metadatacopies 0" '
vgcreate $vg $d3;
status=$?; echo status=$status; test $status = 5
'
test_done
# Local Variables:
# indent-tabs-mode: nil
# End: