1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# sacctmgr modify account, descriptions, limits
############################################################################
# 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 <https://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
source ./globals_accounting
set tc1 "${test_name}-cluster-1"
set tc2 "${test_name}-cluster-2"
set ta1 "${test_name}-account.1"
set ta2 "${test_name}-account.2"
set ta3 "${test_name}-account.3"
set access_err 0
# Account
array set acct_req {}
set acct_req(cluster) $tc1,$tc2
# Modify Account
array set acct_mod_desc {}
array set acct_mod_acct_vals {
description slurmtestaccount2
organization accountorg2
}
array set acct_mod_assoc_vals {}
array set acct_mod_desc2 {}
array set acct_mod_acct_vals2 {}
array set acct_mod_assoc_vals2 {
fairshare 1700
maxcpumins 700000
maxjobs 70
maxnodes 700
maxwall 00:07:00
}
array set acct_mod_desc3 {}
array set acct_mod_acct_vals3 {
description slurmtestaccount1
organization accountorg1
}
array set acct_mod_assoc_vals3 {
fairshare -1
maxcpumins -1
maxjobs -1
maxnodes -1
maxwall -1
}
set timeout 60
#
# Check accounting config and bail if not found.
#
if {[get_config_param "AccountingStorageType"] ne "accounting_storage/slurmdbd"} {
skip "This test can't be run without a usable AccountStorageType"
}
#
# Verify if Administrator privileges
#
if {[get_admin_level] ne "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_cluster "$tc1,$tc2"
if {$access_err != 0} {
skip "Not authorized to perform this test"
}
proc cleanup {} {
global tc1 tc2 ta1 ta2 ta3
remove_acct "$tc1,$tc2" "$ta1,$ta2,$ta3"
remove_acct "" "$ta1,$ta2,$ta3"
remove_cluster "$tc1,$tc2"
}
# Add cluster
if [add_cluster "$tc1,$tc2" ""] {
fail "Unable to add clusters ($tc1,$tc2)"
}
# Add accounts
if [add_acct "$ta1,$ta2,$ta3" [array get acct_req]] {
fail "Unable to add accounts ($ta1,$ta2,$ta3)"
}
# OK This is the real test. First test change the desc and org of the accounts
if [mod_acct "$ta1,$ta2,$ta3" [array get acct_mod_desc] [array get acct_mod_assoc_vals] [array get acct_mod_acct_vals]] {
fail "Unable to modify accounts ($ta1,$ta2,$ta3)"
}
#
# Use sacctmgr to list the test account modifications
#
set matches 0
spawn $sacctmgr -n -p list account account=$ta1,$ta2,$ta3 format="Account,Description,Organization"
expect {
-re "There was a problem" {
fail "There was a problem with the sacctmgr command"
}
-re "($ta1|$ta2|$ta3).$acct_mod_acct_vals(description).$acct_mod_acct_vals(organization)." {
incr matches
exp_continue
}
timeout {
fail "sacctmgr list associations not responding"
}
eof {
wait
}
}
if {$matches != 3} {
fail "Account modification 1 incorrect ($matches != 3)"
}
# Next, test change the limits of the accounts
if [mod_acct $ta1 [array get acct_mod_desc2] [array get acct_mod_assoc_vals2] [array get acct_mod_acct_vals2]] {
fail "Unable to modify account ($ta1)"
}
#
# Use sacctmgr to list the test account modifications
#
set matches 0
spawn $sacctmgr -n -p list associations account=$ta1,$ta2,$ta3 format="Account,Cluster,Fairshare,MaxCPUM,MaxJobs,MaxNodes,MaxWall"
expect {
-re "There was a problem" {
fail "There was a problem with the sacctmgr command"
}
-re "($ta1.($tc1|$tc2).$acct_mod_assoc_vals2(fairshare).$acct_mod_assoc_vals2(maxcpumins).$acct_mod_assoc_vals2(maxjobs).$acct_mod_assoc_vals2(maxnodes).$acct_mod_assoc_vals2(maxwall).|($ta2|$ta3).($tc1|$tc2).1)" {
incr matches
exp_continue
}
timeout {
fail "sacctmgr list associations not responding"
}
eof {
wait
}
}
if {$matches != 6} {
fail "Account modification 2 incorrect ($matches != 6)"
}
# Next, test change the desc and limits of the accounts
if [mod_acct $ta1 [array get acct_mod_desc3] [array get acct_mod_assoc_vals3] [array get acct_mod_acct_vals3]] {
fail "Unable to modify account ($ta1)"
}
#
# Use sacctmgr to list the test account modifications
#
set matches 0
eval spawn $sacctmgr -n -p list account withassoc account=$ta1,$ta2,$ta3 format="Account,Description,Organization,Cluster,Fairshare,MaxCPUM,MaxJobs,MaxNodes,MaxWall"
expect {
-re "There was a problem" {
fail "There was a problem with the sacctmgr command"
}
# 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 "($ta1.$acct_mod_acct_vals3(description).$acct_mod_acct_vals3(organization).($tc1|$tc2).1.....|($ta2|$ta3).$acct_mod_acct_vals(description).$acct_mod_acct_vals(organization).($tc1|$tc2).1.....)" {
incr matches
exp_continue
}
timeout {
fail "sacctmgr list associations not responding"
}
eof {
wait
}
}
if {$matches != 6} {
fail "Account modification 6 incorrect ($matches != 6)"
}
|