From 8d100528841ce55f1d42d71f6fabfac6309a7f26 Mon Sep 17 00:00:00 2001 From: Albert Gil <albert.gil@schedmd.com> Date: Thu, 25 Feb 2021 10:20:49 +0100 Subject: [PATCH] Testsuite - Improve testsuite_user assuming it's NOT in Slurm DB Improve testsuite_user docs. Add a log_warn on check_run_as_user in case user is on DB. Bug 9313 Signed-off-by: Chad Vizino <chad@schedmd.com> --- testsuite/expect/README | 5 +++-- testsuite/expect/globals | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/testsuite/expect/README b/testsuite/expect/README index 07c4b66bdb6..796849b1661 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -42,8 +42,9 @@ testsuite_subtest_details: add details of subtest in the summary [fail] possible values: all, fail, fail_skip or none testsuite_testproc_details: add details of testprocs in the summary [fail] possible values: all, fail, fail_skip or none -testsuite_user: username that may be used when an admin user - such as slurm or root is not desired +testsuite_user: a system username that is NOT on the Slurm DB + that may be used to sudo commands as him + instead of current user (see check_run_as_user) The testsuite needs at least one cluster-wide shared file system. By default, we assume that it's the testsuite/expect directory (i.e. "."). diff --git a/testsuite/expect/globals b/testsuite/expect/globals index df540f62670..3ef078f7880 100755 --- a/testsuite/expect/globals +++ b/testsuite/expect/globals @@ -808,6 +808,10 @@ proc tolerance { expected observed tolerance_expression } { # check. Calling user should be permitted to run_commands as the # supplied user using sudo without password. # See the -user option of run_command. +# This proc also log_warn a message if user already exists in the DB +# because most probably this user is testsuite_user and that user is +# expected NOT to be in the DB and could potentially be removed from it by +# the test. # # RETURN VALUE # Returns a boolean value indicating whether the calling user may @@ -824,6 +828,11 @@ proc check_run_as_user user { if {[run_command_status -none -user $user "$bin_id -un"]} { return false } + + if {[get_admin_level $user] != ""} { + log_warn "User $user already exists in DB, but it's probable that it's going to be removed by the test cleanup" + } + return true } @@ -872,6 +881,7 @@ proc check_run_as_user user { # -user <user> # Attempt to execute command as <user>. Note that sudo must be # properly configured to permit the caller to execute as <user>. +# See check_run_as_user. # # ARGUMENTS # command -- GitLab