#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # sacctmgr list accounts # # 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 # 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 test_id "21.12" set exit_code 0 set almatches 0 set aclmatches 0 set damatches 0 set dcmatches 0 # Test Cluster # set tc1 "test$test_id-cluster-1" set tc2 "test$test_id-cluster-2" # Cluster Limits array set cluster {} set cluster(Fairshare) 2500 set cluster(MaxCPUs) 1000000 set cluster(MaxJobs) 50 set cluster(MaxNodes) 300 set cluster(MaxWall) 01:00:00 # Test Accounts # 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(MaxCPUs) 1000000 set acct(MaxJobs) 50 set acct(MaxNodes) 300 set acct(MaxWall) 01:00:00 set acct(DefaultQos) "normal" set acct(Organization) "Account_Org_A1" set acct(Description) "Test_Account_A1" set access_err 0 set timeout 60 print_header $test_id if { [test_account_storage] == 0 } { send_user "\nWARNING: This test can't be run without a usable AccountStorageType\n" exit 0 } # # Verify if Administrator privileges # 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 set admin=admin.\n" exit 0 } # # Add test cluster # add_cluster "$tc1,$tc2" [array get cluster] if {$access_err != 0} { send_user "\nWARNING: not authorized to perform this test\n" exit $exit_code } if { ![check_acct_associations] } { send_user "\nFAILURE: Our associations don't line up\n" set exit_code 1 } # # Add a 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 send_user "\nFAILURE: $ta1 account erroneously added to $tc2\n" exp_continue } -re "$tc2.$ta2" { exp_continue send_user "\nFAILURE: $ta2 account erroneously added to $tc2\n" set exit_code 1 } timeout { send_user "\nFAILURE: sacctmgr list associations not responding\n" slow_kill $as_list_pid set exit_code 1 } eof { wait } } if {$almatches != 2} { send_user "\nFAILURE: Added associations not found.\n" send_user "\n Need 2 matches and got $almatches instead.\n" set exit_code 1 } if { ![check_acct_associations] } { send_user "\nFAILURE: Our associations don't line up\n" set exit_code 1 } # # Use sacctmgr to list the test accounts # set ac_list_pid [spawn $sacctmgr -p -n list account] expect { -nocase -re "$ta1.$acct(Description).$acct(Organization)" { incr aclmatches exp_continue } -nocase -re "$ta2.$acct(Description).$acct(Organization)" { incr aclmatches exp_continue } timeout { send_user "\nFAILURE: sacctmgr list associations not responding\n" slow_kill $ac_list_pid set exit_code 1 } eof { wait } } if {$aclmatches != 2} { send_user "\nFAILURE: Added account incorrect.\n" send_user "\n Need 2 matches and got $aclmatches instead.\n" 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 { send_user "\nFAILURE: sacctmgr delete not responding\n" slow_kill $sadel_pid set exit_code 1 } eof { wait } } if {$damatches != 1} { send_user "\nFAILURE: sacctmgr had a problem deleting cluster got $damatches\n" set exit_code 1 } if { ![check_acct_associations] } { send_user "\nFAILURE: Our associations don't line up\n" 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 { send_user "\nFAILURE: sacctmgr delete not responding\n" slow_kill $sadel_pid set exit_code 1 } eof { wait } } if {$dcmatches != 1} { send_user "\nFAILURE: sacctmgr had a problem deleting cluster got $dcmatches\n" set exit_code 1 } # # Use sacctmgr to list the test associations # set as2_list_pid [spawn $sacctmgr list associations cluster=$tc1 ] expect { -re "$tc1 *$ta1" { exp_continue send_user "\nFAILURE: test associations still exist.\n" set exit_code 1 } -re "$tc1 *$ta2" { exp_continue send_user "\nFAILURE: test associations still exist.\n" set exit_code 1 } timeout { send_user "\nTest associations delete verified.\n" slow_kill $as2_list_pid } eof { wait } } if { ![check_acct_associations] } { send_user "\nFAILURE: Our associations don't line up\n" set exit_code 1 } if {$exit_code == 0} { print_success $test_id } else { send_user "\nFAILURE\n" } exit $exit_code