Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
b998c002
Commit
b998c002
authored
16 years ago
by
Joseph P. Donaghy
Browse files
Options
Downloads
Patches
Plain Diff
Update to include options b, g, j, l, n, p, u, v.
parent
51a9daf5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testsuite/expect/test12.4
+572
-17
572 additions, 17 deletions
testsuite/expect/test12.4
with
572 additions
and
17 deletions
testsuite/expect/test12.4
+
572
−
17
View file @
b998c002
#!/usr/bin/expect
############################################################################
# Purpose: Test of SLURM functionality
#
Test
sacct
--brief option
.
# Purpose: Test of SLURM
sacct
functionality
# sacct
options b, g, j, l, n, p, u, v
.
#
# 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
-2009 The
Lawrence Livermore National Security
, LLC
.
# Copyright (C) 2008
Lawrence Livermore National Security.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Joseph Donaghy <donaghy1@llnl.gov>
# LLNL-CODE-402394.
...
...
@@ -33,30 +33,235 @@ source ./globals
set test_id "12.4"
set exit_code 0
set
matches 0
set
not_support 0
set
file_in "test.$test_id.input"
set
test_acct "test_acct"
set timeout 60
print_header $test_id
#
# Check accounting config and bail if not found.
#
if { [test_account_storage] == 0 } {
send_user "\nWARNING: This test can't be run without a usable AccountStorageType\n"
exit 0
}
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_NAME set admin=admin.\n"
exit 0
}
#
# Identify the user and his current default account
#
set acct_name ""
set user_name ""
set user_gid ""
spawn $bin_id -u -n
expect {
-re "($alpha_numeric_under)" {
set user_name $expect_out(1,string)
exp_continue
}
eof {
wait
}
}
spawn $bin_id -u
expect {
-re "($alpha_numeric_under)" {
set user_gid $expect_out(1,string)
exp_continue
}
eof {
wait
}
}
set s_pid [spawn $sacctmgr show user $user_name]
expect {
-re "$user_name *($alpha_numeric_under)" {
set acct_name $expect_out(1,string)
exp_continue
}
timeout {
send_user "FAILURE: sacctmgr add not responding\n"
slow_kill $s_pid
exit 1
}
eof {
wait
}
}
#
# Use sacctmgr to add an account
#
set aamatches 0
set sadd_pid [spawn $sacctmgr -i add account $test_acct]
expect {
-re "Adding Account" {
incr aamatches
exp_continue
}
-re "Nothing new added" {
send_user "\nWARNING: vestigial account $test_acct found\n"
incr aamatches
exp_continue
}
timeout {
send_user "\nFAILURE: sacctmgr add not responding\n"
slow_kill $sadd_pid
set exit_code 1
}
eof {
wait
}
}
if {$aamatches != 1} {
send_user "\nFAILURE: sacctmgr had a problem adding account.\n"
exit 1
}
#
# Add self to this new account
#
set sadd_pid [spawn $sacctmgr -i create user name=$user_name account=$test_acct]
expect {
timeout {
send_user "\nFAILURE: sacctmgr add not responding\n"
slow_kill $sadd_pid
set exit_code 1
}
eof {
wait
}
}
make_bash_script $file_in "$bin_id"
#
# Spawn a job via srun using this account
#
set job_id 0
spawn $srun -N1 -v --account=$test_acct $bin_id
expect {
-re "launching ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$job_id == 0} {
send_user "\nFAILURE: did not get srun job_id3\n"
set exit_code 1
} else {
set matches 0
spawn $scontrol show job $job_id
expect {
-re "Account=$test_acct" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: scontrol not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$matches != 1} {
send_user "\nFAILURE: srun failed to use specified account\n"
set exit_code 1
}
}
################################################################
#
# Proc: sacct
# Proc: sacct
_job
#
# Purpose:
p
ass sacct options
to one location
# Purpose:
P
ass sacct options
and test
#
# Returns:
The n
umber of matches.
# Returns:
N
umber of matches.
#
# Input:
a s
witch option
# Input:
S
witch option
s not requiring arguments
#
################################################################
proc sacct_job { soption } {
proc sacct_job { soption
job_id
} {
global sacct
set exit_code 0
set matches 0
set not_support 0
send_user "sacct -$soption\n"
spawn $sacct -$soption
send_user "sacct -$soption -j $job_id\n"
if { $soption == "-long" || $soption == "l" } {
spawn $sacct -$soption -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
exp_continue
}
-re "JobID......JobName....Partition..MaxVMSize" {
incr matches
exp_continue
}
-re "MaxVMSizeNode..MaxVMSizeTask..AveVMSize..MaxRSS" {
incr matches
exp_continue
}
-re "MaxRSSNode.MaxRSSTask.AveRSS.....MaxPages" {
incr matches
exp_continue
}
-re "MaxPagesNode.MaxPagesTask...AvePages...MinCPU" {
incr matches
exp_continue
}
-re "MinCPUNode.MinCPUTask.AveCPU.....NTasks" {
incr matches
exp_continue
}
-re "AllocCPUS..Elapsed....State......ExitCode" {
incr matches
exp_continue
}
-re "$job_id" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: sacct not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$not_support != 0} {
send_user "\nWARNING: can not test without accounting enabled\n"
exit 0
}
if {$matches != 7} {
send_user "\nFAILURE: sacct -$soption failed ($matches)\n"
set exit_code 1
}
return $matches
}
if { $soption == "-brief" || $soption == "b" } {
spawn $sacct -$soption -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
...
...
@@ -66,7 +271,43 @@ expect {
incr matches
exp_continue
}
-re "---------- ---------- --------" {
-re "$job_id" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: sacct not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$not_support != 0} {
send_user "\nWARNING: can not test without accounting enabled\n"
exit 0
}
if {$matches != 2} {
send_user "\nFAILURE: sacct -$soption failed ($matches)\n"
set exit_code 1
}
return $matches
}
if { $soption == "-parsable" || $soption == "p" } {
spawn $sacct -$soption -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
exp_continue
}
-re "JobID\\|JobName\\|Partition\\|Account\\|AllocCPUS\\|State\\|ExitCode\\|" {
incr matches
exp_continue
}
-re "$job_id\\|" {
incr matches
exp_continue
}
...
...
@@ -89,20 +330,334 @@ if {$matches != 2} {
}
return $matches
}
if { $soption == "-parsable2" || $soption == "P" } {
spawn $sacct -$soption -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
exp_continue
}
-re
"JobID\\|JobName\\|Partition\\|Account\\|AllocCPUS\\|State\\|ExitCode *" {
incr matches
exp_continue
}
-re "$job_id\\|" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: sacct not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$not_support != 0} {
send_user "\nWARNING: can not test without accounting enabled\n"
exit 0
}
if {$matches != 2} {
send_user "\nFAILURE: sacct -$soption failed ($matches)\n"
set exit_code 1
}
return $matches
}
if { $soption == "-noheader" || $soption == "n" } {
spawn $sacct -$soption -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
exp_continue
}
-re "AllocCPUS|Account|AssocID|AveCPU|AvePages|AveRSS|AveVSize|BlockID \
|Cluster|CPUTime|CPUTimeRAW|Elapsed \
|Eligible|End|ExitCode|GID \
|Group|JobID|JobName|NodeList \
|MaxPages|MaxPagesNode|MaxPagesTask|MaxRSS |
|MaxRSSNode|MaxRSSTask|MaxVSize|MaxVSizeNode |
|MaxVSizeTask|MinCPU|MinCPUNode|MinCPUTask |
|NCPUS|NNodes|NTasks|Priority |
|Partition|QOS|QOSRAW|ReqCPUS |
|Reserved|ResvCPU|ResvCPURAW|Start |
|State|Submit|Suspended|SystemCPU |
|Timelimit|TotalCPU|UID|User |
|UserCPU|WCKey|WCKeyID" {
incr matches
exp_continue
}
-re "$job_id" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: sacct not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$not_support != 0} {
send_user "\nWARNING: can not test without accounting enabled\n"
exit 0
}
if {$matches != 1} {
send_user "\nFAILURE: sacct -$soption failed ($matches)\n"
set exit_code 1
}
return $matches
}
if { $soption == "-verbose" || $soption == "v" } {
spawn $sacct -$soption -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
exp_continue
}
-re "sacct: Accounting storage SLURMDBD plugin loaded " {
incr matches
exp_continue
}
-re "JobID......JobName....Partition" {
incr matches
exp_continue
}
-re "Account....AllocCPUS..State......ExitCode" {
incr matches
exp_continue
}
-re "$job_id" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: sacct not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$not_support != 0} {
send_user "\nWARNING: can not test without accounting enabled\n"
exit 0
}
if {$matches != 4} {
send_user "\nFAILURE: sacct -$soption failed ($matches)\n"
set exit_code 1
}
return $matches
}
}
################################################################
#
# Proc: sacct_vargs
#
# Purpose: Pass sacct options with arguments and test
#
# Returns: Number of matches.
#
# Input: Switch options with argument
#
################################################################
proc sacct_vargs { soption vargs job_id} {
global sacct
set exit_code 0
set matches 0
set not_support 0
send_user "sacct -$soption $vargs -j $job_id\n"
if { $soption == "g" || $soption == "-gid" || $soption == "-group" || $soption == "u" || $soption == "-uid" || $soption == "-user"} {
spawn $sacct -$soption $vargs -j $job_id
expect {
-re "SLURM accounting storage is disabled" {
set not_support 1
exp_continue
}
-re "JobID......JobName....Partition" {
incr matches
exp_continue
}
-re "Account....AllocCPUS..State......ExitCode" {
incr matches
exp_continue
}
-re "$job_id" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: sacct not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$not_support != 0} {
send_user "\nWARNING: can not test without accounting enabled\n"
exit 0
}
if {$matches != 3} {
send_user "\nFAILURE: sacct -$soption failed ($matches)\n"
set exit_code 1
}
return $matches
}
}
################################################################
set matches [sacct_job -brief]
set matches [sacct_job n $job_id]
if {$matches != 1} {
send_user "\nFAILURE: sacct -n failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job -noheader $job_id]
if {$matches != 1} {
send_user "\nFAILURE: sacct -n failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job l $job_id]
if {$matches != 7} {
send_user "\nFAILURE: sacct --allusers failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job -long $job_id]
if {$matches != 7} {
send_user "\nFAILURE: sacct -l failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job b $job_id]
if {$matches != 2} {
send_user "\nFAILURE: sacct -b failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job -brief $job_id]
if {$matches != 2} {
send_user "\nFAILURE: sacct --brief failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job
b
]
set matches [sacct_job
p $job_id
]
if {$matches != 2} {
send_user "\nFAILURE: sacct -b failed ($matches)\n"
send_user "\nFAILURE: sacct -p failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job -parsable $job_id]
if {$matches != 2} {
send_user "\nFAILURE: sacct --parsable failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job P $job_id]
if {$matches != 2} {
send_user "\nFAILURE: sacct -P failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job -parsable2 $job_id]
if {$matches != 2} {
send_user "\nFAILURE: sacct --parsable2 failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job v $job_id]
if {$matches != 4} {
send_user "\nFAILURE: sacct -v failed ($matches)\n"
set exit_code 1
}
set matches [sacct_job -verbose $job_id]
if {$matches != 4} {
send_user "\nFAILURE: sacct --verbosee failed ($matches)\n"
set exit_code 1
}
set matches [sacct_vargs g $user_gid $job_id]
if {$matches != 3} {
send_user "\nFAILURE: sacct -g failed ($matches)\n"
set exit_code 1
}
set matches [sacct_vargs -gid $user_gid $job_id]
if {$matches != 3} {
send_user "\nFAILURE: sacct --gid failed ($matches)\n"
set exit_code 1
}
set matches [sacct_vargs -group $user_gid $job_id]
if {$matches != 3} {
send_user "\nFAILURE: sacct --group failed ($matches)\n"
set exit_code 1
}
set matches [sacct_vargs u $user_name $job_id]
if {$matches != 3} {
send_user "\nFAILURE: sacct -g failed ($matches)\n"
set exit_code 1
}
set matches [sacct_vargs -uid $user_name $job_id]
if {$matches != 3} {
send_user "\nFAILURE: sacct --gid failed ($matches)\n"
set exit_code 1
}
set matches [sacct_vargs -user $user_name $job_id]
if {$matches != 3} {
send_user "\nFAILURE: sacct --group failed ($matches)\n"
set exit_code 1
}
#
# Use sacctmgr to delete the test account
#
set damatches 0
set sadel_pid [spawn $sacctmgr -i delete account $test_acct]
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 account\n"
set exit_code 1
}
if {$exit_code == 0} {
exec $bin_rm -f $file_in
send_user "\nSUCCESS\n"
}
exit $exit_code
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment