* [PATCH blktests 1/9] blktests: add hepler functions for new md tests
@ 2018-06-06 8:06 bingjingc
2018-06-06 8:44 ` Johannes Thumshirn
0 siblings, 1 reply; 8+ messages in thread
From: bingjingc @ 2018-06-06 8:06 UTC (permalink / raw)
To: linux-block; +Cc: bingjingc, cccheng
We'd like to leverage this test framework for testing linux raid
software. There are several resync tasks in md/raid. For this commit,
we are trying to add creation resync and basic recovery tests for
every raid type.
RAID is different from other block devices. It requires several
raid devices and hotspare devices for being assembled, disambled,
expended or recovered in the runtime. So we don't test devices
iteratively in TEST_DEVS list. We define RAID_DEVS and
RAID_SPARE_DEVS lists for providing block devices instead.
We want to test the software not devices. We also provide a
LIMIT_DEV_SIZE option for limiting the tested array size by limiting
used space for each block device.
[Getting Started]
Additional dependencies are also minimal:
- mdadm
- cmp
And please provide a file named config:
RAID_DEVS=(/dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4)
RAID_SPARE_DEVS=(/dev/loop100 /dev/loop101)
LIMIT_DEV_SIZE=20480 # optional
And as root, you can run the md set of tests by typing
./check md
For someone who don't want to run md tests, they just keep RAID_DEVS
and RAID_SPARE_DEVS not assigned, all md tests will be skipped.
Reviewed-by: Chung-Chiang Cheng <cccheng@synology.com>
Signed-off-by: BingJing Chang <bingjingc@synology.com>
---
common/md | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/md/group | 24 +++++++
2 files changed, 222 insertions(+)
create mode 100644 common/md
create mode 100644 tests/md/group
diff --git a/common/md b/common/md
new file mode 100644
index 0000000..38c2554
--- /dev/null
+++ b/common/md
@@ -0,0 +1,198 @@
+#!/bin/bash
+#
+# Default helper functions for MD devices.
+#
+# Copyright (C) 2018 Synology Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+_check_md_devname_available() {
+ local dev="$1"
+
+ if [ -b "$dev" ]; then
+ SKIP_REASON="Detect that $1 exists. Stop it before this test."
+ return 1
+ fi
+
+ return 0;
+}
+
+_dev_is_available() {
+ local dev="$1"
+
+ if grep -qw "$dev" /proc/mounts; then
+ SKIP_REASON="Detect that $1 is mounted. (see mount)"
+ return 1
+ fi
+
+ dev=$(basename "$dev")
+ if grep -qw "$dev" /proc/mdstat; then
+ SKIP_REASON="Detect that $1 is used. (see cat /proc/mdstat)"
+ return 1
+ fi
+
+ return 0
+}
+
+_check_raid_devs_available() {
+ for dev in "${RAID_DEVS[@]}"
+ do
+ if ! _dev_is_available "$dev"; then
+ return 1
+ fi
+ done
+ return 0
+}
+
+_check_raid_spares_available() {
+ for spare in "${RAID_SPARE_DEVS[@]}"
+ do
+ if ! _dev_is_available "$spare"; then
+ return 1
+ fi
+ done
+ return 0
+}
+
+_have_spares() {
+ local size=${#RAID_SPARE_DEVS[@]}
+
+ if [ -z "$RAID_SPARE_DEVS" ] || [ "$size" -eq 0 ]; then
+ SKIP_REASON="There are no spare devices."
+ SKIP_REASON+=" (RAID_SPARE_DEVS=$RAID_SPARE_DEVS)"
+ return 1
+ fi
+ return 0
+}
+
+_meet_raid1_requirement() {
+ local size=${#RAID_DEVS[@]}
+
+ if ! grep -qw raid1 /proc/mdstat; then
+ SKIP_REASON="RAID1 is not available in /proc/mdstat."
+ return 1
+ fi
+
+ if [ "$size" -lt 2 ]; then
+ SKIP_REASON="RAID1 requires at least 2 devices."
+ SKIP_REASON+=" (RAID_DEVS=$RAID_DEVS)"
+ return 1
+ fi
+ return 0
+}
+
+_meet_raid10_requirement() {
+ local size=${#RAID_DEVS[@]}
+
+ if ! grep -qw raid10 /proc/mdstat; then
+ SKIP_REASON="RAID10 is not available in /proc/mdstat."
+ return 1
+ fi
+
+ if [ "$size" -lt 4 ]; then
+ SKIP_REASON="RAID10 requires at least 4 devices."
+ SKIP_REASON+=" (RAID_DEVS=$RAID_DEVS)"
+ return 1
+ fi
+ return 0
+}
+
+_meet_raid5_requirement() {
+ local size=${#RAID_DEVS[@]}
+
+ if ! grep -qw raid5 /proc/mdstat; then
+ SKIP_REASON="RAID5 is not available in /proc/mdstat."
+ return 1
+ fi
+
+ if [ "$size" -lt 3 ]; then
+ SKIP_REASON="RAID5 requires at least 3 devices."
+ SKIP_REASON+=" (RAID_DEVS=$RAID_DEVS)"
+ return 1
+ fi
+ return 0
+}
+
+_meet_raid6_requirement() {
+ local size=${#RAID_DEVS[@]}
+
+ if ! grep -qw raid6 /proc/mdstat; then
+ SKIP_REASON="RAID6 is not available in /proc/mdstat."
+ return 1
+ fi
+
+ if [ "$size" -lt 4 ]; then
+ SKIP_REASON="RAID6 requires at least 4 devices."
+ SKIP_REASON+=" (RAID_DEVS=$RAID_DEVS)"
+ return 1
+ fi
+ return 0
+}
+
+_start_sync_action() {
+ local dev="$1"
+ local sync_type="$2"
+
+ echo "$sync_type" > /sys/block/"$dev"/md/sync_action
+}
+
+_check_sync_action() {
+ local dev="$1"
+ local sync_type="$2"
+
+ if grep -qw "$sync_type" /sys/block/"$dev"/md/sync_action; then
+ return 0
+ fi
+
+ return 1
+}
+
+_check_last_sync_action() {
+ local dev="$1"
+ local sync_type="$2"
+
+ if grep -qw "$sync_type" /sys/block/"$dev"/md/last_sync_action; then
+ return 0
+ fi
+
+ return 1
+}
+
+_wait_action_completed() {
+ local dev="$1"
+ local sync_type="$2"
+
+ while ! _check_sync_action "$dev" idle || \
+ ! _check_last_sync_action "$dev" "$sync_type"
+ do
+ sleep 1
+ done
+}
+
+_wait_sync_completed() {
+ local dev="$1"
+ _wait_action_completed "$dev" resync
+}
+
+_wait_recovery_completed() {
+ local dev="$1"
+ _wait_action_completed "$dev" recovery
+}
+
+_check_integrity() {
+ local dev="$1"
+ _start_sync_action "$dev" check
+ _wait_action_completed "$dev" check
+}
diff --git a/tests/md/group b/tests/md/group
new file mode 100644
index 0000000..8f15aae
--- /dev/null
+++ b/tests/md/group
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# md raid tests
+#
+# Copyright (C) 2018 Synology Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. common/md
+
+group_requires() {
+ _have_root && [ -f /proc/mdstat ] && _have_program mdadm
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-06 8:06 [PATCH blktests 1/9] blktests: add hepler functions for new md tests bingjingc
@ 2018-06-06 8:44 ` Johannes Thumshirn
2018-06-06 14:29 ` Jens Axboe
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2018-06-06 8:44 UTC (permalink / raw)
To: bingjingc; +Cc: linux-block, cccheng, linux-raid
On Wed, Jun 06, 2018 at 04:06:40PM +0800, bingjingc wrote:
> We'd like to leverage this test framework for testing linux raid
> software. There are several resync tasks in md/raid. For this commit,
> we are trying to add creation resync and basic recovery tests for
> every raid type.
>
> RAID is different from other block devices. It requires several
> raid devices and hotspare devices for being assembled, disambled,
> expended or recovered in the runtime. So we don't test devices
> iteratively in TEST_DEVS list. We define RAID_DEVS and
> RAID_SPARE_DEVS lists for providing block devices instead.
>
> We want to test the software not devices. We also provide a
> LIMIT_DEV_SIZE option for limiting the tested array size by limiting
> used space for each block device.
>
> [Getting Started]
>
> Additional dependencies are also minimal:
> - mdadm
> - cmp
>
> And please provide a file named config:
> RAID_DEVS=(/dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4)
> RAID_SPARE_DEVS=(/dev/loop100 /dev/loop101)
> LIMIT_DEV_SIZE=20480 # optional
>
> And as root, you can run the md set of tests by typing
> ./check md
>
> For someone who don't want to run md tests, they just keep RAID_DEVS
> and RAID_SPARE_DEVS not assigned, all md tests will be skipped.
While I'm very much in support for the idea, please be aware that md
has an own test suite by itself and please Cc the md mailing list as
well.
Thanks,
Johannes
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-06 8:44 ` Johannes Thumshirn
@ 2018-06-06 14:29 ` Jens Axboe
2018-06-06 14:33 ` Johannes Thumshirn
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2018-06-06 14:29 UTC (permalink / raw)
To: Johannes Thumshirn, bingjingc; +Cc: linux-block, cccheng, linux-raid
On 6/6/18 2:44 AM, Johannes Thumshirn wrote:
> On Wed, Jun 06, 2018 at 04:06:40PM +0800, bingjingc wrote:
>> We'd like to leverage this test framework for testing linux raid
>> software. There are several resync tasks in md/raid. For this commit,
>> we are trying to add creation resync and basic recovery tests for
>> every raid type.
>>
>> RAID is different from other block devices. It requires several
>> raid devices and hotspare devices for being assembled, disambled,
>> expended or recovered in the runtime. So we don't test devices
>> iteratively in TEST_DEVS list. We define RAID_DEVS and
>> RAID_SPARE_DEVS lists for providing block devices instead.
>>
>> We want to test the software not devices. We also provide a
>> LIMIT_DEV_SIZE option for limiting the tested array size by limiting
>> used space for each block device.
>>
>> [Getting Started]
>>
>> Additional dependencies are also minimal:
>> - mdadm
>> - cmp
>>
>> And please provide a file named config:
>> RAID_DEVS=(/dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4)
>> RAID_SPARE_DEVS=(/dev/loop100 /dev/loop101)
>> LIMIT_DEV_SIZE=20480 # optional
>>
>> And as root, you can run the md set of tests by typing
>> ./check md
>>
>> For someone who don't want to run md tests, they just keep RAID_DEVS
>> and RAID_SPARE_DEVS not assigned, all md tests will be skipped.
>
> While I'm very much in support for the idea, please be aware that md
> has an own test suite by itself and please Cc the md mailing list as
> well.
Hopefully this can be the start of migrating over those tests!
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-06 14:29 ` Jens Axboe
@ 2018-06-06 14:33 ` Johannes Thumshirn
2018-06-07 2:45 ` bingjingc
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2018-06-06 14:33 UTC (permalink / raw)
To: Jens Axboe; +Cc: bingjingc, linux-block, cccheng, linux-raid
On Wed, Jun 06, 2018 at 08:29:25AM -0600, Jens Axboe wrote:
> Hopefully this can be the start of migrating over those tests!
Yes this would be great. I just wanted to connect the submitter and
the md developers and make them aware of possibly duplicated efforts
;-).
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-06 14:33 ` Johannes Thumshirn
@ 2018-06-07 2:45 ` bingjingc
2018-06-07 6:55 ` Johannes Thumshirn
2018-06-08 14:50 ` Wols Lists
0 siblings, 2 replies; 8+ messages in thread
From: bingjingc @ 2018-06-07 2:45 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Jens Axboe, linux-block, cccheng, linux-raid
Hi Johannes & Jens,
Thank you for your information and positive feedbacks on this patch.
I'm also inspired by xfstests, too. Most conventional filesystems
have their test cases on it. I believe block layer can also have one.
I felt sorry. It's first time I realized there is a test suite under
mdadm project. Now, I am trying to find documentation to get
it works. I can examine the efforts of migrating them or just
triggering them from blktests.
Any ideas from linux-block and linux-raid channels are welcome. :)
All the best,
BingJing
Johannes Thumshirn 於 2018-06-06 22:33 寫到:
> On Wed, Jun 06, 2018 at 08:29:25AM -0600, Jens Axboe wrote:
>> Hopefully this can be the start of migrating over those tests!
>
> Yes this would be great. I just wanted to connect the submitter and
> the md developers and make them aware of possibly duplicated efforts
> ;-).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-07 2:45 ` bingjingc
@ 2018-06-07 6:55 ` Johannes Thumshirn
2018-06-07 12:59 ` Jens Axboe
2018-06-08 14:50 ` Wols Lists
1 sibling, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2018-06-07 6:55 UTC (permalink / raw)
To: bingjingc; +Cc: Jens Axboe, linux-block, cccheng, linux-raid
On Thu, Jun 07, 2018 at 10:45:02AM +0800, bingjingc wrote:
> Hi Johannes & Jens,
>
> Thank you for your information and positive feedbacks on this patch.
>
> I'm also inspired by xfstests, too. Most conventional filesystems
> have their test cases on it. I believe block layer can also have one.
>
> I felt sorry. It's first time I realized there is a test suite under
> mdadm project. Now, I am trying to find documentation to get
> it works. I can examine the efforts of migrating them or just
> triggering them from blktests.
>
> Any ideas from linux-block and linux-raid channels are welcome. :)
Migrating them over would be the best thing since sliced bread. Having
to run only one test suite for the linux block device space is our
long term goal.
Thanks,
Johannes
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-07 6:55 ` Johannes Thumshirn
@ 2018-06-07 12:59 ` Jens Axboe
0 siblings, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2018-06-07 12:59 UTC (permalink / raw)
To: Johannes Thumshirn, bingjingc; +Cc: linux-block, cccheng, linux-raid
On 6/7/18 12:55 AM, Johannes Thumshirn wrote:
> On Thu, Jun 07, 2018 at 10:45:02AM +0800, bingjingc wrote:
>> Hi Johannes & Jens,
>>
>> Thank you for your information and positive feedbacks on this patch.
>>
>> I'm also inspired by xfstests, too. Most conventional filesystems
>> have their test cases on it. I believe block layer can also have one.
>>
>> I felt sorry. It's first time I realized there is a test suite under
>> mdadm project. Now, I am trying to find documentation to get
>> it works. I can examine the efforts of migrating them or just
>> triggering them from blktests.
>>
>> Any ideas from linux-block and linux-raid channels are welcome. :)
>
> Migrating them over would be the best thing since sliced bread. Having
> to run only one test suite for the linux block device space is our
> long term goal.
Fully agree. And don't feel bad about not knowing there's an md test
suite, I didn't either. Which is one of the reasons why having
everything under the blktests umbrella is so important.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH blktests 1/9] blktests: add hepler functions for new md tests
2018-06-07 2:45 ` bingjingc
2018-06-07 6:55 ` Johannes Thumshirn
@ 2018-06-08 14:50 ` Wols Lists
1 sibling, 0 replies; 8+ messages in thread
From: Wols Lists @ 2018-06-08 14:50 UTC (permalink / raw)
To: bingjingc, Johannes Thumshirn
Cc: Jens Axboe, linux-block, cccheng, linux-raid
On 07/06/18 03:45, bingjingc wrote:
> I felt sorry. It's first time I realized there is a test suite under
> mdadm project. Now, I am trying to find documentation to get
> it works. I can examine the efforts of migrating them or just
> triggering them from blktests.
>
> Any ideas from linux-block and linux-raid channels are welcome. :)
Take a look at the raid wiki.
https://raid.wiki.kernel.org/index.php/Linux_Raid
Not knowing anything about raid tests and stuff at the moment, I can't
add that to the wiki (hopefully I'll learn soon), but if there's
anything you think belongs on there, either add it yourself or draft it
and send it to me.
The wiki is currrently being actively edited (by me), but I'm always
wary of adding stuff I don't understand. So if you and the other test
maintainers could create a short page about the test suite, with
pointers to it, it would probably fit neatly under the "Kernel
Programming" section. Then hopefully more people will find out about it.
Cheers,
Wol
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-06-08 14:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06 8:06 [PATCH blktests 1/9] blktests: add hepler functions for new md tests bingjingc
2018-06-06 8:44 ` Johannes Thumshirn
2018-06-06 14:29 ` Jens Axboe
2018-06-06 14:33 ` Johannes Thumshirn
2018-06-07 2:45 ` bingjingc
2018-06-07 6:55 ` Johannes Thumshirn
2018-06-07 12:59 ` Jens Axboe
2018-06-08 14:50 ` Wols Lists
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox