]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - tests/11spare-migration
config: new option to suppress adding bad block lists.
[thirdparty/mdadm.git] / tests / 11spare-migration
index 01693e4b75e157e575e29f20192c5772562f373c..24b6ec693533e868238a65158a741b1d1ad654cf 100644 (file)
@@ -3,6 +3,10 @@
 # above number 7 bigger again by any amount (this is not changed for now as it
 # could affect other tests)
 
+export IMSM_DEVNAME_AS_SERIAL=1
+export IMSM_TEST_OROM=1
+export IMSM_NO_PLATFORM=1
+
 . tests/utils
 set -ex
 verbose="yes"
@@ -21,7 +25,7 @@ listfailed="yes"
 monitor(){
        [ -z $monitorpid ] || return
        if [ "$scan" == "yes" ]; then
-               $mdadm -F -d 1 --scan --mail root@localhost &
+               $mdadm -F -d 1 --scan --mail root@localhost -c $config &
                monitorpid=$!
                return
        fi
@@ -40,16 +44,44 @@ monitor(){
        done
        if [ -n "$mddevs" ]; then
                if [ "$verbose" != "yes" ]; then
-                       $mdadm -F -d 1 $mddevs >&2 &
+                       $mdadm -F -d 1 $mddevs -c $config >&2 &
                        monitorpid=$!
                else
-                       $mdadm -F -t -d 1 $mddevs &
+                       $mdadm -F -t -d 1 $mddevs -c $config &
                        monitorpid=$!
                fi
        fi
        [ "$verbose" != "yes" ] || echo $mddevs $monitorpid
 }
 
+test0()
+{
+dsc "Test 0: No config file, no spare should be moved"
+> $config
+setupdevs 0 0 1 $platform
+setupdevs 1 3 4 $platform
+monitor 0 1
+mdadm -a /dev/$c1 $dev2
+mdadm --fail /dev/$v0 $dev0
+# check that spare loop2 was not moved from container c1 to container c0
+chksparemoved $c1 $c0 $dev2 n
+tidyup
+}
+
+test0a()
+{
+dsc "Test 0a: No domains in config file, no spare should be moved"
+setupdevs 0 0 1 $platform
+setupdevs 1 3 4 $platform
+createconfig a
+monitor 0 1
+mdadm -a /dev/$c1 $dev2
+mdadm --fail /dev/$v0 $dev0
+# check that spare loop2 was not moved from container c1 to container c0
+chksparemoved $c1 $c0 $dev2 n
+tidyup
+}
+
 test1()
 {
 dsc "Test 1: Common domain, add disk to one container and fail first one in another container, spare should be moved"
@@ -113,7 +145,7 @@ tidyup
 
 test4()
 {
-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"
+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"
 setupdevs 0 0 1 $platform
 setupdevs 1 3 4 $platform
 createconfig a
@@ -121,7 +153,9 @@ createconfig domain-$platform $platform spare 0 1 2
 monitor 0 1
 mdadm --fail /dev/$v0 $dev1
 mdadm -a /dev/$c1 $dev5
-chksparemoved $c1 $c0 $dev5 n
+unset shouldmove
+[ "$platform" == "imsm" ] || shouldmove="n"
+chksparemoved $c1 $c0 $dev5 $shouldmove
 tidyup
 }
 
@@ -131,11 +165,11 @@ dsc "Test 5: Two domains, two containers in each domain"
 setupdevs 0 0 1 $platform
 setupdevs 1 3 4 $platform
 setupdevs 2 5 6 $platform
-setupdevs 3 7 8 $platform
+setupdevs 3 8 10 $platform
 # 2 and 9 for spares
 createconfig a
 createconfig domain-$platform"1" $platform spare 0 1 2 3 4
-createconfig domain-$platform"2" $platform spare 5 6 7 8 9
+createconfig domain-$platform"2" $platform spare 5 6 8 9 10
 monitor 0 1 2 3
 test5a
 test5b
@@ -232,7 +266,7 @@ tidyup
 
 test9()
 {
-dsc "Test 9: imsm and native 1.2 - spare should be shared"
+dsc "Test 9: imsm and native 1.2 - one domain, no metadata specified, spare should be moved"
 setupdevs 0 10 11 imsm
 setupdevs 1 8 9 1.2
 createconfig a
@@ -244,6 +278,22 @@ chksparemoved $c1 $c0 $dev12
 tidyup
 }
 
+test9a()
+{
+dsc "Test 9a: imsm and native 1.2 - spare in global domain, should be moved"
+setupdevs 0 10 11 imsm
+setupdevs 1 8 9 1.2
+createconfig a
+createconfig domain-global noplatform spare 8 9 10 11 12
+createconfig domain-1.2 1.2 spare 8 9
+createconfig domain-imsm imsm spare 10 11
+monitor 0 1
+mdadm -a /dev/$c1 $dev12
+mdadm --fail /dev/$v0 $dev10
+chksparemoved $c1 $c0 $dev12
+tidyup
+}
+
 test10()
 {
 dsc "Test 10: Two arrays on the same devices in container"
@@ -331,8 +381,27 @@ chksparemoved $c1 $c0 $d2
 tidyup
 }
 
+test15()
+{
+dsc "Test 15: spare in global domain for $platform metadata, should be moved"
+# this is like 9a but only one metadata used
+setupdevs 0 10 11 $platform
+setupdevs 1 8 9 $platform
+createconfig a
+createconfig domain-global $platform spare 8 9 10 11 12
+createconfig domain-1 $platform spare 8 9
+createconfig domain-2 $platform spare 10 11
+monitor 0 1
+mdadm -a /dev/$c1 $dev12
+mdadm --fail /dev/$v0 $dev10
+chksparemoved $c1 $c0 $dev12
+tidyup
+}
+
 try()
 {
+test0
+test0a
 test1
 test1a
 test2
@@ -347,6 +416,7 @@ if [ "$platform" != "1.2" ]; then
 fi
 test8
 test9
+test9a
 if [ "$platform" != "1.2" ]; then
 # we can't create two subarrays on the same devices for native (without
 # partitions)
@@ -356,6 +426,7 @@ test11
 test12
 test13
 test14
+test15
 }
 
 try_failed()