]>
Commit | Line | Data |
---|---|---|
97691508 AC |
1 | # Set of tests for autorebuild functionality using mdadm -F |
2 | # To be able to test ddf one must have all loop devices of bigger size, with the ones | |
3 | # above number 7 bigger again by any amount (this is not changed for now as it | |
4 | # could affect other tests) | |
5 | ||
3cdcfda4 N |
6 | export IMSM_DEVNAME_AS_SERIAL=1 |
7 | export IMSM_TEST_OROM=1 | |
8 | export IMSM_NO_PLATFORM=1 | |
9 | ||
97691508 AC |
10 | . tests/utils |
11 | set -ex | |
12 | verbose="yes" | |
13 | sleeptime=10 | |
14 | ||
15 | # if listfailed=yes then don't exit if test failed due to wrong | |
16 | # spare-migration and just print a list at the end. Other errors still | |
17 | # stop the test. | |
18 | # if listfailed=no then exit on first failure | |
19 | listfailed="yes" | |
20 | ||
21 | # start Monitor, set monitorpid | |
22 | # uses global scan variable | |
23 | # all parameters are numbers of devices to be monitored. only used when $scan="no" | |
24 | # eg. monitor 0 1 will start monitoring of containers c0, c1 and subarrays v0, v1 | |
25 | monitor(){ | |
26 | [ -z $monitorpid ] || return | |
27 | if [ "$scan" == "yes" ]; then | |
ed02d9cc | 28 | $mdadm -F -d 1 --scan --mail root@localhost -c $config & |
97691508 AC |
29 | monitorpid=$! |
30 | return | |
31 | fi | |
32 | unset mddevs | |
33 | while [ -n "$1" ] | |
34 | do | |
35 | eval container=\$c$1 | |
36 | eval volumes=\$v$1 | |
37 | mddevs="$mddevs /dev/$container" | |
38 | if [ "$container" != "$volumes" ]; then | |
39 | for vol in $volumes; do | |
40 | mddevs="$mddevs /dev/$vol" | |
41 | done | |
42 | fi | |
43 | shift | |
44 | done | |
45 | if [ -n "$mddevs" ]; then | |
46 | if [ "$verbose" != "yes" ]; then | |
ed02d9cc | 47 | $mdadm -F -d 1 $mddevs -c $config >&2 & |
97691508 AC |
48 | monitorpid=$! |
49 | else | |
ed02d9cc | 50 | $mdadm -F -t -d 1 $mddevs -c $config & |
97691508 AC |
51 | monitorpid=$! |
52 | fi | |
53 | fi | |
54 | [ "$verbose" != "yes" ] || echo $mddevs $monitorpid | |
55 | } | |
56 | ||
f6539edf CA |
57 | test0() |
58 | { | |
59 | dsc "Test 0: No config file, no spare should be moved" | |
ab65d723 | 60 | > $config |
f6539edf CA |
61 | setupdevs 0 0 1 $platform |
62 | setupdevs 1 3 4 $platform | |
63 | monitor 0 1 | |
64 | mdadm -a /dev/$c1 $dev2 | |
65 | mdadm --fail /dev/$v0 $dev0 | |
66 | # check that spare loop2 was not moved from container c1 to container c0 | |
67 | chksparemoved $c1 $c0 $dev2 n | |
68 | tidyup | |
69 | } | |
70 | ||
71 | test0a() | |
72 | { | |
73 | dsc "Test 0a: No domains in config file, no spare should be moved" | |
74 | setupdevs 0 0 1 $platform | |
75 | setupdevs 1 3 4 $platform | |
76 | createconfig a | |
77 | monitor 0 1 | |
78 | mdadm -a /dev/$c1 $dev2 | |
79 | mdadm --fail /dev/$v0 $dev0 | |
80 | # check that spare loop2 was not moved from container c1 to container c0 | |
81 | chksparemoved $c1 $c0 $dev2 n | |
82 | tidyup | |
83 | } | |
84 | ||
97691508 AC |
85 | test1() |
86 | { | |
87 | dsc "Test 1: Common domain, add disk to one container and fail first one in another container, spare should be moved" | |
88 | setupdevs 0 0 1 $platform | |
89 | setupdevs 1 3 4 $platform | |
90 | # create config file with arrays and common domain | |
91 | createconfig a | |
92 | createconfig domain-$platform $platform spare 0 1 2 3 4 | |
93 | monitor 0 1 | |
94 | mdadm -a /dev/$c1 $dev2 | |
95 | mdadm --fail /dev/$v0 $dev0 | |
96 | # check that spare loop2 was moved from container c1 to container c0 | |
97 | chksparemoved $c1 $c0 $dev2 | |
98 | tidyup | |
99 | } | |
100 | ||
101 | test1a() | |
102 | { | |
103 | dsc "Test 1a: Common domain, add disk to one container and fail second one in another container, spare should be moved" | |
104 | setupdevs 0 0 1 $platform | |
105 | setupdevs 1 3 4 $platform | |
106 | createconfig a | |
107 | createconfig domain-$platform $platform spare 0 1 2 3 4 | |
108 | monitor 0 1 | |
109 | mdadm -a /dev/$c1 $dev2 | |
110 | mdadm --fail /dev/$v0 $dev1 | |
111 | # check that spare loop2 was moved from container c1 to container c0 | |
112 | chksparemoved $c1 $c0 $dev2 | |
113 | tidyup | |
114 | } | |
115 | ||
116 | test2() | |
117 | { | |
118 | dsc "Test 2: Common domain, fail disk in one container and add one to another container, spare should be moved" | |
119 | setupdevs 0 0 1 $platform | |
120 | setupdevs 1 3 4 $platform | |
121 | createconfig a | |
122 | createconfig domain-$platform $platform spare 0 1 2 3 4 | |
123 | monitor 0 1 | |
124 | mdadm --fail /dev/$v0 $dev1 | |
125 | mdadm -a /dev/$c1 $dev2 | |
126 | chksparemoved $c1 $c0 $dev2 | |
127 | tidyup | |
128 | } | |
129 | ||
130 | test3() | |
131 | { | |
132 | dsc "Test 3: Two domains, fail a disk in one domain, add a disk to another domain, the spare should not be moved" | |
133 | setupdevs 0 0 1 $platform | |
134 | setupdevs 1 3 4 $platform | |
135 | # create config file with 2 domains | |
136 | createconfig a | |
137 | createconfig domain-$platform"1" $platform spare 0 1 2 | |
138 | createconfig domain-$platform"2" $platform spare 3 4 5 | |
139 | monitor 0 1 | |
140 | mdadm --fail /dev/$v0 $dev1 | |
141 | mdadm -a /dev/$c1 $dev5 | |
142 | chksparemoved $c1 $c0 $dev5 n | |
143 | tidyup | |
144 | } | |
145 | ||
146 | test4() | |
147 | { | |
f6539edf | 148 | dsc "Test 4: One domain holds one container, fail a disk in domain, and add disk to a container not described by domain, move if metadata allows" |
97691508 AC |
149 | setupdevs 0 0 1 $platform |
150 | setupdevs 1 3 4 $platform | |
151 | createconfig a | |
152 | createconfig domain-$platform $platform spare 0 1 2 | |
153 | monitor 0 1 | |
154 | mdadm --fail /dev/$v0 $dev1 | |
155 | mdadm -a /dev/$c1 $dev5 | |
f6539edf CA |
156 | unset shouldmove |
157 | [ "$platform" == "imsm" ] || shouldmove="n" | |
158 | chksparemoved $c1 $c0 $dev5 $shouldmove | |
97691508 AC |
159 | tidyup |
160 | } | |
161 | ||
162 | test5() | |
163 | { | |
164 | dsc "Test 5: Two domains, two containers in each domain" | |
165 | setupdevs 0 0 1 $platform | |
166 | setupdevs 1 3 4 $platform | |
167 | setupdevs 2 5 6 $platform | |
76ae4820 | 168 | setupdevs 3 8 10 $platform |
97691508 AC |
169 | # 2 and 9 for spares |
170 | createconfig a | |
171 | createconfig domain-$platform"1" $platform spare 0 1 2 3 4 | |
76ae4820 | 172 | createconfig domain-$platform"2" $platform spare 5 6 8 9 10 |
97691508 AC |
173 | monitor 0 1 2 3 |
174 | test5a | |
175 | test5b | |
176 | test5c | |
177 | tidyup | |
178 | } | |
179 | ||
180 | test5a() | |
181 | { | |
182 | dsc "Test 5a: Two containers in each domain, add spare loop2 to domain1 and fail disk in the other domain, the spare should not be moved" | |
183 | mdadm -a /dev/$c0 $dev2 | |
184 | mdadm --fail /dev/$v2 $dev5 | |
185 | chksparemoved $c0 $c2 $dev2 n | |
186 | } | |
187 | ||
188 | test5b() | |
189 | { | |
190 | dsc "Test 5b: Fail disk in the same domain but different container, spare loop2 should be moved" | |
191 | mdadm --fail /dev/$v1 $dev3 | |
192 | chksparemoved $c0 $c1 $dev2 | |
193 | } | |
194 | ||
195 | test5c() | |
196 | { | |
197 | dsc "Test 5c: Add spare loop9 to different container in domain with degraded array, spare should be moved" | |
198 | mdadm -a /dev/$c3 $dev9 | |
199 | chksparemoved $c3 $c2 $dev9 | |
200 | } | |
201 | ||
202 | test6() | |
203 | { | |
204 | dsc "Test 6: One domain has two containers, fail a disk in one container, there is a spare in other container too small to use for rebuild" | |
205 | setupdevs 0 0 1 $platform | |
206 | setupdevs 1 8 9 $platform | |
207 | # all devices in one domain | |
208 | createconfig a | |
209 | createconfig domain-$platform $platform spare 0 1 2 8 9 | |
210 | monitor 0 1 | |
211 | mdadm -a /dev/$c0 $dev2 | |
212 | mdadm --fail /dev/$v1 $dev8 | |
213 | chksparemoved $c0 $c1 $dev2 n | |
214 | tidyup | |
215 | } | |
216 | ||
217 | test7() | |
218 | { | |
219 | dsc "Test 7: One domain, add small spare to container, fail disk in array, spare not used, add suitable spare to other container, spare should be moved" | |
220 | setupdevs 0 0 1 $platform | |
221 | setupdevs 1 8 9 $platform | |
222 | createconfig a | |
223 | createconfig domain-$platform $platform spare 0 1 2 8 9 10 | |
224 | monitor 0 1 | |
225 | mdadm -a /dev/$c1 $dev2 | |
226 | mdadm --fail /dev/$v1 $dev8 | |
227 | mdadm -a /dev/$c0 $dev10 | |
228 | chksparemoved $c0 $c1 $dev10 | |
229 | tidyup | |
230 | } | |
231 | ||
232 | ||
233 | test7a() | |
234 | { | |
235 | dsc "Test 7a: Small spare in parent, suitable one in other container, $dev2 in $c1 is not in common domain" | |
236 | setupdevs 0 0 1 $platform | |
237 | setupdevs 1 8 9 $platform | |
238 | #all $platform devices in one domain | |
239 | createconfig a | |
240 | createconfig domain-$platform"1" $platform spare 0 1 8 9 10 | |
241 | createconfig domain-$platform"2" $platform spare 2 | |
242 | monitor 0 1 | |
243 | mdadm -a /dev/$c1 $dev2 | |
244 | chkspare $c1 $dev2 | |
245 | mdadm --fail /dev/$v1 $dev8 | |
246 | mdadm -a /dev/$c0 $dev10 | |
247 | chksparemoved $c0 $c1 $dev10 | |
248 | tidyup | |
249 | } | |
250 | ||
251 | test8() | |
252 | { | |
253 | # ddf does not have getinfo_super_disks implemented so skip this test | |
254 | return | |
255 | dsc "Test 8: imsm and ddf - spare should not be migrated" | |
256 | setupdevs 0 10 11 imsm | |
257 | setupdevs 1 8 9 ddf | |
258 | createconfig a | |
259 | createconfig domain0 noplatform spare 8 9 10 11 12 | |
260 | monitor 0 1 | |
261 | mdadm -a /dev/$c1 $dev12 | |
262 | mdadm --fail /dev/$v0 $dev10 | |
263 | chksparemoved $c1 $c0 $dev12 n | |
264 | tidyup | |
265 | } | |
266 | ||
267 | test9() | |
268 | { | |
f6539edf | 269 | dsc "Test 9: imsm and native 1.2 - one domain, no metadata specified, spare should be moved" |
97691508 AC |
270 | setupdevs 0 10 11 imsm |
271 | setupdevs 1 8 9 1.2 | |
272 | createconfig a | |
273 | createconfig domain0 noplatform spare 8 9 10 11 12 | |
274 | monitor 0 1 | |
275 | mdadm -a /dev/$c1 $dev12 | |
276 | mdadm --fail /dev/$v0 $dev10 | |
c7cb3413 | 277 | chksparemoved $c1 $c0 $dev12 |
97691508 AC |
278 | tidyup |
279 | } | |
280 | ||
f6539edf CA |
281 | test9a() |
282 | { | |
283 | dsc "Test 9a: imsm and native 1.2 - spare in global domain, should be moved" | |
284 | setupdevs 0 10 11 imsm | |
285 | setupdevs 1 8 9 1.2 | |
286 | createconfig a | |
287 | createconfig domain-global noplatform spare 8 9 10 11 12 | |
288 | createconfig domain-1.2 1.2 spare 8 9 | |
289 | createconfig domain-imsm imsm spare 10 11 | |
290 | monitor 0 1 | |
291 | mdadm -a /dev/$c1 $dev12 | |
292 | mdadm --fail /dev/$v0 $dev10 | |
293 | chksparemoved $c1 $c0 $dev12 | |
294 | tidyup | |
295 | } | |
296 | ||
97691508 AC |
297 | test10() |
298 | { | |
299 | dsc "Test 10: Two arrays on the same devices in container" | |
300 | setupdevs 0 0 1 $platform 10000 | |
301 | setupdevs 1 3 4 $platform | |
302 | createconfig a | |
303 | createconfig domain-$platform $platform spare 0 1 2 3 4 5 | |
304 | monitor 0 1 | |
305 | mdadm -a /dev/$c1 $dev2 | |
306 | mdadm --fail /dev/md/sub0_ $dev0 | |
307 | chksparemoved $c1 $c0 $dev2 | |
308 | if [ $failed -eq 0 ]; then | |
309 | # now fail the spare and see if we get another one | |
310 | mdadm --fail /dev/md/sub0_ $dev2 | |
311 | mdadm -a /dev/$c1 $dev5 | |
312 | chksparemoved $c1 $c0 $dev5 | |
313 | fi | |
314 | tidyup | |
315 | } | |
316 | ||
317 | test11() | |
318 | { | |
319 | dsc "Test 11: Failed spare from other container should not be used" | |
320 | setupdevs 0 0 1 $platform | |
321 | setupdevs 1 3 4 $platform | |
322 | createconfig a | |
323 | createconfig domain-$platform $platform spare 0 1 2 3 4 | |
324 | monitor 0 1 | |
325 | mdadm -a /dev/$c1 $dev2 | |
326 | mdadm --fail /dev/$v1 $dev3 | |
327 | #wait until recovery finishes so no degraded array in c1 | |
328 | check wait | |
329 | mdadm --fail /dev/$v0 $dev0 | |
330 | chksparemoved $c1 $c0 $dev3 n | |
331 | tidyup | |
332 | } | |
333 | ||
334 | test12() | |
335 | { | |
336 | dsc "Test 12: Only one spare should be taken for rebuild, second not needed" | |
337 | setupdevs 0 0 1 $platform | |
338 | setupdevs 1 3 4 $platform | |
339 | createconfig a | |
340 | createconfig domain-$platform $platform spare 0 1 2 3 4 5 | |
341 | monitor 0 1 | |
342 | mdadm -a /dev/$c1 $dev2 | |
343 | mdadm -a /dev/$c1 $dev5 | |
344 | mdadm --fail /dev/$v0 $dev0 | |
345 | sleep $sleeptime | |
346 | chkarray $dev2 n | |
347 | sc1=$c | |
348 | chkarray $dev5 n | |
349 | sc2=$c | |
350 | [ "$sc1" != "$sc2" ] || err "both spares in the same container $sc1" | |
351 | tidyup | |
352 | } | |
353 | ||
354 | test13() | |
355 | { | |
c7cb3413 | 356 | dsc "Test 13: Common domain, two containers, fail a disk in container, action is below spare, the spare should be moved regadless of action" |
97691508 AC |
357 | setupdevs 0 0 1 $platform |
358 | setupdevs 1 4 5 $platform | |
359 | # same domain but different action on 4 5 6 | |
360 | createconfig a | |
361 | createconfig domain-$platform $platform spare 0 1 | |
362 | createconfig domain-$platform $platform include 4 5 6 | |
363 | monitor 0 1 | |
364 | mdadm -a /dev/$c1 $dev6 | |
365 | mdadm --fail /dev/$v0 $dev0 | |
c7cb3413 | 366 | chksparemoved $c1 $c0 $d6 |
97691508 AC |
367 | tidyup |
368 | } | |
369 | ||
370 | test14() | |
371 | { | |
372 | dsc "Test 14: One domain, small array on big disks, check if small spare is accepted" | |
373 | setupdevs 0 8 9 $platform 10000 1 | |
374 | setupdevs 1 0 1 $platform | |
375 | createconfig a | |
376 | createconfig domain-$platform $platform spare 0 1 2 8 9 | |
377 | monitor 0 1 | |
378 | mdadm -a /dev/$c1 $dev2 | |
379 | mdadm --fail /dev/$v0 $dev9 | |
380 | chksparemoved $c1 $c0 $d2 | |
381 | tidyup | |
382 | } | |
383 | ||
f6539edf CA |
384 | test15() |
385 | { | |
386 | dsc "Test 15: spare in global domain for $platform metadata, should be moved" | |
387 | # this is like 9a but only one metadata used | |
388 | setupdevs 0 10 11 $platform | |
389 | setupdevs 1 8 9 $platform | |
390 | createconfig a | |
391 | createconfig domain-global $platform spare 8 9 10 11 12 | |
392 | createconfig domain-1 $platform spare 8 9 | |
393 | createconfig domain-2 $platform spare 10 11 | |
394 | monitor 0 1 | |
395 | mdadm -a /dev/$c1 $dev12 | |
396 | mdadm --fail /dev/$v0 $dev10 | |
397 | chksparemoved $c1 $c0 $dev12 | |
398 | tidyup | |
399 | } | |
400 | ||
97691508 AC |
401 | try() |
402 | { | |
f6539edf CA |
403 | test0 |
404 | test0a | |
97691508 AC |
405 | test1 |
406 | test1a | |
407 | test2 | |
408 | test3 | |
409 | test4 | |
410 | test5 | |
411 | test6 | |
412 | if [ "$platform" != "1.2" ]; then | |
413 | # this is because we can't have a small spare added to native array | |
414 | test7 | |
415 | test7a | |
416 | fi | |
417 | test8 | |
418 | test9 | |
f6539edf | 419 | test9a |
97691508 AC |
420 | if [ "$platform" != "1.2" ]; then |
421 | # we can't create two subarrays on the same devices for native (without | |
422 | # partitions) | |
423 | test10 | |
424 | fi | |
425 | test11 | |
426 | test12 | |
427 | test13 | |
428 | test14 | |
f6539edf | 429 | test15 |
97691508 AC |
430 | } |
431 | ||
432 | try_failed() | |
433 | { | |
434 | platform="1.2" | |
435 | scan="no" | |
436 | test5 | |
437 | test9 | |
438 | test13 | |
439 | scan="yes" | |
440 | test9 | |
441 | } | |
442 | ||
443 | #try_failed | |
444 | ||
445 | for scan in no yes; do | |
446 | for platform in 1.2 imsm; do | |
447 | try | |
448 | done | |
449 | done | |
450 | ||
451 | [ $listfailed == "no" ] || [ -z $flist ] || echo -e "\n FAILED TESTS: $flist" | |
452 | ||
453 | #cat $targetdir/log | |
454 | rm -f /dev/disk/by-path/loop* |