Whamcloud - gitweb
LU-17156 tests: Improve zfs_or_rotational() 73/52973/8
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Fri, 3 Nov 2023 09:06:03 +0000 (14:36 +0530)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Nov 2023 21:43:12 +0000 (21:43 +0000)
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 <arshad.hussain@aeoncomputing.com>
Change-Id: I0b914236865574dadd4ba0cb9a0ba7a7775fefc5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52973
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/test-framework.sh

index e4d5a29..186236f 100755 (executable)
@@ -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