Whamcloud - gitweb
LU-17050 tests: remove sanity-sec IDENTITY_UPCALL 00/52400/2
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 14 Sep 2023 20:59:58 +0000 (14:59 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 28 Sep 2023 08:02:31 +0000 (08:02 +0000)
In sanity-sec.sh there was an IDENTITY_UPCALL variable that
conflicted with an identically-named global variable in
test-parameters.  Due to new checks by Gerrit Janitor, this
was causing any patch that ran sanity-sec.sh to log a warning.

Remove the parameter from sanity-sec.sh as it is unused.
Update code style in functions upcating identity_upcall.

Test-Parameters: trivial testlist=sanity-sec mdscount=2 mdtcount=4
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I2f2ace33cf01153d16f4f25038065d33443ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52400
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Alex Deiter <alex.deiter@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-sec.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 9f0d9df..05a12a4 100755 (executable)
@@ -96,12 +96,10 @@ else
        echo "without GSS support"
 fi
 
-MDT=$(do_facet $SINGLEMDS lctl get_param -N "mdt.\*MDT0000" |
-       cut -d. -f2 || true)
-[ -z "$MDT" ] && error "fail to get MDT device" && exit 1
+MDT=$(mdtname_from_index 0 $MOUNT)
+[[ -z "$MDT" ]] && error "fail to get MDT0000 device name" && exit 1
 do_facet $SINGLEMDS "mkdir -p $CONFDIR"
 IDENTITY_FLUSH=mdt.$MDT.identity_flush
-IDENTITY_UPCALL=mdt.$MDT.identity_upcall
 
 SAVE_PWD=$PWD
 
@@ -128,7 +126,7 @@ sec_login() {
 declare -a identity_old
 
 sec_setup() {
-       for num in $(seq $MDSCOUNT); do
+       for ((num = 1; num <= $MDSCOUNT; num++)); do
                switch_identity $num true || identity_old[$num]=$?
        done
 
@@ -203,7 +201,7 @@ run_test 1 "setuid/gid ============================="
 # bug 3285 - supplementary group should always succeed.
 # NB: the supplementary groups are set for local client only,
 # as for remote client, the groups of the specified uid on MDT
-# will be obtained by upcall /sbin/l_getidentity and used.
+# will be obtained by upcall /usr/sbin/l_getidentity and used.
 test_4() {
        [[ "$MDS1_VERSION" -ge $(version_code 2.6.93) ]] ||
        [[ "$MDS1_VERSION" -ge $(version_code 2.5.35) &&
@@ -211,7 +209,7 @@ test_4() {
                skip "Need MDS version at least 2.6.93 or 2.5.35"
 
        rm -rf $DIR/$tdir
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 -p $DIR/$tdir
        chmod 0771 $DIR/$tdir
        chgrp $ID0 $DIR/$tdir
        $RUNAS_CMD -u $ID0 ls $DIR/$tdir || error "setgroups (1)"
@@ -5939,8 +5937,8 @@ run_test 65 "lfs find -printf %La and --attrs support"
 log "cleanup: ======================================================"
 
 sec_unsetup() {
-       for num in $(seq $MDSCOUNT); do
-               if [ "${identity_old[$num]}" = 1 ]; then
+       for ((num = 1; num <= $MDSCOUNT; num++)); do
+               if [[ "${identity_old[$num]}" == 1 ]]; then
                        switch_identity $num false || identity_old[$num]=$?
                fi
        done
index 8a20214..56740d7 100755 (executable)
@@ -12467,7 +12467,7 @@ test_103a() {
 
        declare -a identity_old
 
-       for num in $(seq $MDSCOUNT); do
+       for ((num = 1; num <= $MDSCOUNT; num++)); do
                switch_identity $num true || identity_old[$num]=$?
        done
 
@@ -12530,8 +12530,8 @@ test_103a() {
        cd $SAVE_PWD
        umask $SAVE_UMASK
 
-       for num in $(seq $MDSCOUNT); do
-               if [ "${identity_old[$num]}" = 1 ]; then
+       for ((num = 1; num <= $MDSCOUNT; num++)); do
+               if [[ "${identity_old[$num]}" == 1 ]]; then
                        switch_identity $num false || identity_old[$num]=$?
                fi
        done
index bb38de0..5097117 100755 (executable)
@@ -22,7 +22,8 @@ export SK_S2S=${SK_S2S:-false}
 export SK_S2SNM=${SK_S2SNM:-TestFrameNM}
 export SK_S2SNMCLI=${SK_S2SNMCLI:-TestFrameNMCli}
 export SK_SKIPFIRST=${SK_SKIPFIRST:-true}
-export IDENTITY_UPCALL=default
+# whether identity upcall is enabled (true), disabled (false), or default
+export IDENTITY_UPCALL=${IDENTITY_UPCALL:-default}
 export QUOTA_AUTO=1
 export FLAKEY=${FLAKEY:-true}
 # specify environment variable containing batch job name for server statistics
@@ -317,7 +318,7 @@ init_test_env() {
 
        export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
        if [ ! -f "$L_GETIDENTITY" ]; then
-               if `which l_getidentity > /dev/null 2>&1`; then
+               if $(which l_getidentity > /dev/null 2>&1); then
                        export L_GETIDENTITY=$(which l_getidentity)
                else
                        export L_GETIDENTITY=NONE
@@ -391,15 +392,6 @@ init_test_env() {
                ;;
        esac
 
-       case "x$IDUP" in
-               xtrue)
-                       IDENTITY_UPCALL=true
-                       ;;
-               xfalse)
-                       IDENTITY_UPCALL=false
-                       ;;
-       esac
-
        export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
 
        # Paths on remote nodes, if different
@@ -5112,35 +5104,30 @@ umount_client() {
        grep " $1 " /proc/mounts && zconf_umount $HOSTNAME $*
 }
 
-# return value:
-# 0: success, the old identity set already.
-# 1: success, the old identity does not set.
+# usage: switch_identity MDSNUM ENABLE_UPCALL
+#
+# return values:
+# 0: success, the identity upcall was previously enabled already.
+# 1: success, the identity upcall was previously disabled.
 # 2: fail.
 switch_identity() {
-    local num=$1
-    local switch=$2
-    local j=`expr $num - 1`
-    local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
+       local num=$1
+       local enable=$2
+       local facet=mds$num
+       local MDT="$(mdtname_from_index $((num - 1)) $MOUNT)"
+       local upcall="$L_GETIDENTITY"
 
-    if [ -z "$MDT" ]; then
-        return 2
-    fi
+       [[ -n "$MDT" ]] || return 2
 
-    local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
+       local param="mdt.$MDT.identity_upcall"
+       local old="$(do_facet $facet "lctl get_param -n $param")"
 
-    if $switch; then
-        do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
-    else
-        do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
-    fi
+       [[ "$enable" == "true" ]] || upcall="NONE"
 
-    do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
+       do_facet $facet "lctl set_param -n $param='$upcall'" || return 2
+       do_facet $facet "lctl set_param -n mdt.$MDT.identity_flush=-1"
 
-    if [ $old = "NONE" ]; then
-        return 1
-    else
-        return 0
-    fi
+       [[ "$old" != "NONE" ]] # implicit "&& return 0 || return 1"
 }
 
 remount_client()
@@ -5200,7 +5187,7 @@ mountmds() {
                                eval $varname=$host
                        fi
                done
-               if [ $IDENTITY_UPCALL != "default" ]; then
+               if [[ "$IDENTITY_UPCALL" != "default" ]]; then
                        switch_identity $num $IDENTITY_UPCALL
                fi
        done