From 119f2150109452ec58a18ff7908ac7937c15337d Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Mon, 5 Aug 2024 16:58:42 -0400 Subject: [PATCH] device-mapper-multipath-0.8.7-32 Modify bindings, find_multipaths, and user_friendly_names tests * Fixes RHEL-28068 & RHEL-4459 Resolves: RHEL-28068 Resolves: RHEL-44569 --- device-mapper-multipath.spec | 10 +- tests/bindings/main.sh | 126 +++++++++--- tests/find_multipaths/Makefile | 49 ----- tests/find_multipaths/main.sh | 206 ++++++++++++------- tests/user_friendly_names/main.sh | 151 ++++++++++---- tests/user_friendly_names/multipath.conf.no | 3 - tests/user_friendly_names/multipath.conf.yes | 11 - 7 files changed, 355 insertions(+), 201 deletions(-) delete mode 100644 tests/find_multipaths/Makefile delete mode 100644 tests/user_friendly_names/multipath.conf.no delete mode 100644 tests/user_friendly_names/multipath.conf.yes diff --git a/device-mapper-multipath.spec b/device-mapper-multipath.spec index f04b50f..d0d6117 100644 --- a/device-mapper-multipath.spec +++ b/device-mapper-multipath.spec @@ -1,6 +1,6 @@ Name: device-mapper-multipath Version: 0.8.7 -Release: 31%{?dist} +Release: 32%{?dist} Summary: Tools to manage multipath devices using device-mapper License: GPLv2 URL: http://christophe.varoqui.free.fr/ @@ -334,7 +334,13 @@ fi %{_pkgconfdir}/libdmmp.pc %changelog -* Tue Jul 30 2024 Benjamin Marzinski - 0.8.7-30 +* Mon Aug 5 2024 Benjamin Marzinski - 0.8.7-32 +- Modify bindings, find_multipaths, and user_friendly_names tests + * Fixes RHEL-28068 & RHEL-4459 +- Resolves: RHEL-28068 +- Resolves: RHEL-44569 + +* Tue Jul 30 2024 Benjamin Marzinski - 0.8.7-31 - Modify multiple tests especially medium_error_scsi_debug and squelch_scsi_id * Fixes RHEL-28068 & RHEL-4459 - Resolves: RHEL-28068 diff --git a/tests/bindings/main.sh b/tests/bindings/main.sh index 37ceded..76292e4 100755 --- a/tests/bindings/main.sh +++ b/tests/bindings/main.sh @@ -18,40 +18,110 @@ # Author: Lin Li #set -x -source ../include/ec.sh || exit 200 - +source ../include/tc.sh || exit 200 tlog "running $0" -trun "service multipathd stop" -rpm -q device-mapper-multipath || yum install -y device-mapper-multipath -trun "mpathconf --enable --with_multipathd y --user_friendly_names y" -trun "service multipathd status" -sleep 5 +cleanup () +{ + local retries + if pidof multipathd; then + tlog "stopping multipathd" + trun "systemctl stop multipathd.service || pkill multipathd" + sleep 1 + fi + retries=10 + while pidof multipathd; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to stop multipath" + tend + fi + tlog "waiting for multipathd to stop" + sleep 2 + pidof multipathd && pkill multipathd + done + trun "multipath -l -v1" + retries=10 + while [[ -n `multipath -l -v1` ]]; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to remove deviece" + tend + fi + tlog "removing multipath device" + trun "udevadm settle" + trun "multipath -DF" + sleep 2 + done + if lsmod | grep -q "^scsi_debug"; then + tlog "removing scsi_debug module" + tok "rmmod scsi_debug" + fi + trun "rm -f /etc/multipath.conf" +} -trun "multipath -F" -sleep 5 -terr "modprobe -r scsi_debug" -terr "modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 \ -max_luns=2 no_lun_0=1" -sleep 5 +assert () +{ + local cmd="$*" + _trun_ "$cmd" 0 + if test $? -eq 0; then + tpass_ "$cmd" ; + else + tfail_ "$cmd" ; + cleanup ; + tend ; + fi +} -disk_path=$(get_scsi_debug_devices) -disk=$(basename $disk_path) -mpath_name=$(get_mpath_disk_by_scsi_device $disk) +setup_config () +{ + trun "mpathconf --enable --user_friendly_names y" + sed -i '/^blacklist[[:space:]]*{/ a\ + device {\ + vendor ".*"\ + product ".*"\ + } +' /etc/multipath.conf + cat << _EOF_ >> /etc/multipath.conf + +blacklist_exceptions { + device { + vendor Linux + product scsi_debug + } +} +_EOF_ + trun "cat /etc/multipath.conf" +} + +do_reconfigure () +{ + tok "multipathd reconfigure" + sleep 5 +} + +rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath +cleanup +setup_config +trun "rm -r /etc/multipath/bindings" +trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2" +sleep 5 +trun "systemctl start multipathd.service" +while multipathd show daemon | grep -qv idle; do + tlog "waiting for multipathd to start" + sleep 1 +done + +trun 'multipathd show maps raw format "%n"' +mpath_name=`multipathd show maps raw format "%n" | head -1` +assert "[[ -n $mpath_name ]] && [[ $mpath_name != ok ]]" new_alias="mpath_test_$$" trun "sed -i 's/$mpath_name/$new_alias/' /etc/multipath/bindings" -trun "multipath -r" -sleep 5 -tok "[[ -b /dev/mapper/$new_alias ]]" -tok is_mpath $new_alias -sleep 5 +do_reconfigure +trun 'multipathd show maps raw format "%n"' +mpath_name=`multipathd show maps raw format "%n" | head -1` +assert "[[ $mpath_name = $new_alias ]]" -trun "multipath -F" -sleep 5 -trun "modprobe -r scsi_debug" -trun "service multipathd stop" -sleep 3 -trun "multipath -W" -trun "rm /etc/multipath/bindings" +cleanup tend diff --git a/tests/find_multipaths/Makefile b/tests/find_multipaths/Makefile deleted file mode 100644 index b78dc57..0000000 --- a/tests/find_multipaths/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2016 Red Hat, 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 . -# -# # Author: Lin Li - -.PHONY: all install download clean - -BUILT_FILES= - -FILES=$(METADATA) Makefile PURPOSE main.sh - -run: $(FILES) build - ./main.sh - -build: $(BUILT_FILES) - chmod a+x ./main.sh - -clean: - rm -f *~ *.rpm $(BUILT_FILES) - -include /usr/share/rhts/lib/rhts-make.include - -$(METADATA): Makefile - @touch $(METADATA) - @echo "Owner: LiLin " > $(METADATA) - @echo "Name: $(TEST)" >> $(METADATA) - @echo "Path: $(TEST_DIR)" >> $(METADATA) - @echo "License: GPLv3" >> $(METADATA) - @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) - @echo "Description: find_multipaths" >> $(METADATA) - @echo "TestTime: 15m" >> $(METADATA) - @echo "RunFor: device-mapper-multipath" >> $(METADATA) - @echo "Requires: device-mapper-multipath" >> $(METADATA) - - rhts-lint $(METADATA) diff --git a/tests/find_multipaths/main.sh b/tests/find_multipaths/main.sh index b857787..28c325c 100755 --- a/tests/find_multipaths/main.sh +++ b/tests/find_multipaths/main.sh @@ -18,39 +18,92 @@ # Author: Lin Li #set -x -source ../include/ec.sh || exit 200 +source ../include/tc.sh || exit 200 +tlog "running $0" + +remove_devices () +{ + local retries + retries=10 + while [[ -n `multipath -l -v1` ]]; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to remove devices" + cleanup + tend + fi + tlog "removing multipath devices" + trun "udevadm settle" + trun "multipath -F" + sleep 2 + done +} cleanup () { - trun "multipathd disablequeueing maps" - trun "service multipathd stop" - sleep 5 - trun "udevadm settle" - trun "multipath -F" - sleep 5 - trun "modprobe -r scsi_debug" + local retries + if pidof multipathd; then + tlog "stopping multipathd" + trun "systemctl stop multipathd.service || pkill multipathd" + sleep 1 + fi + retries=10 + while pidof multipathd; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to stop multipath" + tend + fi + tlog "waiting for multipathd to stop" + sleep 2 + pidof multipathd && pkill multipathd + done + trun "multipath -l -v1" + retries=10 + while [[ -n `multipath -l -v1` ]]; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to remove devices" + tend + fi + tlog "removing multipath devices" + trun "udevadm settle" + trun "multipath -DF" + sleep 2 + done + if lsmod | grep -q "^scsi_debug"; then + tlog "removing scsi_debug module" + tok "rmmod scsi_debug" + fi + trun "rm -f /etc/multipath.conf" + trun "rm -f /etc/multipath/wwids" + trun "rm -r /etc/multipath/bindings" } -tlog "running $0" +assert () +{ + local cmd="$*" + _trun_ "$cmd" 0 + if test $? -eq 0; then + tpass_ "$cmd" ; + else + tfail_ "$cmd" ; + cleanup ; + tend ; + fi +} -# which not set find_multipaths yes, so multipath always create a multipath device for single device -# so stop service and reconfig with --find_multipaths y, and reload/start the service again. -rpm -q device-mapper-multipath || yum install -y device-mapper-multipath +setup_config () +{ + trun "mpathconf --enable --user_friendly_names y --find_multipaths y" + sed -i '/^blacklist[[:space:]]*{/ a\ + device {\ + vendor ".*"\ + product ".*"\ + } +' /etc/multipath.conf + cat << _EOF_ >> /etc/multipath.conf -# test with find_multipath=y, will not multipath for the single device; reload/start the service to enable the config -cleanup -trun "rm -f /etc/multipath.conf" -trun "rm -f /etc/multipath/wwids" -trun "mpathconf --enable --user_friendly_names y --find_multipaths y --with_multipathd n" -sed -i '/^blacklist[[:space:]]*{/ a\ - device {\n vendor ".*"\n product ".*"\n } -' /etc/multipath.conf -if grep -qw blacklist_exceptions /etc/multipath.conf ; then - sed -i '/^blacklist_exceptions[[:space:]]*{/ a\ - device {\n vendor Linux\n product scsi_debug\n } -' /etc/multipath.conf -else - cat << _EOF_ >> /etc/multipath.conf blacklist_exceptions { device { vendor Linux @@ -58,56 +111,69 @@ blacklist_exceptions { } } _EOF_ -fi -trun "service multipathd start" + trun "cat /etc/multipath.conf" +} + +do_reconfigure () +{ + trun "cat /etc/multipath.conf" + tok "multipathd reconfigure" + sleep 5 +} + +trun "rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath" +cleanup +setup_config + +# test with find_multipath=y, will not multipath the single device trun "modprobe scsi_debug" sleep 5 +trun "systemctl start multipathd.service" +while multipathd show daemon | grep -qv idle; do + tlog "waiting for multipathd to start" + sleep 1 +done +trun 'multipathd show paths raw format "%d %m"' +trun 'cat /etc/multipath/wwids' +mpath_name=`multipathd show paths raw format "%m" | head -1` +tok "[[ $mpath_name = '[orphan]' ]]" +remove_devices + +# test with find_multipath=n, will multipath the single device +trun 'mpathconf --find_multipaths n' +do_reconfigure +trun 'multipathd show paths raw format "%d %m"' +trun 'cat /etc/multipath/wwids' +mpath_name=`multipathd show paths raw format "%m" | head -1` +tok "[[ -n $mpath_name ]] && [[ $mpath_name != '[orphan]' ]]" +remove_devices + +# test with find_multipath=y, with multipath single device with known WWID +trun 'mpathconf --find_multipaths y' +do_reconfigure +trun 'multipathd show paths raw format "%d %m"' +trun 'cat /etc/multipath/wwids' +mpath_name=`multipathd show paths raw format "%m" | head -1` +tok "[[ -n $mpath_name ]] && [[ $mpath_name != '[orphan]' ]]" +remove_devices + +# Clear WWID, test with find_multipath=y, will not multipath single device trun "multipath -W" -cat /etc/multipath/wwids -trun "multipath" -disk_path=$(get_scsi_debug_devices) -disk_node=$(basename $disk_path) -mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) -tok '[[ $mpath_name = "[orphan]" ]]' - -# test with find_multipath=n, will multipath for the single device -trun "mpathconf --user_friendly_names y --find_multipaths n --with_multipathd y" -sleep 5 -mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) -tok "is_mpath $mpath_name" - -# flush new created path -trun "multipath -F" -sleep 1 - -# test with find_multipath=y, A path has the same WWID as a multipath device that was previously created -trun "mpathconf --user_friendly_names y --find_multipaths y --with_multipathd y" -sleep 5 -mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) -tok "is_mpath $mpath_name" -trun "multipath -F" -sleep 1 - -# Clear wwid, test with find_multipath=y, will not multipath for the single device -trun "multipath -W" -trun "service multipathd reload" -sleep 5 -mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) -tok '[[ $mpath_name = "[orphan]" ]]' - -trun "multipath -F" -sleep 5 -trun "modprobe -r scsi_debug" +do_reconfigure +trun 'multipathd show paths raw format "%d %m"' +trun 'cat /etc/multipath/wwids' +mpath_name=`multipathd show paths raw format "%m" | head -1` +tok "[[ $mpath_name = '[orphan]' ]]" +remove_devices +assert 'rmmod scsi_debug' # test find_multipaths=y create device for paths have same wwid -tok "modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 max_luns=2 no_lun_0=1" +trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2" sleep 5 -disk_paths=$(get_scsi_debug_devices) -disk_node=$(basename $disk_paths) -mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) -tok "is_mpath $mpath_name" +trun 'multipathd show paths raw format "%d %m"' +trun 'cat /etc/multipath/wwids' +mpath_name=`multipathd show paths raw format "%m" | head -1` +tok "[[ -n $mpath_name ]] && [[ $mpath_name != '[orphan]' ]]" cleanup -trun "multipath -W" -cat /etc/multipath/wwids tend diff --git a/tests/user_friendly_names/main.sh b/tests/user_friendly_names/main.sh index 56082fd..1d48801 100755 --- a/tests/user_friendly_names/main.sh +++ b/tests/user_friendly_names/main.sh @@ -17,50 +17,125 @@ # Author: Lin Li -source ../include/ec.sh || exit 200 - +source ../include/tc.sh || exit 200 tlog "running $0" -trun "rpm -q device-mapper-multipath || yum install -y device-mapper-multipath" -trun "mpathconf --enable --with_multipathd y --user_friendly_names y" +cleanup () +{ + local retries + if pidof multipathd; then + tlog "stopping multipathd" + trun "systemctl stop multipathd.service || pkill multipathd" + sleep 1 + fi + retries=10 + while pidof multipathd; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to stop multipath" + tend + fi + tlog "waiting for multipathd to stop" + sleep 2 + pidof multipathd && pkill multipathd + done + trun "multipath -l -v1" + retries=10 + while [[ -n `multipath -l -v1` ]]; do + ((retries--)) + if [[ $retries -le 0 ]]; then + tfail_ "failed to remove deviece" + tend + fi + tlog "removing multipath device" + trun "udevadm settle" + trun "multipath -DF" + sleep 2 + done + if lsmod | grep -q "^scsi_debug"; then + tlog "removing scsi_debug module" + tok "rmmod scsi_debug" + fi + trun "rm -f /etc/multipath.conf" +} -# backup the /etc/multipath.conf -trun "cp /etc/multipath.conf /etc/multipath.conf.$$" -trun "multipath -F" +assert () +{ + local cmd="$*" + _trun_ "$cmd" 0 + if test $? -eq 0; then + tpass_ "$cmd" ; + else + tfail_ "$cmd" ; + cleanup ; + tend ; + fi +} -trun "modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 \ -max_luns=2 no_lun_0=1" -trun "multipath" -# wwid shown slowly on s390x by the script framework, but normally when run by multipath command directly -# so extend sleep time -sleep 20 +setup_config () +{ + trun "mpathconf --enable --user_friendly_names y" + sed -i '/^blacklist[[:space:]]*{/ a\ + device {\ + vendor ".*"\ + product ".*"\ + } +' /etc/multipath.conf + cat << _EOF_ >> /etc/multipath.conf -disk=$(get_scsi_debug_devices) -disk=$(basename $disk) -wwid=$(get_wwid_of_disk $disk) -mpath=$(get_mpath_disk_by_scsi_device $disk) +blacklist_exceptions { + device { + vendor Linux + product scsi_debug + } +} -# user_friendly_names = yes and mpath=test -#cur_dir=/mnt/tests/kernel/storage/multipath/user_friendly_names/ -#cur_dir=/home/test/scratch/device-mapper-multipath/user_friendly_names -trun "cat multipath.conf.yes | sed "s/your_wwid/$wwid/g" > /etc/multipath.conf" -trun "cat -n /etc/multipath.conf" -trun "multipath -r" -echo ">>> Verify 'test ($wwid)' is present ..." -trun "multipath -ll" -tok "multipath -ll | egrep \"^test\"" +multipaths { + multipath { + wwid TEST_WWID + alias test + } +} +_EOF_ + trun "cat /etc/multipath.conf" +} -# user_friendly_names = no -trun "cat multipath.conf.no > /etc/multipath.conf" -trun "multipath -r" -echo ">>> Verify 'test' is gone but '$wwid' present ..." -trun "multipath -ll" -tok "multipath -ll | egrep \"^$wwid\"" -sleep 10 -tok "multipath -F $wwid" -sleep 10 -trun "modprobe -r scsi_debug" +do_reconfigure () +{ + trun "cat /etc/multipath.conf" + tok "multipathd reconfigure" + sleep 5 +} -trun "cp /etc/multipath.conf.$$ /etc/multipath.conf" -trun "multipath -F; multipath" +trun "rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath" +cleanup +setup_config +trun "rm -r /etc/multipath/bindings" +trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2" +sleep 5 +trun "systemctl start multipathd.service" +while multipathd show daemon | grep -qv idle; do + tlog "waiting for multipathd to start" + sleep 1 +done +trun 'multipathd show maps raw format "%n %w"' +# verify user_friendly_name +tok 'multipathd show maps raw format "%n" | head -1 | grep -q mpath' +wwid=`multipathd show maps raw format "%w" | head -1` +assert "[[ -n $wwid ]] && [[ $wwid != ok ]]" +sed -i 's/TEST_WWID/'"$wwid"'/' /etc/multipath.conf +do_reconfigure +trun 'multipathd show maps raw format "%n %w"' +# verify configured alias takes precedence over user_friendly_name +tok 'multipathd show maps raw format "%n" | head -1 | grep -q test' +trun "mpathconf --user_friendly_names n" +do_reconfigure +trun 'multipathd show maps raw format "%n %w"' +# verify configured alias takes precedence over wwid name +tok 'multipathd show maps raw format "%n" | head -1 | grep -q test' +sed -i 's/'"$wwid"'/TEST_WWID/' /etc/multipath.conf +do_reconfigure +trun 'multipathd show maps raw format "%n %w"' +tok 'multipathd show maps raw format "%n" | head -1 | grep -q '"$wwid" +cleanup tend diff --git a/tests/user_friendly_names/multipath.conf.no b/tests/user_friendly_names/multipath.conf.no deleted file mode 100644 index b916bfb..0000000 --- a/tests/user_friendly_names/multipath.conf.no +++ /dev/null @@ -1,3 +0,0 @@ -defaults { - user_friendly_names no -} diff --git a/tests/user_friendly_names/multipath.conf.yes b/tests/user_friendly_names/multipath.conf.yes deleted file mode 100644 index ffc21bb..0000000 --- a/tests/user_friendly_names/multipath.conf.yes +++ /dev/null @@ -1,11 +0,0 @@ -defaults { - user_friendly_names yes -} - -multipaths { - multipath { - wwid your_wwid - alias test - } -} -