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

« back to all changes in this revision

Viewing changes to test/t-vgsplit-operation.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) 2007 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 vgsplit operation, including different LV types
13
 
 
14
 
. lib/test
15
 
 
16
 
COMM() {  
17
 
        LAST_TEST="$@"
18
 
}
19
 
 
20
 
aux prepare_pvs 5 258
21
 
# FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run
22
 
# fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1
23
 
# metadata
24
 
 
25
 
#
26
 
# vgsplit can be done into a new or existing VG
27
 
#
28
 
for i in new existing
29
 
do
30
 
        #
31
 
        # We can have PVs or LVs on the cmdline
32
 
        #
33
 
        for j in PV LV
34
 
        do
35
 
COMM "vgsplit correctly splits single linear LV into $i VG ($j args)"
36
 
                vgcreate $vg1 $dev1 $dev2 
37
 
                if [ $i = existing ]; then
38
 
                   vgcreate $vg2 $dev3 $dev4
39
 
                fi 
40
 
                lvcreate -l 4 -n $lv1 $vg1 $dev1 
41
 
                vgchange -an $vg1 
42
 
                if [ $j = PV ]; then
43
 
                  vgsplit $vg1 $vg2 $dev1
44
 
                else
45
 
                  vgsplit -n $lv1 $vg1 $vg2
46
 
                fi 
47
 
                check pvlv_counts $vg1 1 0 0 
48
 
                if [ $i = existing ]; then
49
 
                   check pvlv_counts $vg2 3 1 0
50
 
                else
51
 
                   check pvlv_counts $vg2 1 1 0
52
 
                fi 
53
 
                lvremove -f $vg2/$lv1 
54
 
                vgremove -f $vg2 
55
 
                vgremove -f $vg1
56
 
 
57
 
COMM "vgsplit correctly splits single striped LV into $i VG ($j args)"
58
 
                vgcreate $vg1 $dev1 $dev2 
59
 
                if [ $i = existing ]; then
60
 
                   vgcreate $vg2 $dev3 $dev4
61
 
                fi 
62
 
                lvcreate -l 4 -i 2 -n $lv1 $vg1 $dev1 $dev2 
63
 
                vgchange -an $vg1 
64
 
                if [ $j = PV ]; then
65
 
                  vgsplit $vg1 $vg2 $dev1 $dev2
66
 
                else
67
 
                  vgsplit -n $lv1 $vg1 $vg2
68
 
                fi 
69
 
                if [ $i = existing ]; then
70
 
                  check pvlv_counts $vg2 4 1 0
71
 
                else
72
 
                  check pvlv_counts $vg2 2 1 0
73
 
                fi 
74
 
                lvremove -f $vg2/$lv1 
75
 
                vgremove -f $vg2
76
 
 
77
 
COMM "vgsplit correctly splits mirror LV into $i VG ($j args)" 
78
 
                vgcreate -c n $vg1 $dev1 $dev2 $dev3 
79
 
                if [ $i = existing ]; then
80
 
                  vgcreate -c n $vg2 $dev4
81
 
                fi 
82
 
                lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3 
83
 
                vgchange -an $vg1 
84
 
                if [ $j = PV ]; then
85
 
                  vgsplit $vg1 $vg2 $dev1 $dev2 $dev3
86
 
                else
87
 
                  vgsplit -n $lv1 $vg1 $vg2
88
 
                fi 
89
 
                if [ $i = existing ]; then
90
 
                  check pvlv_counts $vg2 4 1 0
91
 
                else
92
 
                  check pvlv_counts $vg2 3 1 0
93
 
                fi 
94
 
                lvremove -f $vg2/$lv1 
95
 
                vgremove -f $vg2
96
 
 
97
 
COMM "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)" 
98
 
                vgcreate -c n $vg1 $dev1 $dev2 
99
 
                if [ $i = existing ]; then
100
 
                  vgcreate -c n $vg2 $dev3 $dev4
101
 
                fi 
102
 
                lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2 
103
 
                lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 
104
 
                vgchange -an $vg1 
105
 
                if [ $j = PV ]; then
106
 
                  vgsplit $vg1 $vg2 $dev1 $dev2
107
 
                else
108
 
                  vgsplit -n $lv1 $vg1 $vg2
109
 
                fi 
110
 
                if [ $i = existing ]; then
111
 
                  check pvlv_counts $vg2 4 2 1
112
 
                else
113
 
                  check pvlv_counts $vg2 2 2 1
114
 
                fi 
115
 
                lvremove -f $vg2/$lv2 
116
 
                lvremove -f $vg2/$lv1 
117
 
                vgremove -f $vg2
118
 
 
119
 
COMM "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)" 
120
 
                vgcreate -c n $vg1 $dev1 $dev2 
121
 
                if [ $i = existing ]; then
122
 
                  vgcreate -c n $vg2 $dev3
123
 
                fi 
124
 
                lvcreate -l 64 -i 2 -n $lv1 $vg1 
125
 
                lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 
126
 
                vgextend $vg1 $dev4 
127
 
                lvcreate -l 64 -n $lv3 $vg1 $dev4 
128
 
                vgchange -an $vg1 
129
 
                if [ $j = PV ]; then
130
 
                  vgsplit $vg1 $vg2 $dev4
131
 
                else
132
 
                  vgsplit -n $lv3 $vg1 $vg2
133
 
                fi 
134
 
                if [ $i = existing ]; then
135
 
                  check pvlv_counts $vg2 2 1 0
136
 
                  check pvlv_counts $vg1 2 2 1
137
 
                else
138
 
                  check pvlv_counts $vg2 1 1 0
139
 
                  check pvlv_counts $vg1 2 2 1
140
 
                fi 
141
 
                lvremove -f $vg1/$lv2 
142
 
                lvremove -f $vg1/$lv1 
143
 
                lvremove -f $vg2/$lv3 
144
 
                vgremove -f $vg1 
145
 
                vgremove -f $vg2
146
 
 
147
 
COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)" 
148
 
                vgcreate -c n $vg1 $dev1 $dev2 $dev3 
149
 
                if [ $i = existing ]; then
150
 
                  vgcreate -c n $vg2 $dev5
151
 
                fi 
152
 
                lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3 
153
 
                vgextend $vg1 $dev4 
154
 
                lvcreate -l 64 -n $lv2 $vg1 $dev4 
155
 
                vgchange -an $vg1 
156
 
                vgs
157
 
                lvs 
158
 
                pvs
159
 
                if [ $j = PV ]; then
160
 
                  vgsplit $vg1 $vg2 $dev4
161
 
                else
162
 
                  vgsplit -n $lv2 $vg1 $vg2
163
 
                fi 
164
 
                if [ $i = existing ]; then
165
 
                  check pvlv_counts $vg1 3 1 0
166
 
                  check pvlv_counts $vg2 2 1 0
167
 
                else
168
 
                vgs
169
 
                lvs 
170
 
                pvs
171
 
                  check pvlv_counts $vg1 3 1 0
172
 
                  check pvlv_counts $vg2 1 1 0
173
 
                fi 
174
 
                lvremove -f $vg1/$lv1 
175
 
                lvremove -f $vg2/$lv2 
176
 
                vgremove -f $vg1 
177
 
                vgremove -f $vg2
178
 
 
179
 
        done
180
 
done
181
 
 
182
 
#
183
 
# Test more complex setups where the code has to find associated PVs and
184
 
# LVs to split the VG correctly
185
 
186
 
COMM "vgsplit fails splitting 3 striped LVs into VG when only 1 LV specified" 
187
 
vgcreate $vg1 $dev1 $dev2 $dev3 $dev4 
188
 
lvcreate -l 4 -n $lv1 -i 2 $vg1 $dev1 $dev2 
189
 
lvcreate -l 4 -n $lv2 -i 2 $vg1 $dev2 $dev3 
190
 
lvcreate -l 4 -n $lv3 -i 2 $vg1 $dev3 $dev4 
191
 
vgchange -an $vg1 
192
 
not vgsplit -n $lv1 $vg1 $vg2
193
 
vgremove -ff $vg1
194
 
 
195
 
COMM "vgsplit fails splitting one LV with 2 snapshots, only origin LV specified" 
196
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
197
 
lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2 
198
 
lvcreate -l 4 -n $lv2 -s $vg1/$lv1 $dev3
199
 
lvcreate -l 4 -n $lv3 -s $vg1/$lv1 $dev4
200
 
check pvlv_counts $vg1 4 3 2 
201
 
vgchange -an $vg1 
202
 
not vgsplit -n $lv1 $vg1 $vg2;
203
 
lvremove -f $vg1/$lv2 
204
 
lvremove -f $vg1/$lv3 
205
 
lvremove -f $vg1/$lv1 
206
 
vgremove -ff $vg1
207
 
 
208
 
COMM "vgsplit fails splitting one LV with 2 snapshots, only snapshot LV specified" 
209
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
210
 
lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2 
211
 
lvcreate -l 4 -n $lv2 -s $vg1/$lv1 $dev3
212
 
lvcreate -l 4 -n $lv3 -s $vg1/$lv1 $dev4
213
 
check pvlv_counts $vg1 4 3 2 
214
 
vgchange -an $vg1 
215
 
not vgsplit -n $lv2 $vg1 $vg2
216
 
lvremove -f $vg1/$lv2 
217
 
lvremove -f $vg1/$lv3 
218
 
lvremove -f $vg1/$lv1 
219
 
vgremove -ff $vg1
220
 
 
221
 
COMM "vgsplit fails splitting one mirror LV, only one PV specified" 
222
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
223
 
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 
224
 
check pvlv_counts $vg1 4 1 0 
225
 
vgchange -an $vg1 
226
 
not vgsplit $vg1 $vg2 $dev2 
227
 
vgremove -ff $vg1
228
 
 
229
 
COMM "vgsplit fails splitting 1 mirror + 1 striped LV, only striped LV specified" 
230
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
231
 
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 
232
 
lvcreate -l 16 -n $lv2 -i 2 $vg1 $dev3 $dev4 
233
 
check pvlv_counts $vg1 4 2 0 
234
 
vgchange -an $vg1 
235
 
not vgsplit -n $lv2 $vg1 $vg2 2>err
236
 
vgremove -ff $vg1
237
 
 
238
 
#
239
 
# Verify vgsplit rejects active LVs only when active LVs involved in split
240
 
#
241
 
COMM "vgsplit fails, active mirror involved in split" 
242
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
243
 
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 
244
 
lvcreate -l 16 -n $lv2 $vg1 $dev4 
245
 
lvchange -an $vg1/$lv2 
246
 
check pvlv_counts $vg1 4 2 0 
247
 
not vgsplit -n $lv1 $vg1 $vg2;
248
 
check pvlv_counts $vg1 4 2 0 
249
 
vgremove -ff $vg1
250
 
 
251
 
COMM "vgsplit succeeds, active mirror not involved in split" 
252
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
253
 
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 
254
 
lvcreate -l 16 -n $lv2 $vg1 $dev4 
255
 
lvchange -an $vg1/$lv2 
256
 
check pvlv_counts $vg1 4 2 0 
257
 
vgsplit -n $lv2 $vg1 $vg2 
258
 
check pvlv_counts $vg1 3 1 0 
259
 
check pvlv_counts $vg2 1 1 0 
260
 
vgremove -ff $vg1 
261
 
vgremove -ff $vg2
262
 
 
263
 
COMM "vgsplit fails, active snapshot involved in split" 
264
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 
265
 
lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2 
266
 
lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 
267
 
lvcreate -l 64 -i 2 -n $lv3 $vg1 $dev3 $dev4 
268
 
lvchange -an $vg1/$lv3 
269
 
check pvlv_counts $vg1 4 3 1 
270
 
not vgsplit -n $lv2 $vg1 $vg2;
271
 
check pvlv_counts $vg1 4 3 1 
272
 
lvremove -f $vg1/$lv2 
273
 
vgremove -ff $vg1
274
 
 
275
 
COMM "vgsplit succeeds, active snapshot not involved in split" 
276
 
vgcreate -c n $vg1 $dev1 $dev2 $dev3 
277
 
lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2 
278
 
lvcreate -l 4 -s -n $lv2 $vg1/$lv1 
279
 
vgextend $vg1 $dev4 
280
 
lvcreate -l 64 -n $lv3 $vg1 $dev4 
281
 
lvchange -an $vg1/$lv3 
282
 
check pvlv_counts $vg1 4 3 1 
283
 
vgsplit -n $lv3 $vg1 $vg2 
284
 
check pvlv_counts $vg1 3 2 1 
285
 
check pvlv_counts $vg2 1 1 0 
286
 
vgchange -an $vg1 
287
 
lvremove -f $vg1/$lv2 
288
 
vgremove -ff $vg1 
289
 
vgremove -ff $vg2
290