2 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions
6 # of the GNU General Public License v.2.
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software Foundation,
10 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12 test_description
='Exercise some vgcreate diagnostics'
18 pvcreate
--metadatacopies 0 $dev3
20 #COMM 'vgcreate accepts 8.00m physicalextentsize for VG'
21 vgcreate
$vg --physicalextentsize 8.00m
$dev1 $dev2
22 check_vg_field_
$vg vg_extent_size
8.00m
24 # try vgck and to remove it again - should fail (but not segfault)
28 #COMM 'vgcreate accepts smaller (128) maxlogicalvolumes for VG'
29 vgcreate
$vg --maxlogicalvolumes 128 $dev1 $dev2
30 check_vg_field_
$vg max_lv
128
33 #COMM 'vgcreate accepts smaller (128) maxphysicalvolumes for VG'
34 vgcreate
$vg --maxphysicalvolumes 128 $dev1 $dev2
35 check_vg_field_
$vg max_pv
128
38 #COMM 'vgcreate rejects a zero physical extent size'
39 not vgcreate
--physicalextentsize 0 $vg $dev1 $dev2 2>err
40 grep "^ Physical extent size may not be zero\$" err
42 #COMM 'vgcreate rejects "inherit" allocation policy'
43 not vgcreate
--alloc inherit
$vg $dev1 $dev2 2>err
44 grep "^ Volume Group allocation policy cannot inherit from anything\$" err
46 #COMM 'vgcreate rejects vgname "."'
48 not vgcreate
$vginvalid $dev1 $dev2 2>err
49 grep "New volume group name \"$vginvalid\" is invalid\$" err
51 #COMM 'vgcreate rejects vgname greater than 128 characters'
52 vginvalid
=thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome
53 not vgcreate
$vginvalid $dev1 $dev2 2>err
54 grep "New volume group name \"$vginvalid\" is invalid\$" err
56 #COMM 'vgcreate rejects already existing vgname "/tmp/$vg"'
58 #not vgcreate $vg $dev1 $dev2 2>err
59 #grep "New volume group name \"$vg\" is invalid\$" err
61 #COMM "vgcreate rejects repeated invocation (run 2 times) (bz178216)"
62 vgcreate
$vg $dev1 $dev2
63 not vgcreate
$vg $dev1 $dev2
66 #COMM 'vgcreate rejects MaxLogicalVolumes > 255'
67 not vgcreate
--metadatatype 1 --maxlogicalvolumes 1024 $vg $dev1 $dev2 2>err
68 grep "^ Number of volumes may not exceed 255\$" err
70 #COMM "vgcreate fails when the only pv has --metadatacopies 0"
71 not vgcreate
$vg $dev3
73 # Test default (4MB) vg_extent_size as well as limits of extent_size
74 not vgcreate
--physicalextentsize 0k
$vg $dev1 $dev2
75 vgcreate
--physicalextentsize 1k
$vg $dev1 $dev2
76 check_vg_field_
$vg vg_extent_size
1.00k
78 not vgcreate
--physicalextentsize 3K
$vg $dev1 $dev2
79 not vgcreate
--physicalextentsize 1024t
$vg $dev1 $dev2
80 #not vgcreate --physicalextentsize 1T $vg $dev1 $dev2
81 # FIXME: vgcreate allows physicalextentsize larger than pv size!
83 # Test default max_lv, max_pv, extent_size, alloc_policy, clustered
84 vgcreate
$vg $dev1 $dev2
85 check_vg_field_
$vg vg_extent_size
4.00m
86 check_vg_field_
$vg max_lv
0
87 check_vg_field_
$vg max_pv
0
88 check_vg_field_
$vg vg_attr
"wz--n-"
91 # Implicit pvcreate tests, test pvcreate options on vgcreate
92 # --force, --yes, --metadata{size|copies|type}, --zero
93 # --dataalignment[offset]
95 vgcreate
--force --yes --zero y
$vg $dev1 $dev2
101 # vgcreate (lvm2) succeeds writing LVM label at sector $i
102 vgcreate
--labelsector $i $vg $dev1
103 dd if=$dev1 bs
=512 skip
=$i count
=1 2>/dev
/null |
strings |
grep -q LABELONE
;
111 vgcreate
--pvmetadatacopies $i $vg $dev1
112 check_pv_field_
$dev1 pv_mda_count
$i
116 not vgcreate
--metadatacopies 0 $vg $dev1
117 pvcreate
--metadatacopies 1 $dev2
118 vgcreate
--pvmetadatacopies 0 $vg $dev1 $dev2
119 check_pv_field_
$dev1 pv_mda_count
0
120 check_pv_field_
$dev2 pv_mda_count
1
124 # metadatasize, dataalignment, dataalignmentoffset
125 #COMM 'pvcreate sets data offset next to mda area'
126 vgcreate
--metadatasize 100k
--dataalignment 100k
$vg $dev1
127 check_pv_field_
$dev1 pe_start
200.00k
131 # data area is aligned to 64k by default,
132 # data area start is shifted by the specified alignment_offset
134 vgcreate
--metadatasize 128k
--dataalignmentoffset 7s
$vg $dev1
135 check_pv_field_
$dev1 pe_start
$pv_align
142 vgcreate
-M $i $vg $dev1
143 check_vg_field_
$vg vg_fmt lvm
$i
148 # vgcreate fails if pv belongs to existing vg
149 vgcreate
$vg1 $dev1 $dev2
150 not vgcreate
$vg2 $dev2
152 pvremove
-f $dev1 $dev2
154 # all PVs exist in the VG after created
156 vgcreate
$vg1 $dev1 $dev2 $dev3
157 check_pv_field_
$dev1 vg_name
$vg1
158 check_pv_field_
$dev2 vg_name
$vg1
159 check_pv_field_
$dev3 vg_name
$vg1
161 pvremove
-f $dev1 $dev2 $dev3