2
############################################################################
3
# Purpose: Test of SLURM functionality
4
# sacctmgr +=, -= modify QoS test
7
# Output: "TEST: #.#" followed by "SUCCESS" if test was successful, OR
8
# "FAILURE: ..." otherwise with an explanation of the failure, OR
9
# anything else indicates a failure mode that must be investigated.
10
############################################################################
11
# Copyright (C) 2009 Lawrence Livermore National Security.
12
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
13
# Written by Joseph Donaghy <donaghy1@llnl.gov>
14
# CODE-OCEC-09-009. All rights reserved.
16
# This file is part of SLURM, a resource management program.
17
# For details, see <https://computing.llnl.gov/linux/slurm/>.
18
# Please also read the included file: DISCLAIMER.
20
# SLURM is free software; you can redistribute it and/or modify it under
21
# the terms of the GNU General Public License as published by the Free
22
# Software Foundation; either version 2 of the License, or (at your option)
25
# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
26
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
30
# You should have received a copy of the GNU General Public License along
31
# with SLURM; if not, write to the Free Software Foundation, Inc.,
32
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33
############################################################################
34
source ./globals_accounting
36
set test_id "test21.26"
38
set cluster1 qclustest
39
set account1 qacctest1
40
set account2 qacctest2
50
# Check accounting config and bail if not found
52
if { [test_account_storage] == 0 } {
53
send_user "\nWARNING: This test can't be run without a usable AccountStorageType\n"
58
#make sure we have permission to do this work
60
if { [string compare [check_accounting_admin_level] "Administrator"] } {
61
send_user "\nWARNING: This test can't be run without being an Accounting administrator.\nUse sacctmgr mod user \$USER_NAME admin=admin.\n"
66
# remove test associations to make sure we have a clean system
68
remove_user "" "" "$user1"
69
remove_acct "" "$account1,$account2"
71
remove_cluster "$cluster1"
72
if {$access_err != 0} {
73
send_user "\nWARNING: not authorized to perform this test\n"
77
# Build test associations
78
#=====Done Cleaning System=========Begin Add Cluster======
80
incr exit_code [add_cluster "$cluster1" " " "" "" "" "" "" "" "" "" "" "" ""]
82
remove_user "" "" "$user1"
83
remove_acct "" "$account1,$account2"
85
remove_cluster "$cluster1"
88
#=====Done Add Cluster========Begin Add QoS==========
90
incr exit_code [add_qos "$qos1"]
92
remove_user "" "" "$user1"
93
remove_acct "" "$account1,$account2"
95
remove_cluster "$cluster1"
98
#====Done Add QoS===========Begin Add First Account========
100
incr exit_code [add_acct "$cluster1" "" "$account1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
102
remove_user "" "" "$user1"
103
remove_acct "" "$account1,$account2"
105
remove_cluster "$cluster1"
108
#====Done Add First Account====Begin Add Second Account====
110
incr exit_code [add_acct "$cluster1" "$account1" "$account2" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
112
remove_user "" "" "$user1"
113
remove_acct "" "$account1,$account2"
115
remove_cluster "$cluster1"
118
#=====Done Add Second Account========Begin Add User=========
120
incr exit_code [add_user "$cluster1" "$account1,$account2" "$user1" "" "" "$account1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
122
remove_user "" "" "$user1"
123
remove_acct "" "$account1,$account2"
125
remove_cluster "$cluster1"
128
#====Done add user====Done building test associations===Begin test section=======
130
#======Verify initial associations=============
132
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
134
-re "There was a problem" {
135
send_user "FAILURE: there was a problem with the sacctmgr command\n"
138
-re "\n.root.(|root)." {
142
-re "\n.$account1.(|$user1)." {
146
-re "\n.$account2.(|$user1)." {
151
send_user "\nFAILURE: sacctmgr list associations not responding\n"
161
send_user "\nFAILURE: Initial sacctmgr add failed with ($matches)\n"
162
remove_user "" "" "$user1"
163
remove_acct "" "$account1,$account2"
165
remove_cluster "$cluster1"
169
#======Begin Modification to Add $qos1 to $account1=======
170
#modify test1 account to add test QoS
171
incr exit_code [mod_acct "$cluster1" "" "$account1" "" "" "+$qos1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
173
remove_user "" "" "$user1"
174
remove_acct "" "$account1,$account2"
176
remove_cluster "$cluster1"
180
#=======Done Modifying Account=======Next is Verify=======
182
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
185
-re "There was a problem" {
186
send_user "FAILURE: there was a problem with the sacctmgr command\n"
189
-re "\n.root.(|root)." {
193
-re "$qos1.$account1.(|$user1)." {
197
-re "$qos1.$account2.(|$user1)." {
202
send_user "\nFAILURE: sacctmgr list associations not responding\n"
212
send_user "\nFAILURE: failed on verify of +$qos1 to account $account1 ($matches)\n"
213
remove_user "" "" "$user1"
214
remove_acct "" "$account1,$account2"
216
remove_cluster "$cluster1"
220
#======Begin Modification to Subtract $qos1 from $account2=======
221
#modify test2 account to remove test QoS
222
incr exit_code [mod_acct "$cluster1" "" "$account2" "" "" "-$qos1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
224
remove_user "" "" "$user1"
225
remove_acct "" "$account1,$account2"
227
remove_cluster "$cluster1"
231
#=======Done Modifying Account=======Next is Verify=======
233
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
235
-re "There was a problem" {
236
send_user "FAILURE: there was a problem with the sacctmgr command\n"
239
-re "\n.root.(|root)." {
243
-re "$qos1.$account1.(|$user1)." {
247
-re "\n.$account2.(|$user1)." {
252
send_user "\nFAILURE: sacctmgr list associations not responding\n"
262
send_user "\nFAILURE: verify of -$qos1 from account $account2 ($matches)\n"
263
remove_user "" "" "$user1"
264
remove_acct "" "$account1,$account2"
266
remove_cluster "$cluster1"
271
#======Begin Modification to Subtract $qos1 from $account1=======
272
#modify test1 account to remove test QoS
273
incr exit_code [mod_acct "$cluster1" "" "$account1" "" "" "-$qos1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
275
remove_user "" "" "$user1"
276
remove_acct "" "$account1,$account2"
278
remove_cluster "$cluster1"
282
#=======Done Modifying Account=======Next is Verify=======
284
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
286
-re "There was a problem" {
287
send_user "FAILURE: there was a problem with the sacctmgr command\n"
290
-re "\n.root.(|root)." {
294
-re "\n.$account1.(|$user1)." {
298
-re "\n.$account2.(|$user1)." {
303
send_user "\nFAILURE: sacctmgr list associations not responding\n"
313
send_user "\nFAILURE: verify of -$qos1 from account $account1 ($matches)\n"
314
remove_user "" "" "$user1"
315
remove_acct "" "$account1,$account2"
317
remove_cluster "$cluster1"
321
#=====Begin Modification to Add $qos1 from $account2=======
322
#modify test2 account to add test QoS
323
incr exit_code [mod_acct "$cluster1" "" "$account2" "" "" "+$qos1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
325
remove_user "" "" "$user1"
326
remove_acct "" "$account1,$account2"
328
remove_cluster "$cluster1"
332
#=======Done Modifying Account=======Next is Verify=======
334
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
337
-re "There was a problem" {
338
send_user "FAILURE: there was a problem with the sacctmgr command\n"
341
-re "\n.root.(|root)." {
345
-re "\n.$account1.(|$user1)." {
349
-re "$qos1.$account2.(|$user1)." {
354
send_user "\nFAILURE: sacctmgr list associations not responding\n"
364
send_user "\nFAILURE: failed on verify of +$qos1 to account $account2 ($matches)\n"
365
remove_user "" "" "$user1"
366
remove_acct "" "$account1,$account2"
368
remove_cluster "$cluster1"
372
#=======Begin Modification to Add $qos1 from $account2=======
373
#modify root account to add test QoS
374
incr exit_code [mod_acct "$cluster1" "" "root" "" "" "+$qos1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
376
remove_user "" "" "$user1"
377
remove_acct "" "$account1,$account2"
379
remove_cluster "$cluster1"
383
#=======Done Modifying Account=======Next Is Verify=======
385
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
388
-re "There was a problem" {
389
send_user "FAILURE: there was a problem with the sacctmgr command\n"
392
-re "$qos1.root.(|root)." {
396
-re "\n.$account1.(|$user1)." {
400
-re "$qos1.$account2.(|$user1)." {
405
send_user "\nFAILURE: sacctmgr list associations not responding\n"
415
send_user "\nFAILURE: failed on verify of +$qos1 to account root ($matches)\n"
416
remove_user "" "" "$user1"
417
remove_acct "" "$account1,$account2"
419
remove_cluster "$cluster1"
423
#======Begin Modification to Add $qos1 from $account2=======
424
#modify test2 account to remove test QoS
425
incr exit_code [mod_acct "$cluster1" "" "$account2" "" "" "-$qos1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""]
427
remove_user "" "" "$user1"
428
remove_acct "" "$account1,$account2"
430
remove_cluster "$cluster1"
434
#=======Done Modifying Account=======Next is Verify=======
436
set my_pid [eval spawn $sacctmgr list assoc cluster=$cluster1 format=qos,acct,user -p]
439
-re "There was a problem" {
440
send_user "FAILURE: there was a problem with the sacctmgr command\n"
443
-re "$qos1.root.(|root)." {
447
-re "\n.$account1.(|$user1)." {
451
-re "\n.$account2.(|$user1)." {
456
send_user "\nFAILURE: sacctmgr list associations not responding\n"
466
send_user "\nFAILURE: failed on verify of -$qos1 to account $account2 ($matches)\n"
467
remove_user "" "" "$user1"
468
remove_acct "" "$account1,$account2"
470
remove_cluster "$cluster1"
475
#======Done With List====== Ending=======
476
# This is the end below here
478
incr exit_code [remove_user "" "" "$user1"]
479
incr exit_code [remove_acct "" "$account1,$account2"]
480
incr exit_code [remove_qos "$qos1"]
481
incr exit_code [remove_cluster "$cluster1"]
483
if {$exit_code == 0} {
484
send_user "\nSUCCESS: $test_id\n"
486
send_user "\nFAILURE: $test_id\n"