mdadm/test: Update for mdadm test part
cover mdadm/test: Update for mdadm test part
1. add a new unit case for testing readonly/readwrite feature, it covers common metadata versions and raid levels.
2. fixed a issue reported by Xiao Ni, shell got parsing error when array[] has few members, so just check the array[0] is enough.
3. get rid of the useless test files.
Thanks,
Zhilong
Zhilong Liu (4):
test/00readonly: Add unit case for testing readonly/readwrite mdadm/test: Fixed the condition parsing error for array[] mdadm/test: Get rid of tests/testdev
mdadm/test: Get rid of tests/check
test | 2 +- tests/00readonly | 20 ++++++++++++++++++++ tests/check | 35 ----------------------------------- tests/testdev | 13 ------------- 4 files changed, 21 insertions(+), 49 deletions(-) create mode 100644 tests/00readonly delete mode 100644 tests/check delete mode 100644 tests/testdev
Signature · 1 line
1.8.3.1
PATCH 1/4 test/00readonly: Add unit case for testing readonly/readwrite
This is a test case for testing --readonly and
--readwrite feature, it covers common metadata
versions and raid levels.
--- tests/00readonly | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/00readonly
tests/00readonly new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/bash + +for metadata in 0.9 1.0 1.1 1.2 +do + for level in linear raid0 raid1 raid4 raid5 raid6 raid10 + do + mdadm -CR $md0 -l $level -n 4 --metadata=$metadata \ + $dev1 $dev2 $dev3 $dev4 --assume-clean + check nosync + check $level + mdadm -ro $md0 + check readonly && + [ "$(cat /sys/block/md0/md/array_state)" == "readonly" ] + mdadm -w $md0 + check $level + mdadm -S $md0 + done +done + +exit 0
Signature · 1 line
1.8.3.1
PATCH 2/4 mdadm/test: Fixed the condition parsing error for array[]
In reply to Zhilong Liuit complains too many arguments when array[] has few members, it's proper to check whether or not array[0] is zero.
--- test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test +1 -1
@@ -75,7 +75,7 @@ save_log() { echo elif [ "$DEVTYPE" == 'loop' -o "$DEVTYPE" == 'disk' ] then - if [ ! -z ${array[@]} -a ${#array[@]} -ge 1 ] + if [ ! -z "$array" -a ${#array[@]} -ge 1 ] then md_disks=($($mdadm -D -Y ${array[@]} | grep "/dev/" | cut -d'=' -f2)) cat /proc/mdstat | grep -q "bitmap"
Signature · 1 line
1.8.3.1
PATCH 3/4 mdadm/test: Get rid of tests/testdev
In reply to Zhilong LiuIt's time to get rid of the tests/testdev due
to it has covered by testdev() in 'test'.
--- tests/testdev | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 tests/testdev
tests/testdev deleted +0 -13
@@ -1,13 +0,0 @@ -dev=$1 -cnt=$2 -size=$3 -chunk=$4 -mkfs -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2 -dsize=$[size/chunk] -dsize=$[dsize*chunk] -rasize=$[dsize*2*cnt] -if [ $rasize -ne `/sbin/blockdev --getsize $dev` ] -then - echo "ERROR: size is wrong for $dev: $cnt * $size (chunk=$chunk) = $rasize, not `/sbin/blockdev --getsize $dev`" - exit 1; -fi
Signature · 1 line
1.8.3.1
PATCH 4/4 mdadm/test: Get rid of tests/check
In reply to Zhilong LiuThe tests/check is not useful due to check()
in 'test' has covered various checking.
--- tests/check | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 tests/check
tests/check deleted +0 -35
@@ -1,35 +0,0 @@ - -case $1 in - raid* | linear ) - grep -s "active $1 " /proc/mdstat > /dev/null || { - echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;} - ;; - resync | recovery ) - sleep 0.1 - grep -s $1 /proc/mdstat > /dev/null || { - echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1; } - ;; - - nosync ) - sleep 0.5 - grep -s 're[synccovery]* =' > /dev/null /proc/mdstat && { - echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1; } - ;; - - wait ) - sleep 0.1 - while grep 're[synccovery]* =' > /dev/null /proc/mdstat - do sleep 2; - done - ;; - - state ) - grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || { - echo >&2 "ERROR state $2 not found!"; cat /proc/mdstat ; exit 1; } - sleep 0.5 - ;; - - * ) echo >&2 ERROR unknown check $1 ; exit 1; -esac - -exit 0
Signature · 1 line
1.8.3.1
PATCH v2 1/4 test/00readonly: Add unit case for testing readonly/readwrite
In reply to Zhilong LiuThis is a test case for testing --readonly and
--readwrite feature, it covers common metadata
versions and raid levels.
---
Changing from v1:
improve checking sysfs configure.
tests/00readonly | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/00readonly
tests/00readonly new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/bash + +for metadata in 0.9 1.0 1.1 1.2 +do + for level in linear raid0 raid1 raid4 raid5 raid6 raid10 + do + mdadm -CR $md0 -l $level -n 4 --metadata=$metadata \ + $dev1 $dev2 $dev3 $dev4 --assume-clean + check nosync + check $level + mdadm -ro $md0 + check readonly + state=$(cat /sys/block/md0/md/array_state) + [ "$state" == "readonly" ] || + die "array_state should be 'readonly', but is $state" + mdadm -w $md0 + check $level + mdadm -S $md0 + done +done + +exit 0
Signature · 1 line
2.6.6