summaryrefslogtreecommitdiff
path: root/test/shell/process-each-vg.sh
blob: e8690f51e3c7d2bcf8a691c3ab55f4537ff6546a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/bin/sh
# Copyright (C) 2008-2013 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 toollib process_each_vg'

. lib/inittest

aux prepare_devs 6

#
# process_each_vg is used by a number of vg commands;
# use 'vgremove' and 'vgs' to test it.
#
# The logic in process_each_vg is mainly related to
# selecting which vg's to process.
#

#
# set up four vgs that we will remove
#
vgcreate $vg1 "$dev1"
vgcreate $vg2 "$dev2"
vgcreate $vg3 "$dev3"
vgcreate $vg4 "$dev4"

# these two vgs will not be removed
vgcreate $vg5 "$dev5"
vgchange --addtag tagvg5 $vg5
lvcreate -l 4 -n $lv1 $vg5
vgcreate $vg6 "$dev6"
lvcreate -l 4 -n $lv2 $vg6

# should fail without any arg
not vgremove

# should succeed
vgremove $vg1
vgremove $vg2 $vg3 $vg4

# these should fail because they are already removed
not vgremove $vg1
not vgremove $vg2
not vgremove $vg3
not vgremove $vg4

# these should fail because they have lvs in them
not vgremove $vg5
not vgremove $vg6

# check that the vgs we removed are gone
not vgs $vg1
not vgs $vg2
not vgs $vg3
not vgs $vg4


#
# set up four vgs that we will remove
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

# should do nothing and fail
not vgremove garbage

# should find nothing to remove
vgremove @garbage

# should find nothing to remove
vgremove @$vg1

# should succeed
vgremove $vg1
not vgs $vg1

vgremove $vg2 $vg3 $vg4
not vgs $vg2
not vgs $vg3
not vgs $vg4


#
# set up four vgs that we will remove
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

vgremove @tagfoo
not vgs $vg1
not vgs $vg2

vgremove @tagfoo2 @tagbar
not vgs $vg3
not vgs $vg4


#
# set up four vgs that we will remove
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

vgremove $vg1 @tagfoo2
not vgs $vg1
not vgs $vg3

vgremove @tagbar $vg2
not vgs $vg2
not vgs $vg4


#
# set up four vgs that we will remove
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

vgremove @foo @tagfoo2 $vg1 $vg2
not vgs $vg1
not vgs $vg2
not vgs $vg3
not vgs $vg4


#
# set up four vgs that we will remove
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

vgremove @tagfoo $vg1 @tagfoo @tagfoo2 $vg3 @tagbar
not vgs $vg1
not vgs $vg2
not vgs $vg3
not vgs $vg4


#
# set up four vgs that we will remove
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

not vgremove garbage $vg1
not vgs $vg1

not vgremove $vg2 garbage
not vgs $vg2

vgremove $vg3 @garbage
not vgs $vg3

vgremove @garbage $vg4
not vgs $vg4


#
# end vgremove tests
# check that the two vgs we did not intend to remove
# are still there, and then remove them
#
vgs $vg5
vgs $vg6
vgremove -f $vg5
vgremove -f $vg6
not vgs $vg5
not vgs $vg6


#
# set up four vgs that we will report
#
vgcreate --addtag tagfoo $vg1 "$dev1"
vgcreate --addtag tagfoo $vg2 "$dev2"
vgcreate --addtag tagfoo2 $vg3 "$dev3"
vgcreate --addtag tagbar $vg4 "$dev4"
vgchange --addtag foo $vg4

vgs >err
grep $vg1 err
grep $vg2 err
grep $vg3 err
grep $vg4 err

vgs $vg1 $vg2 >err
grep $vg1 err
grep $vg2 err
not grep $vg3 err
not grep $vg4 err

vgs @tagfoo >err
grep $vg1 err
grep $vg2 err
not grep $vg3 err
not grep $vg4 err

vgs @tagfoo2 >err
grep $vg3 err
not grep $vg1 err
not grep $vg2 err
not grep $vg4 err

vgs @tagfoo2 @tagbar >err
grep $vg3 err
grep $vg4 err
not grep $vg1 err
not grep $vg2 err

vgs $vg1 @tagbar >err
grep $vg1 err
grep $vg4 err
not grep $vg2 err
not grep $vg3 err

vgs $vg1 @tagfoo >err
grep $vg1 err
grep $vg2 err
not grep $vg3 err
not grep $vg4 err

not vgs garbage >err
not grep $vg1 err
not grep $vg2 err
not grep $vg3 err
not grep $vg4 err

not vgs garbage $vg1 >err
grep $vg1 err
not grep $vg2 err
not grep $vg3 err
not grep $vg4 err

vgs @garbage @foo >err
grep $vg4 err
not grep $vg1 err
not grep $vg2 err
not grep $vg3 err