2
############################################################################
3
# Purpose: Test of SLURM sprio functionality.
5
# sprio all options all arguments
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
############################################################################
38
set file_in "test$test_id.input"
43
# Check accounting config and bail if not found.
45
if { [test_account_storage] == 0 } {
46
send_user "\nWARNING: This test can't be run without a usable AccountStorageType\n"
49
if { [string compare [priority_type] multifactor] } {
50
send_user "\nWARNING: This test can't be run without a usable PriorityType\n"
55
# Build input script file
57
make_bash_script $file_in "$bin_sleep 600"
59
proc def_node_cnt { } {
60
global sinfo alpha_numeric_under number exit_code
63
spawn $sinfo -h -o "name=%20P node_cnt=%D"
65
-re "name=($alpha_numeric_under)\\\* *node_cnt=($number)" {
66
set node_cnt $expect_out(2,string)
70
send_user "\nFAILURE: sbatch not responding\n"
80
################################################################
84
# Purpose: Submit a job
88
################################################################
90
proc sub_job { node_cnt } {
92
global exit_code file_in number sbatch test_id
93
set file_in test${test_id}.input
96
spawn $sbatch --output=/dev/null --error=/dev/null -N $node_cnt --exclusive $file_in
98
-re "Submitted batch job ($number)" {
99
set job_id $expect_out(1,string)
103
send_user "\nFAILURE: sbatch not responding\n"
112
send_user "\nFAILURE: did not get sbatch job_id\n"
118
################################################################
122
# Purpose: Pass sprio options and test
124
# Returns: Number of matches.
126
# Input: Switch options not requiring arguments
128
################################################################
130
proc sprio_opt { soption } {
131
global number sprio exit_code
135
send_user "$sprio $soption \n"
137
############# sprio help option
138
if { $soption == "--help" } {
140
spawn $sprio $soption
142
-re "SLURM accounting storage is disabled" {
146
-re "noheader.*jobs.*long.*norm.*format.*user.*verbose.*version.*weights" {
147
if {$debug} {send_user "\nmatch1\n"}
151
-re "Help options:" {
152
if {$debug} {send_user "\nmatch2\n"}
156
-re "help *show this help message" {
157
if {$debug} {send_user "\nmatch3\n"}
161
-re "usage *display a brief summary of sprio options" {
162
if {$debug} {send_user "\nmatch4\n"}
167
send_user "\nFAILURE: sprio not responding\n"
175
if {$not_support == 1} {
176
send_user "\nWARNING: can not test without accounting enabled\n"
181
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
187
############# sprio usage option
188
if { $soption == "--usage" } {
190
spawn $sprio $soption job sizes
192
-re "SLURM accounting storage is disabled" {
196
-re "Usage: sprio .-j jid.s.. .-u user_name.s.. .-o format. .--usage. .-hlnvVw." {
197
if {$debug} {send_user "\nmatch5\n"}
202
send_user "\nFAILURE: sprio not responding\n"
210
if {$not_support == 1} {
211
send_user "\nWARNING: can not test without accounting enabled\n"
215
send_user "\nFAILURE: sprio -$soption failed ($matches)\n"
221
############# sprio version options
222
if { $soption == "--version" || $soption == "-V" } {
224
spawn $sprio $soption
226
-re "SLURM accounting storage is disabled" {
230
-re "slurm $number.$number.$number" {
231
if {$debug} {send_user "\nmatch6\n"}
236
send_user "\nFAILURE: sprio not responding\n"
244
if {$not_support == 1} {
245
send_user "\nWARNING: can not test without accounting enabled\n"
250
send_user "\nFAILURE: sprio -$soption failed ($matches)\n"
256
############# sprio weights options
257
if { $soption == "--weights" || $soption == "-w" } {
259
spawn $sprio $soption
261
-re "SLURM accounting storage is disabled" {
265
-re "JOBID *PRIORITY" {
266
if {$debug} {send_user "\nmatch7\n"}
271
if {$debug} {send_user "\nmatch8\n"}
276
send_user "\nFAILURE: sprio not responding\n"
284
if {$not_support == 1} {
285
send_user "\nWARNING: can not test without accounting enabled\n"
290
send_user "\nFAILURE: sprio -$soption failed ($matches)\n"
297
################################################################
301
# Purpose: Pass sprio options, arguments and test
303
# Returns: Number of matches.
305
# Input: Switch options requiring arguments
307
################################################################
309
proc sprio_args { soption sargs jobid} {
310
global number float sprio exit_code
314
send_user "$sprio $soption $sargs $jobid\n"
316
############# sprio noheader options
317
if { $soption == "--noheader" || $soption == "-h" } {
319
spawn $sprio $soption $sargs $jobid
321
-re "SLURM accounting storage is disabled" {
325
-re "JOBID|PRIORITY|AGE|FAIRSHARE|JOBSIZE|PARTITION|QOS" {
326
if {$debug} {send_user "\nmatch9\n"}
331
send_user "\nFAILURE: sprio not responding\n"
339
if {$not_support == 1} {
340
send_user "\nWARNING: can not test without accounting enabled\n"
344
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
350
############# sprio jobs options
351
if { $soption == "--jobs" || $soption == "-j" } {
353
spawn $sprio $soption $jobid
355
-re "SLURM accounting storage is disabled" {
359
-re "JOBID.*PRIORITY" {
360
if {$debug} {send_user "\nmatch10\n"}
364
-re "$jobid *$number" {
365
if {$debug} {send_user "\nmatch11\n"}
370
send_user "\nFAILURE: sprio not responding\n"
378
if {$not_support == 1} {
379
send_user "\nWARNING: can not test without accounting enabled\n"
383
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
389
############# sprio long options
390
if { $soption == "--long" || $soption == "-l" } {
392
spawn $sprio $soption $sargs $jobid
394
-re "SLURM accounting storage is disabled" {
398
-re "JOBID USER PRIORITY AGE FAIRSHARE JOBSIZE PARTITION QOS NICE" {
399
if {$debug} {send_user "\nmatch12\n"}
403
-re "$jobid.*$number *$number *$number *$number *$number *$number *$number" {
404
if {$debug} {send_user "\nmatch13\n"}
409
send_user "\nFAILURE: sprio not responding\n"
417
if {$not_support == 1} {
418
send_user "\nWARNING: can not test without accounting enabled\n"
422
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
428
############# sprio norm options
429
if { $soption == "--norm" || $soption == "-n" } {
431
spawn $sprio $soption $sargs $jobid
433
-re "SLURM accounting storage is disabled" {
437
-re "JOBID *PRIORITY" {
438
if {$debug} {send_user "\nmatch14\n"}
442
-re "$jobid *$float" {
443
if {$debug} {send_user "\nmatch15\n"}
448
send_user "\nFAILURE: sprio not responding\n"
456
if {$not_support == 1} {
457
send_user "\nWARNING: can not test without accounting enabled\n"
461
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
467
############# sprio format options
468
if { $soption == "--format" || $soption == "-o" } {
470
spawn $sprio $soption "%.7i %.8u %.10y %.10Y %.10a %.10A %.10f %.10F %.10j %.10J %.10p %.10P %.10q %.10Q %.6N" $sargs $jobid
472
-re "SLURM accounting storage is disabled" {
476
-re "JOBID USER PRIORITY PRIORITY AGE AGE " {
477
if {$debug} {send_user "\nmatch16\n"}
481
-re "FAIRSHARE FAIRSHARE JOBSIZE JOBSIZE PARTITION PARTITION QOS QOS NICE" {
482
if {$debug} {send_user "\nmatch17\n"}
486
-re "$jobid *.* *$float *$number *$float *$number *$float *$number *$float *$number *$float *$number *$float *$number *$number" {
487
if {$debug} {send_user "\nmatch18\n"}
492
send_user "\nFAILURE: sprio not responding\n"
500
if {$not_support == 1} {
501
send_user "\nWARNING: can not test without accounting enabled\n"
505
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
511
############# sprio u option
512
if { $soption == "-u" } {
514
spawn $sprio $soption $sargs
516
-re "SLURM accounting storage is disabled" {
521
if {$debug} {send_user "\nmatch19\n"}
525
-re "$jobid *$sargs" {
526
if {$debug} {send_user "\nmatch20\n"}
531
send_user "\nFAILURE: sprio not responding\n"
539
if {$not_support == 1} {
540
send_user "\nWARNING: can not test without accounting enabled\n"
544
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
550
############# sprio usage option
551
if { $soption == "--user=" } {
553
spawn $sprio $soption$sargs
555
-re "SLURM accounting storage is disabled" {
560
if {$debug} {send_user "\nmatch21\n"}
564
-re "$jobid *$sargs" {
565
if {$debug} {send_user "\nmatch22\n"}
570
send_user "\nFAILURE: sprio not responding\n"
578
if {$not_support == 1} {
579
send_user "\nWARNING: can not test without accounting enabled\n"
583
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
589
############# sprio verbose options
590
if { $soption == "--verbose" || $soption == "-v" } {
592
spawn $sprio $soption $sargs $jobid
594
-re "SLURM accounting storage is disabled" {
598
-re "format.*job_flag.*jobs.*$jobid.*verbose" {
599
if {$debug} {send_user "\nmatch23\n"}
603
-re "JOBID *PRIORITY" {
604
if {$debug} {send_user "\nmatch24\n"}
608
-re "$jobid *$number *$number" {
609
if {$debug} {send_user "\nmatch25\n"}
614
send_user "\nFAILURE: sprio not responding\n"
622
if {$not_support == 1} {
623
send_user "\nWARNING: can not test without accounting enabled\n"
627
send_user "\nFAILURE: sprio $soption failed ($matches)\n"
635
################################################################
636
# Start a group of jobs
638
set node_cnt [def_node_cnt]
639
set jobid1 [sub_job $node_cnt]
640
set jobid2 [sub_job $node_cnt]
641
if {$exit_code != 0} {
646
send_user "\nSubmitted 2 jobs successfully\n\n"
651
set nuid [get_my_nuid]
654
# Start testing sprio options and arguments
656
sprio_args -h -j $jobid2
657
sprio_args --noheader -j $jobid2
658
sprio_args -j -j $jobid2
659
sprio_args --jobs -j $jobid2
660
sprio_args -l -j $jobid2
661
sprio_args --long -j $jobid2
662
sprio_args -n -j $jobid2
663
sprio_args --norm -j $jobid2
664
sprio_args -o -j $jobid2
665
sprio_args --format -j $jobid2
666
sprio_args -u $nuid $jobid2
667
sprio_args --user= $nuid $jobid2
668
sprio_args -v -j $jobid2
669
sprio_args -verbose -j $jobid2
684
# Exit with code as appropriate
686
if {$exit_code == 0} {
687
exec $bin_rm -f $file_in
688
send_user "\nSUCCESS\n"