Skip to content

Commit

Permalink
tests: fix "foreign" verification for nameing tests.
Browse files Browse the repository at this point in the history
Mdadm supports DEVNODE in multiple form, we cannot trust that because it
does not always reflect name in metadata. Tests are defining clear
expectations- we must use them.

Do foreign verification against WANTED_NAME instead of passed DEVNODE.

Signed-off-by: Mariusz Tkaczyk <[email protected]>
  • Loading branch information
mtkaczyk committed Nov 25, 2024
1 parent 7f960c3 commit eb24054
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ is_raid_foreign() {
# 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
if [ `expr length "$(hostname):$name"` -lt 31 ]; then
is_foreign="no"
else
is_foreign="yes"
Expand Down
6 changes: 4 additions & 2 deletions tests/templates/names_template
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ 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
Expand Down Expand Up @@ -34,6 +32,10 @@ function names_verify() {
local WANTED_NAME="$3"
local EXPECTED=""

# We don't know what is saved in metadata, but we know what to expect. Therfore check if
# expecation would be foreign (no hostname information).
is_raid_foreign $WANTED_NAME

local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)"
if [[ "$?" != "0" ]]; then
echo "Cannot get details for $DEVNODE_NAME - unexpected devnode."
Expand Down

0 comments on commit eb24054

Please sign in to comment.