Whamcloud - gitweb
LU-17050 tests: test Kerberos env in sanity-krb5 68/52068/4
authorSebastien Buisson <sbuisson@ddn.com>
Thu, 24 Aug 2023 09:40:46 +0000 (11:40 +0200)
committerOleg Drokin <green@whamcloud.com>
Wed, 6 Sep 2023 06:21:32 +0000 (06:21 +0000)
Test Kerberos environnement is sane before trying to launch
sanity-krb5 tests.

Test-Parameters: trivial kerberos=true testlist=sanity-krb5
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I1675ba7db8c62687c69359a15cc931b5dfd40018
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52068
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Aurelien Degremont <adegremont@nvidia.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-krb5.sh
lustre/tests/test-framework.sh

index 94b8fab..2cfce7a 100755 (executable)
@@ -37,12 +37,18 @@ DBENCH_PID=0
 GSS=true
 GSS_KRB5=true
 
+check_krb_env() {
+       which klist || skip "Kerberos env not setup"
+       which kinit || skip "Kerberos env not setup"
+}
+
 prepare_krb5_creds() {
        echo prepare krb5 cred
        echo RUNAS=$RUNAS
        $RUNAS krb5_login.sh || exit 1
 }
 
+check_krb_env
 prepare_krb5_creds
 
 # we want double mount
@@ -113,6 +119,24 @@ error_dbench()
        error $err_str
 }
 
+# obtain and cache Kerberos ticket-granting ticket
+refresh_krb5_tgt() {
+       local myRUNAS_UID=$1
+       local myRUNAS_GID=$2
+       shift 2
+       local myRUNAS=$@
+       if [ -z "$myRUNAS" ]; then
+               error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
+       fi
+
+       CLIENTS=${CLIENTS:-$HOSTNAME}
+       do_nodes $CLIENTS "set -x
+if ! $myRUNAS krb5_login.sh; then
+    echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
+    exit 1
+fi"
+}
+
 restore_krb5_cred() {
        local keys=$(keyctl show | awk '$6 ~ "^lgssc:" {print $1}')
 
index 407474e..46c9d04 100755 (executable)
@@ -7696,24 +7696,6 @@ exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
 }
 
-# obtain and cache Kerberos ticket-granting ticket
-refresh_krb5_tgt() {
-       local myRUNAS_UID=$1
-       local myRUNAS_GID=$2
-       shift 2
-       local myRUNAS=$@
-       if [ -z "$myRUNAS" ]; then
-               error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
-       fi
-
-       CLIENTS=${CLIENTS:-$HOSTNAME}
-       do_nodes $CLIENTS "set -x
-if ! $myRUNAS krb5_login.sh; then
-    echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
-    exit 1
-fi"
-}
-
 # Run multiop in the background, but wait for it to print
 # "PAUSING" to its stdout before returning from this function.
 multiop_bg_pause() {