# 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"
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
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"
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
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
}
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
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
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"
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
fi
test8
test9
+test9a
if [ "$platform" != "1.2" ]; then
# we can't create two subarrays on the same devices for native (without
# partitions)
test12
test13
test14
+test15
}
try_failed()