#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # sacctmgr add multiple accounts ############################################################################ # Copyright (C) 2008-2010 Lawrence Livermore National Security. # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). # Written by Joseph Donaghy # CODE-OCEC-09-009. All rights reserved. # # This file is part of Slurm, a resource management program. # For details, see . # 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 source ./globals_accounting set exit_code 0 set almatches 0 set damatches 0 set dcmatches 0 # Cluster Names # set tc1 "test$test_id-cluster-1" set tc2 "test$test_id-cluster-2" # Cluster values # array set cluster {} set cluster(Fairshare) 2500 set cluster(MaxCPUs) 100 set cluster(MaxJobs) 50 set cluster(MaxNodes) 300 set cluster(MaxWall) 01:00:00 # Account Name # set ta1 "test$test_id-account.1" set ta2 "test$test_id-account.2" # Account Limits # array set acct {} set acct(Cluster) $tc1 set acct(Fairshare) 2500 set acct(GrpCPUMins) 100 set acct(GrpCPURunMins) 150 set acct(GrpCPUs) 50 set acct(GrpJobs) 100 set acct(GrpMemory) 60 set acct(GrpSubmitJobs) 500 set acct(GrpNodes) 100 set acct(GrpWall) 00:45:00 set acct(MaxCPUMins) 100000 set acct(MaxCPUs) 100 set acct(MaxJobs) 50 set acct(MaxSubmitJobs) 60 set acct(MaxNodes) 300 set acct(MaxWall) 01:00:00 set acct(DefaultQos) "test$test_id\_qos" set acct(Organization) "Account_Org_A1" set acct(Description) "Test_Account_A1" set access_err 0 set timeout 60 if { [test_account_storage] == 0 } { skip "This test can't be run without a usable AccountStorageType" } # # Verify if Administrator privileges # if { [string compare [check_accounting_admin_level] "Administrator"] } { skip "This test can't be run without being an Accounting administrator.\nUse: sacctmgr mod user \$USER set admin=admin" } #make sure we have a clean system and permission to do this work remove_acct "" "$ta1,$ta2" remove_cluster "$tc1,$tc2" if {$access_err != 0} { skip "Not authorized to perform this test" } # # Add test Cluster # add_cluster "$tc1,$tc2" [array get cluster] if {$access_err != 0} { skip "Not authorized to perform this test" } if { ![check_acct_associations] } { log_error "Our associations don't line up" set exit_code 1 } # # Create tmp QOS # set qos_set 0 spawn $sacctmgr -i add qos $acct(DefaultQos) expect { -re "Adding QOS" { set qos_set 1 exp_continue } timeout { log_error "sacctmgr is not responding" set exit_code 1 } eof { wait } } if {$qos_set != 1} { log_error "QOS $acct(DefaultQos) was not created" set exit_code 1 } # # Add test Account # add_acct "$ta1,$ta2" [array get acct] # # Use sacctmgr to list the test associations # set as_list_pid [spawn $sacctmgr -p list associations cluster=$tc1,$tc2] expect { -re "$tc1.$ta1" { incr almatches exp_continue } -re "$tc1.$ta2" { incr almatches exp_continue } -re "$tc2.$ta1" { set exit_code 1 log_error "$ta1 account erroneously added to $tc2" exp_continue } -re "$tc2.$ta2" { exp_continue log_error "$ta2 account erroneously added to $tc2" set exit_code 1 } timeout { log_error "sacctmgr list associations not responding" slow_kill $as_list_pid set exit_code 1 } eof { wait } } if {$almatches != 2} { log_error "Added associations not found. Need 2 matches and got $almatches instead" set exit_code 1 } # Check that the Association was set correctly check_assoc_limit 2 account $ta1 [array get acct] check_assoc_limit 2 account $ta2 [array get acct] if { ![check_acct_associations] } { log_error "Our associations don't line up" set exit_code 1 } # # Use sacctmgr to delete the test account # set sadel_pid [spawn $sacctmgr -i delete account $ta1,$ta2] expect { -re "Deleting account" { incr damatches exp_continue } timeout { log_error "sacctmgr delete not responding" slow_kill $sadel_pid set exit_code 1 } eof { wait } } if {$damatches != 1} { log_error "sacctmgr had a problem deleting cluster got $damatches" set exit_code 1 } if { ![check_acct_associations] } { log_error "Our associations don't line up" set exit_code 1 } # # Use sacctmgr to delete the test cluster # set sadel_pid [spawn $sacctmgr -i delete cluster $tc1,$tc2] expect { -re "Deleting clusters" { incr dcmatches exp_continue } timeout { log_error "sacctmgr delete not responding" slow_kill $sadel_pid set exit_code 1 } eof { wait } } if {$dcmatches != 1} { log_error "sacctmgr had a problem deleting cluster got $dcmatches" set exit_code 1 } # # Delete Qos # set dmatches 0 set sadel_pid [spawn $sacctmgr -i delete qos $acct(DefaultQos)] expect { -re "Deleting QOS" { incr dmatches exp_continue } timeout { log_error "sacctmgr delete not responding" slow_kill $sadel_pid set exit_code 1 } eof { wait } } if {$dmatches != 1} { log_error "sacctmgr had a problem deleting QOS got $dmatches" set exit_code 1 } # # Use sacctmgr to list the test associations # set as2_list_pid [spawn $sacctmgr list association cluster=$tc1 ] expect { -re "$tc1 *$ta1" { exp_continue log_error "Test associations still exist" set exit_code 1 } -re "$tc1 *$ta2" { exp_continue log_error "Test associations still exist" set exit_code 1 } timeout { log_debug "Test associations delete verified" slow_kill $as2_list_pid } eof { wait } } if { ![check_acct_associations] } { fail "Our associations don't line up" } if {$exit_code != 0} { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }