Whamcloud - gitweb
LU-16915 tests: improve distro type checking 90/54790/5
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 12 Apr 2024 01:18:28 +0000 (19:18 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 30 Apr 2024 06:51:18 +0000 (06:51 +0000)
Improve lustre_os_release() infrastructure to reduce redundant
code and make it easier to use.

Test-Parameters: trivial
Test-Parameters: testlist=sanity-sec env=ONLY=51,HONOR_EXCEPT=y serverdistro=el9.3
Test-Parameters: testlist=sanity env=ONLY=906,HONOR_EXCEPT=y serverdistro=el9.3
Fixes: b881bd1051 ("LU-16915 tests: except sanity-sec test_51")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Id02223752df4eb3fd3b62b339e8c417eb33ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54790
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/sanity-sec.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index da0f525..c248713 100755 (executable)
@@ -15,12 +15,12 @@ init_test_env $@
 init_logging
 
 ALWAYS_EXCEPT="$SANITY_SEC_EXCEPT "
-if [[ "$MDS1_OS_ID" == "rhel" || "$MDS1_OS_ID_LIKE" =~ "rhel" ]] &&
+if [[ "$MDS1_OS_ID_LIKE" =~ "rhel" ]] &&
    (( $MDS1_OS_VERSION_CODE == $(version_code 9.3) )); then
        always_except LU-16915 51
 fi
 
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="26"
+[[ "$SLOW" == "no" ]] && EXCEPT_SLOW="26"
 
 NODEMAP_TESTS=$(seq 7 26)
 
index 3ff6c03..8868245 100755 (executable)
@@ -80,12 +80,9 @@ if [[ "$ost1_FSTYPE" = "zfs" ]]; then
        always_except LU-9054 312
 fi
 
-proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
-
-if [ -r /etc/redhat-release ]; then
-       rhel_version=$(cat /etc/redhat-release |
-               sed -e 's/^[^0-9.]*//g' | sed -e 's/[ ].*//')
-       if (( $(version_code $rhel_version) >= $(version_code 9.3.0) )); then
+# Check if running on specific distros to skip certain subtests
+if [[ "$CLIENT_OS_ID_LIKE" =~ "rhel" ]]; then
+       if (( $CLIENT_OS_VERSION_CODE == $(version_code 9.3.0) )); then
                # disable test_906 temporarily until rhel9.3 solves the
                # failure on fio io_uring I/O engine.
                always_except LU-17289 906
@@ -95,6 +92,8 @@ fi
 build_test_filter
 FAIL_ON_ERROR=false
 
+proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
+
 cleanup() {
        echo -n "cln.."
        pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
index ad523fa..d4ff821 100755 (executable)
@@ -389,10 +389,10 @@ get_lustre_env() {
                # MDS1_OS_VERSION_ID, MDS1_OS_ID, MDS1_OS_ID_LIKE,
                # OST1_OS_VERSION_ID, OST1_OS_ID, OST1_OS_ID_LIKE,
                # CLIENT_OS_VERSION_ID, CLIENT_OS_ID, CLIENT_OS_ID_LIKE
-               lustre_os_release "eval export" mgs
-               lustre_os_release "eval export" mds1
-               lustre_os_release "eval export" ost1
-               lustre_os_release "eval export" client
+               lustre_os_release mgs
+               lustre_os_release mds1
+               lustre_os_release ost1
+               lustre_os_release client
        fi
 
        # Prefer using "mds1" directly instead of SINGLEMDS.
@@ -773,24 +773,30 @@ lustre_version_code() {
 # generates $facet_OS_ID, $facet_OS_ID_LIKE, $facet_VERSION_ID
 # and also $facet_OS_VERSION_CODE=$(version_code $facet_VERSION_ID)
 lustre_os_release() {
-       local action=${1:-echo}
-       local facet=$2
-       local FACET_OS=$(tr "[:lower:]" "[:upper:]" <<<$facet)_OS_
-
-       [[ "$action" == "echo" ]] &&
-               echo "$facet: $(do_facet $facet "cat /etc/system-release")"
-       do_facet $facet "[[ -r /etc/os-release ]] || ls -s /etc/*release" 1>&2
+       local facet=$1
+       local facet_os=$(tr "[:lower:]" "[:upper:]" <<<$facet)_OS_
+       local facet_version=${facet_os}VERSION_
+       local line
+
+       echo "$facet: $(do_facet $facet "cat /etc/system-release")"
+       do_facet $facet "test -r /etc/os-release" || {
+               echo "$facet: has no /etc/os-release"
+               do_facet $facet "uname -a; ls -s /etc/*release"
+               return 0
+       }
 
-       while read LINE; do
-       case $LINE in
-       VERSION_ID=*|ID=*|ID_LIKE=*) $action ${FACET_OS}$LINE ;;
-       esac
+       while read line; do
+               # more variables in os-release could be exported, but these
+               # are the ones that looked enough for our needs here
+               case $line in
+               VERSION_ID=*|ID=*|ID_LIKE=*) eval export ${facet_os}$line ;;
+               esac
        done < <(do_facet $facet "cat /etc/os-release")
 
-       [[ "$action" == "echo" ]] && return 0
-
-       local facet_version=${FACET_OS}VERSION
-       $action ${facet_version}_CODE=\$\(version_code \$${facet_version}_ID\)
+       eval export ${facet_version}CODE=\$\(version_code \$${facet_version}ID\)
+       # add in the "self" ID to ID_LIKE so only one needs to be checked
+       eval export ${facet_os}ID_LIKE+=\" \$${facet_os}ID\"
+       env | grep "${facet_os}"
 }
 
 module_loaded () {
@@ -9593,11 +9599,8 @@ init_logging() {
 
        # log actual client and server versions if needed for debugging
        log "Client: $(lustre_build_version client)"
-       lustre_os_release echo client
        log "MDS: $(lustre_build_version mds1)"
-       lustre_os_release echo mds1
        log "OSS: $(lustre_build_version ost1)"
-       lustre_os_release echo ost1
 }
 
 log_test() {