~ubuntu-branches/ubuntu/saucy/lvm2/saucy

« back to all changes in this revision

Viewing changes to test/t-pvcreate-usage.sh

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-08-14 14:35:57 UTC
  • mfrom: (3.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20120814143557-93aill2tp3kf3o30
Tags: 2.02.95-4ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/patches/avoid-dev-block.patch: Prefer any other device name over
    names in /dev/block/ since lvm.conf won't handle this.
  - debian/rules:
    - copy .po file to .pot file for Rosetta (Ubuntu specific).
  - debian/{dmsetup,lvm2}-udeb.install:
    - install initramfs and udev hooks in udebs (Debian bug 504341).
  - auto-start VGs as their PVs are discovered (Ubuntu specific):
    - add debian/tree/lvm2/lib/udev/rules.d/85-lvm2.rules: use watershed plus
      the sledgehammer of vgscan/vgchange to turn on VGs as they come online.
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/hooks/lvm2:
      - add 85-lvm2.rules to the list of udev rules to copy.
      - depend on udev.
    - debian/control:
      - add versioned Depend on watershed in lvm2 for udev rules.
      - add Depends on watershed-udeb in lvm2-udeb for udev rules.
      - add versioned Depend/Breaks on udev in dmsetup for udev rules.
      - add Depend on initramfs-tools in dmsetup so system is not potentially
        rendered unbootable by out-of-order dpkg configuration.
    - debian/rules:
      - do not install local-top scripts since Ubuntu mounts root using udev.
      - do not install init scripts for lvm2, since udev starts LVM.
    - debian/lvm2.postinst: handle missing lvm2 init script.
    - debian/tree/dmsetup/lib/udev/rules.d/60-persistent-storage-dm.rules:
      watch dm devices for changes with inotify
  - add mountroot failure hooks to help fix bad boots (Debian bug 468115):
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/init-premount/lvm2
  - remaining changes to upstream event manager packages (Debian bug 514706):
    - debian/rules:
      - enable dmeventd during configure.
    - debian/dmeventd.{8,manpages}: install dmeventd files.
  - rename debian/clvm.defaults to debian/clvm.default so it is installed
    correctly.
  - debian/control: add dmsetup-udeb to libdevmapper1.02.1-udeb recommends.
  - debian/rules: make sure dmsetup and lvm2 initramfs-tools scripts are
    executable.  When the Ubuntu-specific ones are added with a patch,
    they may lose their executable bit.
  - Add and install clvmd resource agent
  - Add dependency on libudev-dev to libdevmapper-dev so that the .pc file
    works.
  - debian/{clvmd.ra,clvm.init}:
    - create /run/lvm if it doesn't exist.
  - debian/clvm.init:
    - exit 3 if not running on status action.
  - Call dh_installman so that our dmeventd manpage actually gets installed
  - Install the missing fsadm manpage.

 * libdevmapper-dev:
  - move .so symlinks and pkgconfig files to multiarched locations.
  - mark libdevmapper-dev M-A: same

 * libdevmapper-event1.02.1:
  - Add Breaks: dmeventd (<< 2.02.95-4ubuntu1) due to debian symbol rename

 * debian/lvm2.{preinst,postinst,postrm}:
  - Implement removal of obsolete /etc/init.d/lvm2 conffile, which
    should not have been re-introduced in Quantal.

 * Dropped Changes, included in Debian:
  - Mostly included packages for upstream event manager (Debian bug 514706).
  - debian/patches/rules-subdir.patch: removed as reordering will cause
    build failure with dmeventd.
  - debian/patches/libdm-event-static.patch: removed as other static libs
    aren't being built anymore either.
  - Update symbols for libdevmapper-event.
  - Update libdevmapper-event, dmeventd descriptions to match Debian
    boilerplate.

 * Disappeared Changes:
  - Don't install documentation in udebs. No diff found, but no docs are
    installed into udebs either.

 * Resurected Changes:
  - corrected dropping the wrong init script. Now clvm.init is shipped
    and lvm2.init is dropped in favor of udev rules as per original
    intention (LP: #1037033).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
3
 
#
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.
7
 
#
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
11
 
 
12
 
test_description='Test pvcreate option values'
13
 
PAGESIZE=$(getconf PAGESIZE)
14
 
 
15
 
. lib/test
16
 
 
17
 
aux prepare_devs 4
18
 
 
19
 
#COMM 'pvcreate rejects negative setphysicalvolumesize'
20
 
not pvcreate --setphysicalvolumesize -1024 $dev1
21
 
 
22
 
#COMM 'pvcreate rejects negative metadatasize'
23
 
not pvcreate --metadatasize -1024 $dev1
24
 
 
25
 
# x. metadatasize 0, defaults to 255
26
 
# FIXME: unable to check default value, not in reporting cmds
27
 
# should default to 255 according to code
28
 
#   check pv_field pv_mda_size 255 
29
 
#COMM 'pvcreate accepts metadatasize 0'
30
 
pvcreate --metadatasize 0 $dev1
31
 
pvremove $dev1
32
 
 
33
 
#Verify vg_mda_size is smaller pv_mda_size
34
 
pvcreate --metadatasize 512k $dev1
35
 
pvcreate --metadatasize 96k $dev2
36
 
vgcreate $vg $dev1 $dev2
37
 
check compare_fields vgs $vg vg_mda_size pvs $dev2 pv_mda_size
38
 
vgremove -ff $vg
39
 
 
40
 
# x. metadatasize too large
41
 
# For some reason we allow this, even though there's no room for data?
42
 
##COMM  'pvcreate rejects metadatasize too large' 
43
 
#not pvcreate --metadatasize 100000000000000 $dev1
44
 
 
45
 
#COMM 'pvcreate rejects metadatacopies < 0'
46
 
not pvcreate --metadatacopies -1 $dev1
47
 
 
48
 
#COMM 'pvcreate accepts metadatacopies = 0, 1, 2'
49
 
for j in metadatacopies pvmetadatacopies
50
 
do
51
 
pvcreate --$j 0 $dev1
52
 
pvcreate --$j 1 $dev2
53
 
pvcreate --$j 2 $dev3
54
 
check pv_field $dev1 pv_mda_count 0
55
 
check pv_field $dev2 pv_mda_count 1
56
 
check pv_field $dev3 pv_mda_count 2
57
 
pvremove $dev1 
58
 
pvremove $dev2 
59
 
pvremove $dev3
60
 
done
61
 
 
62
 
#COMM 'pvcreate rejects metadatacopies > 2'
63
 
not pvcreate --metadatacopies 3 $dev1
64
 
 
65
 
#COMM 'pvcreate rejects invalid device'
66
 
not pvcreate $dev1bogus
67
 
 
68
 
#COMM 'pvcreate rejects labelsector < 0'
69
 
not pvcreate --labelsector -1 $dev1
70
 
 
71
 
#COMM 'pvcreate rejects labelsector > 1000000000000'
72
 
not pvcreate --labelsector 1000000000000 $dev1
73
 
 
74
 
# other possibilites based on code inspection (not sure how hard)
75
 
# x. device too small (min of 512 * 1024 KB)
76
 
# x. device filtered out
77
 
# x. unable to open /dev/urandom RDONLY
78
 
# x. device too large (pe_count > UINT32_MAX)
79
 
# x. device read-only
80
 
# x. unable to open device readonly
81
 
# x. BLKGETSIZE64 fails
82
 
# x. set size to value inconsistent with device / PE size
83
 
 
84
 
#COMM 'pvcreate basic dataalignment sanity checks'
85
 
not pvcreate --dataalignment -1 $dev1
86
 
not pvcreate -M 1 --dataalignment 1 $dev1
87
 
not pvcreate --dataalignment 1e $dev1
88
 
 
89
 
#COMM 'pvcreate always rounded up to page size for start of device'
90
 
#pvcreate --metadatacopies 0 --dataalignment 1 $dev1
91
 
# amuse shell experts
92
 
#check pv_field $dev1 pe_start $(($(getconf PAGESIZE)/1024))".00k"
93
 
 
94
 
#COMM 'pvcreate sets data offset directly'
95
 
pvcreate --dataalignment 512k $dev1
96
 
check pv_field $dev1 pe_start 512.00k
97
 
 
98
 
#COMM 'vgcreate/vgremove do not modify data offset of existing PV'
99
 
vgcreate $vg $dev1  --config 'devices { data_alignment = 1024 }'
100
 
check pv_field $dev1 pe_start 512.00k
101
 
vgremove $vg --config 'devices { data_alignment = 1024 }'
102
 
check pv_field $dev1 pe_start 512.00k
103
 
 
104
 
#COMM 'pvcreate sets data offset next to mda area'
105
 
pvcreate --metadatasize 100k --dataalignment 100k $dev1
106
 
check pv_field $dev1 pe_start 200.00k
107
 
 
108
 
# metadata area start is aligned according to pagesize
109
 
if [ $PAGESIZE -eq 65536 ] ; then
110
 
        pv_align="192.50k"
111
 
elif [ $PAGESIZE -eq 8192 ] ; then
112
 
        pv_align="136.50k"
113
 
else
114
 
        pv_align="133.00k"
115
 
fi
116
 
 
117
 
pvcreate --metadatasize 128k --dataalignment 3.5k $dev1
118
 
check pv_field $dev1 pe_start $pv_align
119
 
 
120
 
pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1
121
 
check pv_field $dev1 pe_start $pv_align
122
 
 
123
 
# data area is aligned to 1M by default,
124
 
# data area start is shifted by the specified alignment_offset
125
 
pv_align="1052160B" # 1048576 + (7*512)
126
 
pvcreate --metadatasize 128k --dataalignmentoffset 7s $dev1
127
 
check pv_field $dev1 pe_start $pv_align "--units b"
128
 
 
129
 
# 2nd metadata area is created without problems when
130
 
# data area start is shifted by the specified alignment_offset
131
 
pvcreate --metadatasize 128k --metadatacopies 2 --dataalignmentoffset 7s $dev1
132
 
check pv_field $dev1 pv_mda_count 2
133
 
# FIXME: compare start of 2nd mda with and without --dataalignmentoffset
134
 
 
135
 
#COMM 'pv with LVM1 compatible data alignment can be convereted'
136
 
#compatible == LVM1_PE_ALIGN == 64k
137
 
pvcreate --dataalignment 256k $dev1
138
 
vgcreate -s 1m $vg $dev1
139
 
vgconvert -M1 $vg
140
 
vgconvert -M2 $vg
141
 
check pv_field $dev1 pe_start 256.00k
142
 
vgremove $vg
143
 
 
144
 
#COMM 'pv with LVM1 incompatible data alignment cannot be convereted'
145
 
pvcreate --dataalignment 10k $dev1
146
 
vgcreate -s 1m $vg $dev1
147
 
not vgconvert -M1 $vg
148
 
vgremove $vg
149
 
 
150
 
#COMM 'vgcfgrestore allows pe_start=0'
151
 
#basically it produces nonsense, but it tests vgcfgrestore,
152
 
#not that final cfg is usable...
153
 
pvcreate --metadatacopies 0 $dev1
154
 
pvcreate $dev2
155
 
vgcreate $vg $dev1 $dev2
156
 
vgcfgbackup -f "$(pwd)/backup.$$" $vg
157
 
sed 's/pe_start = [0-9]*/pe_start = 0/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1"
158
 
vgcfgrestore -f "$(pwd)/backup.$$1" $vg
159
 
check pv_field $dev1 pe_start 0
160
 
check pv_field $dev2 pe_start 0
161
 
vgremove $vg
162
 
 
163
 
echo test pvcreate --metadataignore
164
 
for pv_in_vg in 1 0; do
165
 
for mdacp in 1 2; do
166
 
for ignore in y n; do
167
 
        echo pvcreate --metadataignore has proper mda_count and mda_used_count
168
 
        pvcreate --metadatacopies $mdacp --metadataignore $ignore $dev1 $dev2
169
 
        check pv_field $dev1 pv_mda_count $mdacp
170
 
        check pv_field $dev2 pv_mda_count $mdacp
171
 
        if [ $ignore = y ]; then
172
 
                check pv_field $dev1 pv_mda_used_count 0
173
 
                check pv_field $dev2 pv_mda_used_count 0
174
 
        else
175
 
                check pv_field $dev1 pv_mda_used_count $mdacp
176
 
                check pv_field $dev2 pv_mda_used_count $mdacp
177
 
        fi
178
 
        echo vgcreate has proper vg_mda_count and vg_mda_used_count
179
 
        if [ $pv_in_vg = 1 ]; then
180
 
                vgcreate -c n "$vg" $dev1 $dev2
181
 
                check vg_field $vg vg_mda_count $(($mdacp * 2))
182
 
                if [ $ignore = y ]; then
183
 
                        check vg_field $vg vg_mda_used_count 1
184
 
                else
185
 
                        check vg_field $vg vg_mda_used_count $(($mdacp * 2))
186
 
                fi
187
 
                check vg_field $vg vg_mda_copies unmanaged
188
 
                vgremove $vg
189
 
        fi
190
 
done
191
 
done
192
 
done