From: Xiao Ni <xni@redhat.com>
To: mariusz.tkaczyk@linux.intel.com
Cc: linux-raid@vger.kernel.org, heinzm@redhat.com, ncroxon@redhat.com
Subject: [PATCH 06/19] mdadm/tests: names_template enhance
Date: Wed, 22 May 2024 16:50:43 +0800 [thread overview]
Message-ID: <20240522085056.54818-7-xni@redhat.com> (raw)
In-Reply-To: <20240522085056.54818-1-xni@redhat.com>
For super1, if the length of hostname is >= 32, it doesn't add hostname
in metadata name. Fix this problem by checking the length of hostname.
Because other cases may use need to check this, so do the check in
do_setup.
And this patch adds a check if link /dev/md/name exists.
Signed-off-by: Xiao Ni <xni@redhat.com>
---
test | 5 +++++
tests/func.sh | 13 +++++++++++++
tests/templates/names_template | 14 ++++++++++++--
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/test b/test
index 3da53f871122..814ce1992b0c 100755
--- a/test
+++ b/test
@@ -11,6 +11,11 @@ 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"
savelogs=0
exitonerror=1
diff --git a/tests/func.sh b/tests/func.sh
index 221cff158f8c..cfe83e552a2a 100644
--- a/tests/func.sh
+++ b/tests/func.sh
@@ -153,6 +153,18 @@ restore_system_speed_limit() {
echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max
}
+is_raid_foreign() {
+
+ # If the length of hostname is >= 32, super1 doesn't use
+ # hostname in metadata
+ hostname=$(hostname)
+ if [ `expr length $(hostname)` -lt 32 ]; then
+ is_foreign="no"
+ else
+ is_foreign="yes"
+ fi
+}
+
do_setup() {
trap cleanup 0 1 3 15
trap ctrl_c 2
@@ -232,6 +244,7 @@ do_setup() {
[ -f /proc/mdstat ] || modprobe md_mod
echo 0 > /sys/module/md_mod/parameters/start_ro
record_system_speed_limit
+ is_raid_foreign
}
# check various things
diff --git a/tests/templates/names_template b/tests/templates/names_template
index 1b6cd14bf51d..88ad5b8c6b38 100644
--- a/tests/templates/names_template
+++ b/tests/templates/names_template
@@ -30,6 +30,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 +39,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 +58,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
--
2.32.0 (Apple Git-132)
next prev parent reply other threads:[~2024-05-22 8:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 8:50 [PATCH 00/19] mdadm/tests: enhance/fix regression cases Xiao Ni
2024-05-22 8:50 ` [PATCH 01/19] Change some error messages to info level Xiao Ni
2024-05-23 14:20 ` Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 02/19] mdadm: Start update_opt from 0 Xiao Ni
2024-05-23 14:22 ` Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 03/19] Don't control reshape speed in daemon Xiao Ni
2024-05-23 14:25 ` Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 04/19] mdadm/tests: test enhance Xiao Ni
2024-05-23 14:26 ` Mariusz Tkaczyk
2024-05-23 14:39 ` Xiao Ni
2024-05-23 14:52 ` Mariusz Tkaczyk
2024-05-23 14:56 ` Xiao Ni
2024-05-24 7:59 ` Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 05/19] mdadm/tests: test don't fail when systemd reports error Xiao Ni
2024-05-23 14:29 ` Mariusz Tkaczyk
2024-05-22 8:50 ` Xiao Ni [this message]
2024-05-23 14:37 ` [PATCH 06/19] mdadm/tests: names_template enhance Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 07/19] mdadm/tests: 03assem-incr enhance Xiao Ni
2024-05-23 14:39 ` Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 08/19] mdadm/tests 03r0assem enhance Xiao Ni
2024-05-23 14:40 ` Mariusz Tkaczyk
2024-05-22 8:50 ` [PATCH 09/19] mdadm/tests: remove 03r5assem-failed Xiao Ni
2024-05-22 8:50 ` [PATCH 10/19] mdadm/tests: 03r5assemV1 Xiao Ni
2024-05-22 8:50 ` [PATCH 11/19] mdadm/tests: remove 04r5swap.broken Xiao Ni
2024-05-22 8:50 ` [PATCH 12/19] tests/04update-metadata skip linear Xiao Ni
2024-05-22 8:50 ` [PATCH 13/19] mdadm/tests: 05r5-internalbitmap Xiao Ni
2024-05-22 8:50 ` [PATCH 14/19] mdadm/tests: 05r6-bitmapfile Xiao Ni
2024-05-22 8:50 ` [PATCH 15/19] mdadm/tests: 06name enhance Xiao Ni
2024-05-22 8:50 ` [PATCH 16/19] mdadm/tests: 07autoassemble Xiao Ni
2024-05-22 8:50 ` [PATCH 17/19] mdadm/tests: 07autodetect.broken can be removed Xiao Ni
2024-05-22 8:50 ` [PATCH 18/19] mdadm/tests: 07changelevelintr Xiao Ni
2024-05-22 8:50 ` [PATCH 19/19] mdadm/tests: disable selinux Xiao Ni
2024-05-24 8:45 ` [PATCH 00/19] mdadm/tests: enhance/fix regression cases Mariusz Tkaczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240522085056.54818-7-xni@redhat.com \
--to=xni@redhat.com \
--cc=heinzm@redhat.com \
--cc=linux-raid@vger.kernel.org \
--cc=mariusz.tkaczyk@linux.intel.com \
--cc=ncroxon@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).