| #!/usr/bin/expect |
| ############################################################################ |
| # Purpose: Test of SLURM functionality |
| # sacctmgr modify multiple users |
| # |
| # |
| # Output: "TEST: #.#" followed by "SUCCESS" if test was successful, OR |
| # "FAILURE: ..." otherwise with an explanation of the failure, OR |
| # anything else indicates a failure mode that must be investigated. |
| ############################################################################ |
| # Copyright (C) 2008-2010 Lawrence Livermore National Security. |
| # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). |
| # Written by Joseph Donaghy <donaghy1@llnl.gov> |
| # CODE-OCEC-09-009. All rights reserved. |
| # |
| # This file is part of SLURM, a resource management program. |
| # For details, see <http://slurm.schedmd.com/>. |
| # Please also read the included file: DISCLAIMER. |
| # |
| # SLURM is free software; you can redistribute it and/or modify it under |
| # the terms of the GNU General Public License as published by the Free |
| # Software Foundation; either version 2 of the License, or (at your option) |
| # any later version. |
| # |
| # SLURM is distributed in the hope that it will be useful, but WITHOUT ANY |
| # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| # details. |
| # |
| # You should have received a copy of the GNU General Public License along |
| # with SLURM; if not, write to the Free Software Foundation, Inc., |
| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| ############################################################################ |
| source ./globals_accounting |
| |
| set test_id "21.18" |
| set exit_code 0 |
| set tc1 slurm_test-cluster-1 |
| set tc2 slurm_test-cluster-2 |
| set tc3 slurm_test-cluster-3 |
| set fs2 1700 |
| set fs3 1 |
| set mc2 700000 |
| set mc3 1 |
| set mj2 70 |
| set mj3 1 |
| set mn2 700 |
| set mn3 1 |
| set mw2 00:07:00 |
| set mw3 00:01:00 |
| set ta1 slurm_test-account.1 |
| set ta2 slurm_test-account.2 |
| set ta3 slurm_test-account.3 |
| set ds1 testaccounta1 |
| set ds2 testacct |
| set or1 accountorga1 |
| set or2 acttrg |
| set qs1 normal |
| set tu1 slurm_test-user.1 |
| set tu2 slurm_test-user.2 |
| set tu3 slurm_test-user.3 |
| set ala Administrator |
| set alo Operator |
| set fs fairshare |
| set mc maxcpu |
| set mj maxjob |
| set mn maxnode |
| set mw maxwall |
| set access_err 0 |
| |
| |
| print_header $test_id |
| |
| set timeout 60 |
| |
| # |
| # Check accounting config and bail if not found. |
| # |
| if { [test_account_storage] == 0 } { |
| send_user "\nWARNING: This test can't be run without a usable AccountStorageType\n" |
| exit 0 |
| } |
| |
| if { [string compare [check_accounting_admin_level] "Administrator"] } { |
| send_user "\nWARNING: This test can't be run without being an Accounting administrator.\nUse sacctmgr mod user \$USER_NAME admin=admin.\n" |
| exit 0 |
| } |
| |
| #make sure we have a clean system and permission to do this work |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| if {$access_err != 0} { |
| send_user "\nWARNING: not authorized to perform this test\n" |
| exit $exit_code |
| } |
| |
| #add cluster |
| incr exit_code [add_cluster "$tc1,$tc2,$tc3" "" "" "" "" "" "" "" "" "" "" "" "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| #add accounts |
| incr exit_code [add_acct "$tc1,$tc2,$tc3" "" "$ta1,$ta2,$ta3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| #add users |
| incr exit_code [add_user "$tc1,$tc2,$tc3" "$ta1,$ta2,$ta3" "$tu1,$tu2,$tu3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| # First test change the AdminLevel and DefaultAccount of the accounts |
| # cluster account name part wadmin wdacct wdwckey qos fairshare grpcpumin grpcpu grpjob grpnode grpsubmit grpwall maxcpumin maxcpu maxjob maxnode maxsubmit maxwall admin dacct dwckey |
| incr exit_code [mod_user "$tc1,$tc2,$tc3" "" "$tu1,$tu2,$tu3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" $alo $ta2 "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| # |
| # Use sacctmgr to list the test account modifications |
| # |
| set matches 0 |
| set my_pid [spawn $sacctmgr -n -p list user names=$tu1,$tu2,$tu3 format="User,DefaultA,Admin" cluster=$tc1] |
| expect { |
| -re "There was a problem" { |
| send_user "FAILURE: there was a problem with the sacctmgr command\n" |
| incr exit_code 1 |
| } |
| -re "($tu1|$tu2|$tu3).$ta2.$alo." { |
| incr matches |
| exp_continue |
| } |
| timeout { |
| send_user "\nFAILURE: sacctmgr list associations not responding\n" |
| slow_kill $my_pid |
| incr exit_code 1 |
| } |
| eof { |
| wait |
| } |
| } |
| |
| if {$matches != 3} { |
| send_user "\nFAILURE: Account modification 3 incorrect with only $matches.\n" |
| incr exit_code 1 |
| } |
| |
| # Test change the AdminLevel and DefaultAccount of two accounts |
| # cluster account name part wadmin wdacct wdwckey qos fairshare grpcpumin grpcpu grpjob grpnode grpsubmit grpwall maxcpumin maxcpu maxjob maxnode maxsubmit maxwall admin dacct dwckey |
| incr exit_code [mod_user "$tc1,$tc2,$tc3" "" "$tu1,$tu3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" $ala $ta3 "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| # |
| # Use sacctmgr to list the test account modifications |
| # |
| set matches 0 |
| set my_pid [spawn $sacctmgr -n -p list user names=$tu1,$tu2,$tu3 format="User,DefaultA,Admin" cluster=$tc1] |
| expect { |
| -re "There was a problem" { |
| send_user "FAILURE: there was a problem with the sacctmgr command\n" |
| incr exit_code 1 |
| } |
| -re "(($tu1|$tu3).$ta3.$ala.|$tu2.$ta2.$alo.)" { |
| incr matches |
| exp_continue |
| } |
| timeout { |
| send_user "\nFAILURE: sacctmgr list associations not responding\n" |
| slow_kill $my_pid |
| incr exit_code 1 |
| } |
| eof { |
| wait |
| } |
| } |
| |
| if {$matches != 3} { |
| send_user "\nFAILURE: Account modification 3 incorrect with only $matches.\n" |
| incr exit_code 1 |
| } |
| |
| # Next, test change the limits of the users |
| # cluster account name part wadmin wdacct wdwckey qos fairshare grpcpumin grpcpu grpjob grpnode grpsubmit grpwall maxcpumin maxcpu maxjob maxnode maxsubmit maxwall admin dacct dwckey |
| |
| incr exit_code [mod_user "$tc1,$tc2" "" "$tu1,$tu2,$tu3" "" "" "" "" "" $fs2 "" "" "" "" "" "" "" "" $mc2 "" $mj2 $mn2 "" $mw2 "" "" "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| # |
| # Use sacctmgr to list the test user modifications |
| # |
| set matches 0 |
| set my_pid [spawn $sacctmgr -n -p list assoc users=$tu1,$tu2,$tu3 format="User,Cluster,Fairshare,Maxcpum,MaxJ,MaxN,MaxW"] |
| expect { |
| -re "There was a problem" { |
| send_user "FAILURE: there was a problem with the sacctmgr command\n" |
| incr exit_code 1 |
| } |
| -re "(($tu1|$tu2|$tu3).($tc1|$tc2).$fs2.$mc2.$mj2.$mn2.$mw2.)" { |
| incr matches |
| exp_continue |
| } |
| timeout { |
| send_user "\nFAILURE: sacctmgr list associations not responding\n" |
| slow_kill $my_pid |
| incr exit_code 1 |
| } |
| eof { |
| wait |
| } |
| } |
| |
| if {$matches != 18} { |
| send_user "\nFAILURE: User modification 18 incorrect with only $matches.\n" |
| incr exit_code 1 |
| } |
| |
| # Next, test change the limits of two users |
| # adminlevel defaultaccount fs maxcpu maxjob maxnodes maxwall waccounts wcluster wnames |
| |
| incr exit_code [mod_user "$tc1,$tc2,$tc3" "" "$tu1,$tu3" "" "" "" "" "" $fs3 "" "" "" "" "" "" "" "" $mc3 "" $mj3 $mn3 "" $mw3 "" "" "" ""] |
| if { $exit_code } { |
| remove_user "" "" "$tu1,$tu2,$tu3" |
| remove_acct "" "$ta1,$ta2,$ta3" |
| remove_cluster "$tc1,$tc2,$tc3" |
| exit $exit_code |
| } |
| |
| # |
| # Use sacctmgr to list the test user modifications |
| # |
| set matches 0 |
| set my_pid [eval spawn $sacctmgr -n -p list assoc user=$tu1,$tu2,$tu3 format="User,Cluster,Fairshare,Maxcpum,MaxJ,MaxN,MaxW"] |
| expect { |
| -re "There was a problem" { |
| send_user "FAILURE: there was a problem with the sacctmgr command\n" |
| incr exit_code 1 |
| } |
| # Any time you use () around something you need to combine all |
| # those things together since you can miss some and they be thrown away |
| -re "(($tu1|$tu3).($tc1|$tc2).$fs3.$mc3.$mj3.$mn3.$mw3.|$tu2.($tc1|$tc2).$fs2.$mc2.$mj2.$mn2.$mw2.)" { |
| incr matches |
| exp_continue |
| } |
| timeout { |
| send_user "\nFAILURE: sacctmgr list associations not responding\n" |
| slow_kill $my_pid |
| incr exit_code 1 |
| } |
| eof { |
| wait |
| } |
| } |
| |
| if {$matches != 18} { |
| send_user "\nFAILURE: User modification 18 incorrect with $matches.\n" |
| incr exit_code 1 |
| } |
| |
| # This is the end below here |
| |
| incr exit_code [remove_user "" "" "$tu1,$tu2,$tu3"] |
| incr exit_code [remove_acct "" "$ta1,$ta2,$ta3"] |
| incr exit_code [remove_cluster "$tc1,$tc2,$tc3"] |
| |
| if {$exit_code == 0} { |
| print_success $test_id |
| } else { |
| send_user "\nFAILURE\n" |
| } |
| exit $exit_code |
| |