From b0262a00714f2d77b6d6ba745169c8fa18d38b32 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Fri, 3 Nov 2023 14:36:03 +0530 Subject: [PATCH] LU-17156 tests: Improve zfs_or_rotational() Improve zfs_or_rotational() under test-framework.sh to handle get_param failure gracefully and not throw bash syntax error. Fix ostname_from_index() to print the OST name once instead of twice if there are multiple mountpoints (e.g. sanityn). If the caller wants the specific name when there are two different filesystems mounted, the specific mountpoint should be given. Test-Parameters: trivial testlist=sanityn Fixes: 43c3a804fe ("LU-13805 tests: Add racing tests of BIO, DIO") Signed-off-by: Arshad Hussain Change-Id: I0b914236865574dadd4ba0cb9a0ba7a7775fefc5 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52973 Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/tests/test-framework.sh | 57 ++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index e4d5a29..186236f 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -7258,19 +7258,17 @@ check_grant() { ######################## # helper functions -osc_to_ost() -{ - osc=$1 - ost=`echo $1 | awk -F_ '{print $3}'` - if [ -z $ost ]; then - ost=`echo $1 | sed 's/-osc.*//'` - fi - echo $ost +osc_to_ost() { + local osc=$1 + + echo ${osc/-osc*/} } -ostuuid_from_index() -{ - $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p" +ostuuid_from_index() { + # only print the first UUID, if 'lfs osts' shows multiple mountpoints + local uuid=($($LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p")) + + echo ${uuid} } ostname_from_index() { @@ -7279,24 +7277,31 @@ ostname_from_index() { echo ${uuid/_UUID/} } +mdtuuid_from_index() { + # only print the first UUID, if 'lfs osts' shows multiple mountpoints + local uuid=($($LFS mdts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p")) + + echo ${uuid} +} + mdtname_from_index() { local uuid=$(mdtuuid_from_index $1 $2) + echo ${uuid/_UUID/} } -mdssize_from_index () { +mdssize_from_index() { local mdt=$(mdtname_from_index $2) - $LFS df $1 | grep $mdt | awk '{ print $2 }' + + $LFS df $1 | awk "/$mdt/ { print \$2 }" } index_from_ostuuid() { - $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p" -} + # only print the first index, if 'lfs osts' shows multiple mountpoints + local ostidx=($($LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p")) -mdtuuid_from_index() -{ - $LFS mdts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p" + echo ${ostidx} } # Description: @@ -11562,10 +11567,20 @@ verify_compare_yaml() { zfs_or_rotational() { local ost_idx=0 - local ost_name=$(ostname_from_index $ost_idx) - local nonrotat=$(do_facet ost1 $LCTL get_param -n osd-*.$ost_name.nonrotational) + local ost_name=$(ostname_from_index $ost_idx $MOUNT) + local param="get_param -n osd-*.${ost_name}.nonrotational" + local nonrotat=$(do_facet ost1 $LCTL $param) + + if [[ -z "$nonrotat" ]]; then + # At this point there is no point moving ahead. + # Will stop here and dump all the info + set -x + local ost_name=$(ostname_from_index $ost_idx) + set +x + error "$LCTL $input_str" + fi - if [ "$ost1_FSTYPE" == "zfs" ] || [ "$nonrotat" -eq 0 ]; then + if [[ "$ost1_FSTYPE" == "zfs" ]] || (( "$nonrotat" == 0 )); then return 0 else return 1 -- 1.8.3.1