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)
11 # if listfailed=yes then don't exit if test failed due to wrong
12 # spare-migration and just print a list at the end. Other errors still
14 # if listfailed=no then exit on first failure
17 # start Monitor, set monitorpid
18 # uses global scan variable
19 # all parameters are numbers of devices to be monitored. only used when $scan="no"
20 # eg. monitor 0 1 will start monitoring of containers c0, c1 and subarrays v0, v1
22 [ -z $monitorpid ] || return
23 if [ "$scan" == "yes" ]; then
24 $mdadm -F -d 1 --scan --mail root@localhost &
33 mddevs="$mddevs /dev/$container"
34 if [ "$container" != "$volumes" ]; then
35 for vol in $volumes; do
36 mddevs="$mddevs /dev/$vol"
41 if [ -n "$mddevs" ]; then
42 if [ "$verbose" != "yes" ]; then
43 $mdadm -F -d 1 $mddevs >&2 &
46 $mdadm -F -t -d 1 $mddevs &
50 [ "$verbose" != "yes" ] || echo $mddevs $monitorpid
55 dsc "Test 1: Common domain, add disk to one container and fail first one in another container, spare should be moved"
56 setupdevs 0 0 1 $platform
57 setupdevs 1 3 4 $platform
58 # create config file with arrays and common domain
60 createconfig domain-$platform $platform spare 0 1 2 3 4
62 mdadm -a /dev/$c1 $dev2
63 mdadm --fail /dev/$v0 $dev0
64 # check that spare loop2 was moved from container c1 to container c0
65 chksparemoved $c1 $c0 $dev2
71 dsc "Test 1a: Common domain, add disk to one container and fail second one in another container, spare should be moved"
72 setupdevs 0 0 1 $platform
73 setupdevs 1 3 4 $platform
75 createconfig domain-$platform $platform spare 0 1 2 3 4
77 mdadm -a /dev/$c1 $dev2
78 mdadm --fail /dev/$v0 $dev1
79 # check that spare loop2 was moved from container c1 to container c0
80 chksparemoved $c1 $c0 $dev2
86 dsc "Test 2: Common domain, fail disk in one container and add one to another container, spare should be moved"
87 setupdevs 0 0 1 $platform
88 setupdevs 1 3 4 $platform
90 createconfig domain-$platform $platform spare 0 1 2 3 4
92 mdadm --fail /dev/$v0 $dev1
93 mdadm -a /dev/$c1 $dev2
94 chksparemoved $c1 $c0 $dev2
100 dsc "Test 3: Two domains, fail a disk in one domain, add a disk to another domain, the spare should not be moved"
101 setupdevs 0 0 1 $platform
102 setupdevs 1 3 4 $platform
103 # create config file with 2 domains
105 createconfig domain-$platform"1" $platform spare 0 1 2
106 createconfig domain-$platform"2" $platform spare 3 4 5
108 mdadm --fail /dev/$v0 $dev1
109 mdadm -a /dev/$c1 $dev5
110 chksparemoved $c1 $c0 $dev5 n
116 dsc "Test 4: One domain holds one container, fail a disk in domain, and add disk to a container not described by domain, spare loop5 should not be moved"
117 setupdevs 0 0 1 $platform
118 setupdevs 1 3 4 $platform
120 createconfig domain-$platform $platform spare 0 1 2
122 mdadm --fail /dev/$v0 $dev1
123 mdadm -a /dev/$c1 $dev5
124 chksparemoved $c1 $c0 $dev5 n
130 dsc "Test 5: Two domains, two containers in each domain"
131 setupdevs 0 0 1 $platform
132 setupdevs 1 3 4 $platform
133 setupdevs 2 5 6 $platform
134 setupdevs 3 7 8 $platform
137 createconfig domain-$platform"1" $platform spare 0 1 2 3 4
138 createconfig domain-$platform"2" $platform spare 5 6 7 8 9
148 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"
149 mdadm -a /dev/$c0 $dev2
150 mdadm --fail /dev/$v2 $dev5
151 chksparemoved $c0 $c2 $dev2 n
156 dsc "Test 5b: Fail disk in the same domain but different container, spare loop2 should be moved"
157 mdadm --fail /dev/$v1 $dev3
158 chksparemoved $c0 $c1 $dev2
163 dsc "Test 5c: Add spare loop9 to different container in domain with degraded array, spare should be moved"
164 mdadm -a /dev/$c3 $dev9
165 chksparemoved $c3 $c2 $dev9
170 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"
171 setupdevs 0 0 1 $platform
172 setupdevs 1 8 9 $platform
173 # all devices in one domain
175 createconfig domain-$platform $platform spare 0 1 2 8 9
177 mdadm -a /dev/$c0 $dev2
178 mdadm --fail /dev/$v1 $dev8
179 chksparemoved $c0 $c1 $dev2 n
185 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"
186 setupdevs 0 0 1 $platform
187 setupdevs 1 8 9 $platform
189 createconfig domain-$platform $platform spare 0 1 2 8 9 10
191 mdadm -a /dev/$c1 $dev2
192 mdadm --fail /dev/$v1 $dev8
193 mdadm -a /dev/$c0 $dev10
194 chksparemoved $c0 $c1 $dev10
201 dsc "Test 7a: Small spare in parent, suitable one in other container, $dev2 in $c1 is not in common domain"
202 setupdevs 0 0 1 $platform
203 setupdevs 1 8 9 $platform
204 #all $platform devices in one domain
206 createconfig domain-$platform"1" $platform spare 0 1 8 9 10
207 createconfig domain-$platform"2" $platform spare 2
209 mdadm -a /dev/$c1 $dev2
211 mdadm --fail /dev/$v1 $dev8
212 mdadm -a /dev/$c0 $dev10
213 chksparemoved $c0 $c1 $dev10
219 # ddf does not have getinfo_super_disks implemented so skip this test
221 dsc "Test 8: imsm and ddf - spare should not be migrated"
222 setupdevs 0 10 11 imsm
225 createconfig domain0 noplatform spare 8 9 10 11 12
227 mdadm -a /dev/$c1 $dev12
228 mdadm --fail /dev/$v0 $dev10
229 chksparemoved $c1 $c0 $dev12 n
235 dsc "Test 9: imsm and native 1.2 - spare should not be shared"
236 setupdevs 0 10 11 imsm
239 createconfig domain0 noplatform spare 8 9 10 11 12
241 mdadm -a /dev/$c1 $dev12
242 mdadm --fail /dev/$v0 $dev10
243 chksparemoved $c1 $c0 $dev12 n
249 dsc "Test 10: Two arrays on the same devices in container"
250 setupdevs 0 0 1 $platform 10000
251 setupdevs 1 3 4 $platform
253 createconfig domain-$platform $platform spare 0 1 2 3 4 5
255 mdadm -a /dev/$c1 $dev2
256 mdadm --fail /dev/md/sub0_ $dev0
257 chksparemoved $c1 $c0 $dev2
258 if [ $failed -eq 0 ]; then
259 # now fail the spare and see if we get another one
260 mdadm --fail /dev/md/sub0_ $dev2
261 mdadm -a /dev/$c1 $dev5
262 chksparemoved $c1 $c0 $dev5
269 dsc "Test 11: Failed spare from other container should not be used"
270 setupdevs 0 0 1 $platform
271 setupdevs 1 3 4 $platform
273 createconfig domain-$platform $platform spare 0 1 2 3 4
275 mdadm -a /dev/$c1 $dev2
276 mdadm --fail /dev/$v1 $dev3
277 #wait until recovery finishes so no degraded array in c1
279 mdadm --fail /dev/$v0 $dev0
280 chksparemoved $c1 $c0 $dev3 n
286 dsc "Test 12: Only one spare should be taken for rebuild, second not needed"
287 setupdevs 0 0 1 $platform
288 setupdevs 1 3 4 $platform
290 createconfig domain-$platform $platform spare 0 1 2 3 4 5
292 mdadm -a /dev/$c1 $dev2
293 mdadm -a /dev/$c1 $dev5
294 mdadm --fail /dev/$v0 $dev0
300 [ "$sc1" != "$sc2" ] || err "both spares in the same container $sc1"
306 dsc "Test 13: Common domain, two containers, fail a disk in container, action is below spare, the spare should not be moved"
307 setupdevs 0 0 1 $platform
308 setupdevs 1 4 5 $platform
309 # same domain but different action on 4 5 6
311 createconfig domain-$platform $platform spare 0 1
312 createconfig domain-$platform $platform include 4 5 6
314 mdadm -a /dev/$c1 $dev6
315 mdadm --fail /dev/$v0 $dev0
316 chksparemoved $c1 $c0 $d6 n
322 dsc "Test 14: One domain, small array on big disks, check if small spare is accepted"
323 setupdevs 0 8 9 $platform 10000 1
324 setupdevs 1 0 1 $platform
326 createconfig domain-$platform $platform spare 0 1 2 8 9
328 mdadm -a /dev/$c1 $dev2
329 mdadm --fail /dev/$v0 $dev9
330 chksparemoved $c1 $c0 $d2
343 if [ "$platform" != "1.2" ]; then
344 # this is because we can't have a small spare added to native array
350 if [ "$platform" != "1.2" ]; then
351 # we can't create two subarrays on the same devices for native (without
374 for scan in no yes; do
375 for platform in 1.2 imsm; do
380 [ $listfailed == "no" ] || [ -z $flist ] || echo -e "\n FAILED TESTS: $flist"
383 rm -f /dev/disk/by-path/loop*