diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-25 06:14:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-25 06:14:19 +0000 |
commit | 50f2ad8e92ef06e4dee6d7070049a96231d3a8ee (patch) | |
tree | b7cda9c5caad5948899bf7d6551262d9d7d86d09 /test | |
parent | Adding upstream version 4.3+20240412. (diff) | |
download | mdadm-50f2ad8e92ef06e4dee6d7070049a96231d3a8ee.tar.xz mdadm-50f2ad8e92ef06e4dee6d7070049a96231d3a8ee.zip |
Adding upstream version 4.3+20240723.upstream/4.3+20240723
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
35 files changed, 285 insertions, 449 deletions
@@ -6,8 +6,21 @@ targetdir="/var/tmp" logdir="$targetdir" config=/tmp/mdadm.conf testdir=$PWD/tests -system_speed_limit=`cat /proc/sys/dev/raid/speed_limit_max` +system_speed_limit_max=0 +system_speed_limit_min=0 +test_speed_limit_min=100 +test_speed_limit_max=500 devlist= +# If super1 metadata name doesn't have the same hostname with machine, +# it's treated as foreign. +# For example, /dev/md0 is created, stops it, then assemble it, the +# device node will be /dev/md127 (127 is choosed by mdadm autumatically) +is_foreign="no" +#disable selinux +sys_selinux="Permissive" + +skipping_linear="no" +skipping_multipath="no" savelogs=0 exitonerror=1 @@ -25,6 +38,11 @@ LVM_VOLGROUP=mdtest md0=/dev/md0 md1=/dev/md1 md2=/dev/md2 +# if user doesn't specify minor number, mdadm chooses minor number +# automatically from 127. +md127=/dev/md127 +md126=/dev/md126 +md125=/dev/md125 mdp0=/dev/md_d0 mdp1=/dev/md_d1 @@ -39,10 +57,6 @@ ctrl_c() { ctrl_c_error=1 } -restore_system_speed_limit() { - echo $system_speed_limit > /proc/sys/dev/raid/speed_limit_max -} - mdadm() { rm -f $targetdir/stderr case $* in @@ -103,16 +117,17 @@ do_test() { do_clean # source script in a subshell, so it has access to our # namespace, but cannot change it. + control_system_speed_limit echo -ne "$_script... " if ( set -ex ; . $_script ) &> $targetdir/log then if [ -f "${_script}.inject_error" ]; then echo "dmesg checking is skipped because test inject error" else - dmesg | grep -iq "error\|call trace\|segfault" && + dmesg | grep -iq "error\|call trace\|segfault" | grep -v "systemd" && die "dmesg prints errors when testing $_basename!" fi - echo "succeeded" + succeed "succeeded\n" _fail=0 else save_log fail @@ -300,10 +315,8 @@ parse_args() { } print_warning() { - cat <<-EOF - Warning! Tests are performed on system level mdadm! - If you want to test local build, you need to install it first! - EOF + warn "Warning! Tests are performed on system level mdadm!\n" + echo "If you want to test local build, you need to install it first!" } main() { @@ -338,6 +351,7 @@ main() { fi done + restore_selinux exit 0 } diff --git a/tests/01r5fail b/tests/01r5fail index 873dba5..c210d6e 100644 --- a/tests/01r5fail +++ b/tests/01r5fail @@ -17,11 +17,7 @@ check wait mdadm $md0 --fail $dev0 mdadm $md0 --remove $dev3 $dev0 check recovery -check state _UUU - -mdadm $md0 -a $dev3 -check recovery check wait check state UUUU -mdadm -S $md0
\ No newline at end of file +mdadm -S $md0 diff --git a/tests/01r5integ.broken b/tests/01r5integ.broken deleted file mode 100644 index 2073763..0000000 --- a/tests/01r5integ.broken +++ /dev/null @@ -1,7 +0,0 @@ -fails rarely - -Fails about 1 in every 30 runs with a sha mismatch error: - - c49ab26e1b01def7874af9b8a6d6d0c29fdfafe6 /dev/md0 does not match - 15dc2f73262f811ada53c65e505ceec9cf025cb9 /dev/md0 with /dev/loop3 - missing diff --git a/tests/01raid6integ.broken b/tests/01raid6integ.broken deleted file mode 100644 index 1df735f..0000000 --- a/tests/01raid6integ.broken +++ /dev/null @@ -1,7 +0,0 @@ -fails infrequently - -Fails about 1 in 5 with a sha mismatch: - - 8286c2bc045ae2cfe9f8b7ae3a898fa25db6926f /dev/md0 does not match - a083a0738b58caab37fd568b91b177035ded37df /dev/md0 with /dev/loop2 and - /dev/loop3 missing diff --git a/tests/03assem-incr b/tests/03assem-incr index 38880a7..56afbf2 100644 --- a/tests/03assem-incr +++ b/tests/03assem-incr @@ -9,15 +9,23 @@ set -x -e levels=(raid0 raid1 raid5) if [ "$LINEAR" == "yes" ]; then - levels+=( linear ) + levels+=( linear ) fi +is_raid_foreign $md0 + for l in ${levels[@]} do - mdadm -CR $md0 -l $l -n5 $dev0 $dev1 $dev2 $dev3 $dev4 --assume-clean - mdadm -S md0 - mdadm -I $dev1 - mdadm -I $dev3 - mdadm -A /dev/md0 $dev0 $dev1 $dev2 $dev3 $dev4 - mdadm -S /dev/md0 + mdadm -CR $md0 -l $l -n5 $dev0 $dev1 $dev2 $dev3 $dev4 --assume-clean + mdadm -S $md0 + mdadm -I $dev1 + mdadm -I $dev3 + mdadm -A $md0 $dev0 $dev1 $dev2 $dev3 $dev4 + # If one array is foreign (metadata name doesn't have the machine's + # hostname), mdadm chooses a minor number automatically from 127 + if [ $is_foreign == "no" ]; then + mdadm -S $md0 + else + mdadm -S $md127 + fi done diff --git a/tests/03r0assem b/tests/03r0assem index f7c29e8..4bf8b9e 100644 --- a/tests/03r0assem +++ b/tests/03r0assem @@ -35,16 +35,6 @@ mdadm -S $md2 { echo DEVICE $devlist - echo array $md2 name=2 -} > $conf - -mdadm -As -c $conf $md2 -$tst -mdadm -S $md2 - - -{ - echo DEVICE $devlist echo array $md2 devices=$dev0,$dev1,$dev2 } > $conf diff --git a/tests/03r5assem-failed b/tests/03r5assem-failed deleted file mode 100644 index d38241d..0000000 --- a/tests/03r5assem-failed +++ /dev/null @@ -1,12 +0,0 @@ - -# Create an array, fail one device while array is active, stop array, -# then re-assemble listing the failed device first. - -mdadm -CR $md1 -l5 -n4 $dev0 $dev1 $dev2 $dev3 -check wait - -echo 2000 > /sys/block/md1/md/safe_mode_delay -mkfs $md1 -mdadm $md1 -f $dev0 -mdadm -S $md1 -mdadm -A $md1 $dev0 $dev1 $dev2 $dev3 || exit 1 diff --git a/tests/03r5assemV1 b/tests/03r5assemV1 index bca0c58..6026011 100644 --- a/tests/03r5assemV1 +++ b/tests/03r5assemV1 @@ -33,14 +33,6 @@ eval $tst { echo DEVICE $devlist - echo array $md1 name=one -} > $conf - -mdadm -As -c $conf -eval $tst - -{ - echo DEVICE $devlist echo array $md1 devices=$dev0,$dev1,$dev2,$dev3,$dev4 } > $conf @@ -90,15 +82,6 @@ eval $tst { echo DEVICE $devlist - echo array $md1 name=one -} > $conf - -mdadm -As -c $conf -check state U_U -eval $tst - -{ - echo DEVICE $devlist echo array $md1 devices=$dev0,$dev1,$dev2 } > $conf diff --git a/tests/04r5swap.broken b/tests/04r5swap.broken deleted file mode 100644 index e38987d..0000000 --- a/tests/04r5swap.broken +++ /dev/null @@ -1,7 +0,0 @@ -always fails - -Fails with errors: - - mdadm: /dev/loop0 has no superblock - assembly aborted - - ERROR: no recovery happening diff --git a/tests/04update-metadata b/tests/04update-metadata index 2b72a30..c748770 100644 --- a/tests/04update-metadata +++ b/tests/04update-metadata @@ -8,24 +8,29 @@ set -xe dlist="$dev0 $dev1 $dev2 $dev3" -for ls in linear/4 raid1/1 raid5/3 raid6/2 +if [ $skipping_linear == "yes" ]; then + level_list="raid1/1 raid5/3 raid6/2" +else + level_list="linear/4 raid1/1 raid5/3 raid6/2" +fi +for ls in $level_list do - s=${ls#*/} l=${ls%/*} - if [[ $l == 'raid1' ]]; then - mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 $dlist - else - mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist - fi - testdev $md0 $s 19904 64 - mdadm -S $md0 - mdadm -A $md0 --update=metadata $dlist - testdev $md0 $s 19904 64 check - mdadm -S $md0 + s=${ls#*/} l=${ls%/*} + if [[ $l == 'raid1' ]]; then + mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 $dlist + else + mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist + fi + testdev $md0 $s 19904 64 + mdadm -S $md0 + mdadm -A $md0 --update=metadata $dlist + testdev $md0 $s 19904 64 check + mdadm -S $md0 done if mdadm -A $md0 --update=metadata $dlist then echo >&2 should fail with v1.0 metadata - exit 1 + exit 1 fi mdadm -CR -e 0.90 $md0 --level=6 -n4 -c32 $dlist @@ -33,7 +38,7 @@ mdadm -S $md0 if mdadm -A $md0 --update=metadata $dlist then echo >&2 should fail during resync - exit 1 + exit 1 fi mdadm -A $md0 $dlist mdadm --wait $md0 || true @@ -48,5 +53,5 @@ mdadm -S $md0 if mdadm -A $md0 --update=metadata $dlist then echo >&2 should fail when bitmap present - exit 1 + exit 1 fi diff --git a/tests/04update-uuid b/tests/04update-uuid index a4409e7..25314ab 100644 --- a/tests/04update-uuid +++ b/tests/04update-uuid @@ -25,7 +25,7 @@ mdadm -S /dev/md0 # now if we have a bitmap, that needs updating too. rm -f $targetdir/bitmap -mdadm -CR --assume-clean -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 +yes | mdadm -CR --assume-clean -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 mdadm -S /dev/md0 mdadm -A /dev/md0 -b $targetdir/bitmap --update=uuid --uuid=0123456789abcdef:fedcba9876543210 $dev0 $dev1 $dev2 no_errors @@ -41,7 +41,7 @@ mdadm -S /dev/md0 # and bitmap for version1 rm -f $targetdir/bitmap -mdadm -CR --assume-clean -e1.1 -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 +yes | mdadm -CR --assume-clean -e1.1 -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 mdadm -S /dev/md0 mdadm -A /dev/md0 -b $targetdir/bitmap --update=uuid --uuid=0123456789abcdef:fedcba9876543210 $dev0 $dev1 $dev2 no_errors diff --git a/tests/05r1-bitmapfile b/tests/05r1-bitmapfile deleted file mode 100644 index f384f0e..0000000 --- a/tests/05r1-bitmapfile +++ /dev/null @@ -1,49 +0,0 @@ - -# -# create a raid1 with a bitmap file -# -bmf=$targetdir/bitmap -rm -f $bmf -mdadm --create --run $md0 --level=1 -n2 --delay=1 --bitmap $bmf $dev1 $dev2 -check wait -testdev $md0 1 $mdsize1a 64 -mdadm -S $md0 - -mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 -testdev $md0 1 $mdsize1a 64 -dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -sleep 4 -dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" - exit 1 -fi -mdadm $md0 -f $dev1 -testdev $md0 1 $mdsize1a 64 -sleep 4 -dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" - exit 2 -fi - -mdadm -S $md0 - -mdadm --assemble -R $md0 --bitmap=$bmf $dev2 -dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -mdadm --zero $dev1 # force --add, not --re-add -mdadm $md0 --add $dev1 -#it is too fast# check recovery - -check wait -sleep 4 -dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" - exit 1 -fi - -mdadm -S $md0 diff --git a/tests/05r1-grow-external b/tests/05r1-grow-external deleted file mode 100644 index 69da3e9..0000000 --- a/tests/05r1-grow-external +++ /dev/null @@ -1,33 +0,0 @@ - -# -# create a raid1 array, add an external bitmap -# -mdadm --create --run $md0 -l 1 -n 2 $dev1 $dev2 -check wait -testdev $md0 1 $mdsize1a 64 - -bmf=$targetdir/bm -rm -f $bmf -#mdadm -E $dev1 -mdadm --grow $md0 --bitmap=$bmf --delay=1 || { mdadm -X $bmf ; exit 1; } -dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -sleep 4 -dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -testdev $md0 1 $mdsize1a 64 -dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -sleep 4 -dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -#echo $dirty1 $dirty2 $dirty3 $dirty4 -if [ $dirty2 -ne 0 -o $dirty4 -ne 0 -o $dirty3 -lt 400 ] -then - echo bad dirty counts - exit 1 -fi - -# now to remove the bitmap -check bitmap -mdadm --grow $md0 --bitmap=none -check nobitmap -mdadm -S $md0 diff --git a/tests/05r1-grow-internal b/tests/05r1-grow-internal index 24b3aec..f7fff98 100644 --- a/tests/05r1-grow-internal +++ b/tests/05r1-grow-internal @@ -8,18 +8,15 @@ testdev $md0 1 $mdsize1a 64 #mdadm -E $dev1 mdadm --grow $md0 --bitmap=internal --bitmap-chunk=4 --delay=1 || { mdadm -X $dev2 ; exit 1; } -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` testdev $md0 1 $mdsize1a 64 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -#echo $dirty1 $dirty2 $dirty3 $dirty4 -if [ $dirty2 -ne 0 -o $dirty4 -ne 0 -o $dirty3 -lt 400 ] -then +if [ $dirty1 -ne 0 -o $dirty2 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: dirty1 $dirty1, dirty2 $dirty2" echo bad dirty counts exit 1 fi diff --git a/tests/05r1-grow-internal-1 b/tests/05r1-grow-internal-1 index 2f0d823..f0f8349 100644 --- a/tests/05r1-grow-internal-1 +++ b/tests/05r1-grow-internal-1 @@ -8,19 +8,15 @@ testdev $md0 1 $mdsize1b 64 #mdadm -E $dev1 mdadm --grow $md0 --bitmap=internal --bitmap-chunk=4 --delay=1 -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` testdev $md0 1 $mdsize1b 64 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -#echo $dirty1 $dirty2 $dirty3 $dirty4 -if [ $dirty2 -ne 0 -o $dirty4 -ne 0 -o $dirty3 -lt 400 ] -then - echo bad dirty counts +if [ $dirty1 -ne 0 -o $dirty2 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: dirty1 $dirty1, dirty2 $dirty2" exit 1 fi diff --git a/tests/05r1-internalbitmap b/tests/05r1-internalbitmap index dd7232a..f1a2843 100644 --- a/tests/05r1-internalbitmap +++ b/tests/05r1-internalbitmap @@ -9,21 +9,20 @@ mdadm -S $md0 mdadm --assemble $md0 $dev1 $dev2 testdev $md0 1 $mdsize0 64 -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" +if [ $dirty1 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty1" exit 1 fi mdadm $md0 -f $dev1 testdev $md0 1 $mdsize0 64 sleep 4 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" +total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +if [ $dirty2 -ne $total ] +then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" exit 2 fi @@ -34,13 +33,12 @@ mdadm --zero-superblock $dev1 mdadm $md0 --add $dev1 check recovery -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` check wait sleep 4 -dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" +if [ $dirty3 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty3" exit 1 fi diff --git a/tests/05r1-internalbitmap-v1a b/tests/05r1-internalbitmap-v1a index 3ddc082..cf3f397 100644 --- a/tests/05r1-internalbitmap-v1a +++ b/tests/05r1-internalbitmap-v1a @@ -10,21 +10,20 @@ mdadm -S $md0 mdadm --assemble $md0 $dev1 $dev2 testdev $md0 1 $mdsize1b 64 -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" +if [ $dirty1 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty1" exit 1 fi mdadm $md0 -f $dev1 testdev $md0 1 $mdsize1b 64 sleep 4 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" +total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +if [ $dirty2 -ne $total ] +then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" exit 2 fi @@ -35,13 +34,12 @@ mdadm --assemble -R $md0 $dev2 mdadm $md0 --add $dev1 check recovery -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` check wait sleep 4 -dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" +if [ $dirty3 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty3" exit 1 fi diff --git a/tests/05r1-internalbitmap-v1b b/tests/05r1-internalbitmap-v1b index 40f7abe..4952887 100644 --- a/tests/05r1-internalbitmap-v1b +++ b/tests/05r1-internalbitmap-v1b @@ -11,21 +11,20 @@ mdadm -S $md0 mdadm --assemble $md0 $dev1 $dev2 check bitmap testdev $md0 1 $mdsize11 64 -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" +if [ $dirty1 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty1" exit 1 fi mdadm $md0 -f $dev1 testdev $md0 1 $mdsize11 64 sleep 4 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" +total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +if [ $dirty2 -ne $total ] +then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" exit 2 fi @@ -35,14 +34,12 @@ mdadm --zero-superblock $dev1 mdadm --assemble -R $md0 $dev2 mdadm $md0 --add $dev1 check recovery - -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` check wait sleep 4 -dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" +if [ $dirty3 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty3" exit 1 fi diff --git a/tests/05r1-internalbitmap-v1c b/tests/05r1-internalbitmap-v1c index 2eaea59..e1e4472 100644 --- a/tests/05r1-internalbitmap-v1c +++ b/tests/05r1-internalbitmap-v1c @@ -10,21 +10,20 @@ mdadm -S $md0 mdadm --assemble $md0 $dev1 $dev2 testdev $md0 1 $mdsize12 64 -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" +if [ $dirty1 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty1" exit 1 fi mdadm $md0 -f $dev1 testdev $md0 1 $mdsize12 64 sleep 4 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" +total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +if [ $dirty2 -ne $total ] +then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" exit 2 fi @@ -35,13 +34,12 @@ mdadm --assemble -R $md0 $dev2 mdadm $md0 --add $dev1 check recovery -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` check wait sleep 4 -dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" +if [ $dirty3 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty3" exit 1 fi diff --git a/tests/05r1-n3-bitmapfile b/tests/05r1-n3-bitmapfile deleted file mode 100644 index f1c3f1e..0000000 --- a/tests/05r1-n3-bitmapfile +++ /dev/null @@ -1,53 +0,0 @@ - -# -# create a raid1 with 3 devices and a bitmap file -# make sure resync does right thing. -# -# -bmf=$targetdir/bitmap -rm -f $bmf -mdadm --create -e0.90 --run $md0 --level=1 -n3 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3 -check wait -testdev $md0 1 $mdsize0 64 -mdadm -S $md0 - -mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 -testdev $md0 1 $mdsize0 64 -dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -sleep 4 -dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" - exit 1 -fi -mdadm $md0 -f $dev2 -testdev $md0 1 $mdsize0 64 -sleep 4 -dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" - exit 2 -fi - -mdadm -S $md0 - -mdadm --assemble -R $md0 --bitmap=$bmf $dev1 $dev3 -check nosync -mdadm --zero-superblock $dev2 -mdadm $md0 --add $dev2 -check recovery - -dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -check wait -sleep 4 -dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" - exit 1 -fi - -mdadm -S $md0 -exit 0 diff --git a/tests/05r1-re-add-nosuper b/tests/05r1-re-add-nosuper index 058d602..7d41fd7 100644 --- a/tests/05r1-re-add-nosuper +++ b/tests/05r1-re-add-nosuper @@ -6,7 +6,7 @@ # bmf=$targetdir/bitmap2 rm -f $bmf -mdadm -B $md0 -l1 -n2 -b$bmf -d1 $dev1 $dev2 +yes | mdadm -B $md0 -l1 -n2 -b$bmf -d1 $dev1 $dev2 check resync check wait testdev $md0 1 $size 1 diff --git a/tests/05r5-bitmapfile b/tests/05r5-bitmapfile deleted file mode 100644 index 6d173d8..0000000 --- a/tests/05r5-bitmapfile +++ /dev/null @@ -1,49 +0,0 @@ - -# -# create a raid1 with a bitmap file -# -bmf=$targetdir/bitmap -rm -f $bmf -mdadm --create --run $md0 --level=5 -n3 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3 -check wait -testdev $md0 2 $mdsize1 512 -mdadm -S $md0 - -mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 -testdev $md0 2 $mdsize1 512 -dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -sleep 4 -dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" - exit 1 -fi -mdadm $md0 -f $dev1 -testdev $md0 2 $mdsize1 512 -sleep 4 -dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" - exit 2 -fi - -mdadm -S $md0 - -mdadm --assemble -R $md0 --bitmap=$bmf $dev2 $dev3 -mdadm --zero $dev1 # force add, not re-add -mdadm $md0 --add $dev1 -check recovery - -dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -check wait -sleep 4 -dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" - exit 1 -fi - -mdadm -S $md0 diff --git a/tests/05r5-internalbitmap b/tests/05r5-internalbitmap index 13dc592..1a64482 100644 --- a/tests/05r5-internalbitmap +++ b/tests/05r5-internalbitmap @@ -9,21 +9,20 @@ mdadm -S $md0 mdadm --assemble $md0 $dev1 $dev2 $dev3 testdev $md0 2 $mdsize1 512 -dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` sleep 4 -dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" +if [ $dirty1 -ne 0 ] +then echo >&2 "ERROR bad 'dirty' counts: $dirty1" exit 1 fi mdadm $md0 -f $dev1 testdev $md0 2 $mdsize1 512 sleep 4 -dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] +dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +if [ $dirty2 -lt 400 ] then - echo >&2 "ERROR dirty count $dirty3 is too small" + echo >&2 "ERROR dirty count $dirty2 is too small" exit 2 fi @@ -33,14 +32,12 @@ mdadm --assemble -R $md0 $dev2 $dev3 mdadm --zero $dev1 # force --add, not --re-add mdadm $md0 --add $dev1 check recovery - -dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` check wait sleep 4 -dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` +dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" +if [ $dirty3 -ne 0 ] +then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty3" exit 1 fi diff --git a/tests/05r6-bitmapfile b/tests/05r6-bitmapfile deleted file mode 100644 index d11896d..0000000 --- a/tests/05r6-bitmapfile +++ /dev/null @@ -1,49 +0,0 @@ - -# -# create a raid1 with a bitmap file -# -bmf=$targetdir/bitmap -rm -f $bmf -mdadm --create --run $md0 --level=6 -n4 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3 $dev4 -check wait -testdev $md0 2 $mdsize1 512 -mdadm -S $md0 - -mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 $dev4 -testdev $md0 2 $mdsize1 512 -dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -sleep 4 -dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] -then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" - exit 1 -fi -mdadm $md0 -f $dev3 -testdev $md0 2 $mdsize1 512 -sleep 4 -dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -if [ $dirty3 -lt 400 ] -then - echo >&2 "ERROR dirty count $dirty3 is too small" - exit 2 -fi - -mdadm -S $md0 - -mdadm --assemble -R $md0 --bitmap=$bmf $dev1 $dev2 $dev4 -mdadm --zero $dev3 # force --add, not --re-add -mdadm $md0 --add $dev3 -check recovery - -dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -check wait -sleep 4 -dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - -if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] -then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" - exit 1 -fi - -mdadm -S $md0 diff --git a/tests/06name b/tests/06name index 86eaab6..9ec3437 100644 --- a/tests/06name +++ b/tests/06name @@ -2,9 +2,17 @@ set -x # create an array with a name +is_raid_foreign $md0 + mdadm -CR $md0 -l0 -n2 --metadata=1 --name="Fred" $dev0 $dev1 -mdadm -E $dev0 | grep 'Name : Fred' > /dev/null || exit 1 -mdadm -D $md0 | grep 'Name : Fred' > /dev/null || exit 1 + +if [ $is_foreign == "no" ]; then + mdadm -E $dev0 | grep "Name : $(hostname):Fred" > /dev/null || exit 1 + mdadm -D $md0 | grep "Name : $(hostname):Fred" > /dev/null || exit 1 +else + mdadm -E $dev0 | grep "Name : Fred" > /dev/null || exit 1 + mdadm -D $md0 | grep "Name : Fred" > /dev/null || exit 1 +fi mdadm -S $md0 mdadm -A $md0 --name="Fred" $devlist diff --git a/tests/07autoassemble b/tests/07autoassemble index e689be7..b6630e1 100644 --- a/tests/07autoassemble +++ b/tests/07autoassemble @@ -2,6 +2,9 @@ # create two raid1s, build a raid0 on top, then # tear it down and get auto-assemble to rebuild it. +#the length of md0/md1/md2 is same. So use md0 here. +is_raid_foreign $md0 + mdadm -CR $md1 -l1 -n2 $dev0 $dev1 --homehost=testing mdadm -CR $md2 -l1 -n2 $dev2 $dev3 --homehost=testing mdadm -CR $md0 -l0 -n2 $md1 $md2 --homehost=testing @@ -10,7 +13,14 @@ mdadm -Ss mdadm -As -c /dev/null --homehost=testing -vvv testdev $md1 1 $mdsize1a 64 testdev $md2 1 $mdsize1a 64 -testdev $md0 2 $mdsize11a 512 +# md1 and md2 will be incremental assemble by udev rule. And +# the testing machines' hostname is not testing. The md0 will +# be considered as a foreign array. It can use 0 as metadata +# name. md127 will be used +testdev $md127 2 $mdsize11a 512 +mdadm --stop $md127 +mdadm --zero-superblock $md1 +mdadm --zero-superblock $md2 mdadm -Ss mdadm --zero-superblock $dev0 $dev1 $dev2 $dev3 @@ -20,5 +30,31 @@ mdadm -CR $md0 -l0 -n2 $md1 $dev2 --homehost=testing mdadm -Ss mdadm -As -c /dev/null --homehost=testing -vvv testdev $md1 1 $mdsize1a 64 -testdev $md0 1 $[mdsize1a+mdsize11a] 512 +testdev $md127 1 $[mdsize1a+mdsize11a] 512 +mdadm --stop $md127 +mdadm --zero-superblock $md1 +mdadm -Ss + +# Don't specify homehost when creating raid and use the test +# machine's homehost. For super1.2, if homehost name's length +# is > 32, it doesn't use homehost name in metadata name and +# the array will be treated as foreign array +mdadm --zero-superblock $dev0 $dev1 $dev2 $dev3 +mdadm -CR $md1 -l1 -n2 $dev0 $dev1 +mdadm -CR $md2 -l1 -n2 $dev2 $dev3 +mdadm -CR $md0 -l0 -n2 $md1 $md2 +mdadm -Ss +mdadm -As -c /dev/null +if [ $is_foreign == "yes" ]; then + # md127 is md1 + testdev $md127 1 $mdsize1a 64 + # md126 is md0, udev rule incremental assemble it + testdev $md126 2 $mdsize11a 512 + # md125 is md2 + testdev $md125 1 $mdsize1a 64 +else + testdev $md1 1 $mdsize1a 64 + testdev $md2 1 $mdsize1a 64 + testdev $md0 2 $mdsize11a 512 +fi mdadm -Ss diff --git a/tests/07autoassemble.broken b/tests/07autoassemble.broken deleted file mode 100644 index 8be0940..0000000 --- a/tests/07autoassemble.broken +++ /dev/null @@ -1,8 +0,0 @@ -always fails - -Prints lots of messages, but the array doesn't assemble. Error -possibly related to: - - mdadm: /dev/md/1 is busy - skipping - mdadm: no recogniseable superblock on /dev/md/testing:0 - mdadm: /dev/md/2 is busy - skipping diff --git a/tests/07autodetect.broken b/tests/07autodetect.broken deleted file mode 100644 index 294954a..0000000 --- a/tests/07autodetect.broken +++ /dev/null @@ -1,5 +0,0 @@ -always fails - -Fails with error: - - ERROR: no resync happening diff --git a/tests/07changelevelintr b/tests/07changelevelintr index 18c6309..d921f2b 100644 --- a/tests/07changelevelintr +++ b/tests/07changelevelintr @@ -27,11 +27,9 @@ checkgeo() { } restart() { - sleep 0.5 check reshape mdadm -S $md0 mdadm -A $md0 $devs --backup-file=$bu - sleep 0.5 check reshape } @@ -49,13 +47,16 @@ mdadm -G $md0 --layout rs --backup-file=$bu restart checkgeo md0 raid5 5 $[128*1024] 3 -mdadm -G $md0 --array-size 58368 +# It needs to shrink array size first. Choose a value that +# is power of 2 for array size. If not, it can't change +# chunk size. +mdadm -G $md0 --array-size 51200 mdadm -G $md0 --raid-disks 4 -c 64 --backup-file=$bu restart checkgeo md0 raid5 4 $[64*1024] 3 devs="$dev0 $dev1 $dev2 $dev3" -mdadm -G $md0 --array-size 19456 +mdadm -G $md0 --array-size 18432 mdadm -G $md0 -n 2 -c 256 --backup-file=$bu restart checkgeo md0 raid5 2 $[256*1024] 3 diff --git a/tests/07changelevelintr.broken b/tests/07changelevelintr.broken deleted file mode 100644 index 284b490..0000000 --- a/tests/07changelevelintr.broken +++ /dev/null @@ -1,9 +0,0 @@ -always fails - -Fails with errors: - - mdadm: this change will reduce the size of the array. - use --grow --array-size first to truncate array. - e.g. mdadm --grow /dev/md0 --array-size 56832 - - ERROR: no reshape happening diff --git a/tests/07revert-grow b/tests/07revert-grow index c8c4e85..333483d 100644 --- a/tests/07revert-grow +++ b/tests/07revert-grow @@ -43,7 +43,7 @@ testdev $md0 2 $mdsize1 512 mdadm -G $md0 -n 5 sleep 3 mdadm -S $md0 -strace -o /tmp/str ./mdadm -A $md0 --update=revert-reshape $devlist4 +mdadm -A $md0 --update=revert-reshape $devlist4 check wait check raid10 testdev $md0 2 $mdsize1 512 diff --git a/tests/07revert-inplace b/tests/07revert-inplace index a73eb97..776324a 100644 --- a/tests/07revert-inplace +++ b/tests/07revert-inplace @@ -37,7 +37,7 @@ testdev $md0 3 $mdsize1 64 mdadm -G $md0 -c 32 sleep 2 mdadm -S $md0 -strace -o /tmp/str ./mdadm -A $md0 --update=revert-reshape $devlist5 +mdadm -A $md0 --update=revert-reshape $devlist5 check wait check raid10 testdev $md0 3 $mdsize1 64 diff --git a/tests/23rdev-lifetime b/tests/23rdev-lifetime index 1750b0d..03b61de 100644 --- a/tests/23rdev-lifetime +++ b/tests/23rdev-lifetime @@ -4,7 +4,7 @@ pid="" runtime=2 clean_up_test() { - pill -9 $pid + kill -9 $pid echo clear > /sys/block/md0/md/array_state } diff --git a/tests/func.sh b/tests/func.sh index b474442..e7ccc4f 100644 --- a/tests/func.sh +++ b/tests/func.sh @@ -23,6 +23,28 @@ mdsize12=19988 # ddf needs bigger devices as 32Meg is reserved! ddfsize=65536 +# Systemd flags +devname_as_serial_flag="IMSM_DEVNAME_AS_SERIAL=1" +no_platform_flag="IMSM_NO_PLATFORM=1" + +# Common colors +COLOR_FAIL='\033[0;31m' #RED +COLOR_WARN='\033[1;33m' #YELLOW +COLOR_SUCCESS='\033[0;32m' #GREEN +COLOR_NONE='\033[0m' + +fail() { + printf "${COLOR_FAIL}$1${COLOR_NONE}" +} + +warn() { + printf "${COLOR_WARN}$1${COLOR_NONE}" +} + +succeed() { + printf "${COLOR_SUCCESS}$1${COLOR_NONE}" +} + # $1 is optional parameter, it shows why to save log save_log() { status=$1 @@ -36,7 +58,8 @@ save_log() { cat /proc/mdstat >> $logdir/$logfile array=($(mdadm -Ds | cut -d' ' -f2)) [ "$1" == "fail" ] && - echo "FAILED - see $logdir/$_basename.log and $logdir/$logfile for details" + fail "FAILED" + echo " - see $logdir/$_basename.log and $logdir/$logfile for details\n" if [ $DEVTYPE == 'lvm' ] then # not supported lvm type yet @@ -86,6 +109,7 @@ cleanup() { $mdadm --zero ${disks[@]} &> /dev/null ;; esac + clean_systemd_env } do_clean() @@ -125,6 +149,7 @@ check_env() { MULTIPATH="yes" if [ "$MULTIPATH" != "yes" ]; then echo "test: skipping tests for multipath, which is removed in upstream 6.8+ kernels" + skipping_multipath="yes" fi # Check whether to run linear tests @@ -133,14 +158,75 @@ check_env() { LINEAR="yes" if [ "$LINEAR" != "yes" ]; then echo "test: skipping tests for linear, which is removed in upstream 6.8+ kernels" + skipping_linear="yes" + fi +} + +record_system_speed_limit() { + system_speed_limit_max=`cat /proc/sys/dev/raid/speed_limit_max` + system_speed_limit_min=`cat /proc/sys/dev/raid/speed_limit_min` +} + +# To avoid sync action finishes before checking it, it needs to limit +# the sync speed +control_system_speed_limit() { + echo $test_speed_limit_min > /proc/sys/dev/raid/speed_limit_min + echo $test_speed_limit_max > /proc/sys/dev/raid/speed_limit_max +} + +restore_system_speed_limit() { + echo $system_speed_limit_min > /proc/sys/dev/raid/speed_limit_max + echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max +} + +is_raid_foreign() { + + name=$1 + # super1 uses this formula strlen(homehost)+1+strlen(name) < 32 + # to decide if an array is foreign or local. It adds homehost if + # one array is local + hostname=$(hostname) + if [ `expr length "$(hostname)$name"` -lt 31 ]; then + is_foreign="no" + else + is_foreign="yes" fi } +record_selinux() { + sys_selinux=`getenforce` + setenforce Permissive +} + +restore_selinux() { + setenforce $sys_selinux +} + +setup_systemd_env() { + warn "Warning! Test suite will set up systemd environment!\n" + echo "Use \"systemctl show-environment\" to show systemd environment variables" + for env_var in $devname_as_serial_flag $no_platform_flag + do + systemctl set-environment $env_var + echo "Added $env_var" to systemd environment, use \ + \"systemctl unset-environment $env_var\" to remove it. + done +} + +clean_systemd_env() { + for env_var in $devname_as_serial_flag $no_platform_flag + do + systemctl unset-environment $env_var + echo "Removed $env_var from systemd environment." + done +} + do_setup() { trap cleanup 0 1 3 15 trap ctrl_c 2 check_env + setup_systemd_env [ -d $logdir ] || mkdir -p $logdir devlist= @@ -214,6 +300,8 @@ do_setup() { ulimit -c unlimited [ -f /proc/mdstat ] || modprobe md_mod echo 0 > /sys/module/md_mod/parameters/start_ro + record_system_speed_limit + record_selinux } # check various things @@ -265,15 +353,17 @@ check() { fi ;; wait ) - p=`cat /proc/sys/dev/raid/speed_limit_max` - echo 2000000 > /proc/sys/dev/raid/speed_limit_max + min=`cat /proc/sys/dev/raid/speed_limit_min` + max=`cat /proc/sys/dev/raid/speed_limit_max` + echo 200000 > /proc/sys/dev/raid/speed_limit_max sleep 0.1 while grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat || grep -v idle > /dev/null /sys/block/md*/md/sync_action do sleep 0.5 done - echo $p > /proc/sys/dev/raid/speed_limit_max + echo $min > /proc/sys/dev/raid/speed_limit_min + echo $max > /proc/sys/dev/raid/speed_limit_max ;; state ) grep -sq "blocks.*\[$2\]\$" /proc/mdstat || diff --git a/tests/templates/names_template b/tests/templates/names_template index 1b6cd14..c94245e 100644 --- a/tests/templates/names_template +++ b/tests/templates/names_template @@ -4,6 +4,8 @@ function names_create() { local NAME=$2 local NEG_TEST=$3 + is_raid_foreign $DEVNAME + if [[ -z "$NAME" ]]; then mdadm -CR "$DEVNAME" -l0 -n 1 $dev0 --force else @@ -30,6 +32,7 @@ function names_verify() { local DEVNODE_NAME="$1" local WANTED_LINK="$2" local WANTED_NAME="$3" + local EXPECTED="" local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)" if [[ "$?" != "0" ]]; then @@ -38,7 +41,12 @@ function names_verify() { fi if [[ "$WANTED_LINK" != "empty" ]]; then - local EXPECTED="MD_DEVNAME=$WANTED_LINK" + EXPECTED="MD_DEVNAME=$WANTED_LINK" + + if [ ! -b /dev/md/$WANTED_LINK ]; then + echo "/dev/md/$WANTED_LINK doesn't exit" + exit 1 + fi fi if [[ "$RES" != "$EXPECTED" ]]; then @@ -52,7 +60,11 @@ function names_verify() { exit 1 fi - local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" + if [ $is_foreign == "no" ]; then + EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" + else + EXPECTED="MD_NAME=$WANTED_NAME" + fi if [[ "$RES" != "$EXPECTED" ]]; then echo "$RES doesn't match $EXPECTED." exit 1 |