From: Andreas Dilger Date: Fri, 12 Apr 2024 01:18:28 +0000 (-0600) Subject: LU-16915 tests: improve distro type checking X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=81e3d27adf705b2f00f14847dd496b837358e139;p=fs%2Flustre-release.git LU-16915 tests: improve distro type checking Improve lustre_os_release() infrastructure to reduce redundant code and make it easier to use. Lustre-change: https://review.whamcloud.com/54790 Lustre-commit: 1ffbec13c0f745d0b9c6b91959b1afa52f99d63b Test-Parameters: trivial Fixes: 339b5e918f ("LU-16915 tests: except sanity-sec test_51") Signed-off-by: Andreas Dilger Change-Id: Id02223752df4eb3fd3b62b339e8c417eb33ebbe5 Reviewed-by: Jian Yu Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55213 Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index cc4ffe3..fcb69fb 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -16,12 +16,12 @@ init_logging ALWAYS_EXCEPT="$SANITY_SEC_EXCEPT " always_except EX-7601 66 -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) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index b4096da..5d9047a 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -108,10 +108,9 @@ if [ -r /etc/SuSE-release ] || [ -r /etc/SUSE-brand ]; then (( $sles_version >= $(version_code 12.0.0) )) || always_except LU-3703 234 -elif [ -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 +elif [[ "$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 @@ -137,6 +136,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; } diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 01580b30..608958e 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -173,10 +173,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 # Prefer using "mds1" directly instead of SINGLEMDS. # Keep this for compat until it is removed from scripts. @@ -559,24 +559,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 () { @@ -9297,11 +9303,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() {