From 6a2f20c47bf59c9313f844aceec61faad4ffd602 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Fri, 25 Jun 2010 19:14:15 +0000 Subject: [PATCH] fixed and removed tests --- testsuite/expect/Makefile.am | 1 - testsuite/expect/Makefile.in | 1 - testsuite/expect/test23.1 | 219 ++++------- testsuite/expect/test23.2 | 669 ++++++++++++++++++++++++++++++-- testsuite/expect/test23.3 | 713 ----------------------------------- 5 files changed, 707 insertions(+), 896 deletions(-) delete mode 100755 testsuite/expect/test23.3 diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am index eb02f79b32e..f53bda4d80a 100644 --- a/testsuite/expect/Makefile.am +++ b/testsuite/expect/Makefile.am @@ -332,7 +332,6 @@ EXTRA_DIST = \ test22.2 \ test23.1 \ test23.2 \ - test23.3 \ test24.1 \ test24.1.prog.c \ test24.2 \ diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in index a6f110dfe69..d0cc1b777f6 100644 --- a/testsuite/expect/Makefile.in +++ b/testsuite/expect/Makefile.in @@ -601,7 +601,6 @@ EXTRA_DIST = \ test22.2 \ test23.1 \ test23.2 \ - test23.3 \ test24.1 \ test24.1.prog.c \ test24.2 \ diff --git a/testsuite/expect/test23.1 b/testsuite/expect/test23.1 index 3b5492c69cd..822501d20c6 100755 --- a/testsuite/expect/test23.1 +++ b/testsuite/expect/test23.1 @@ -59,197 +59,136 @@ proc sstat_job { soption } { set not_support 0 send_user "sstat -$soption \n" - if { $soption == "e" || $soption == "-helpformat" } { - - spawn $sstat -$soption - expect { - -re "AveCPU *AvePages *AveRSS *AveVMSize" { - if {$debug} {send_user "\nmatch1\n"} - incr matches - exp_continue - } - -re "JobID *MaxPages *MaxPagesNode *MaxPagesTask" { - if {$debug} {send_user "\nmatch2\n"} - incr matches - exp_continue - } - -re "MaxRSS *MaxRSSNode *MaxRSSTask *MaxVMSize" { - if {$debug} {send_user "\nmatch3\n"} - incr matches - exp_continue - } - -re "MaxVMSizeNode *MaxVMSizeTask *MinCPU *MinCPUNode" { - if {$debug} {send_user "\nmatch4\n"} - incr matches - exp_continue - } - -re "MinCPUTask *NTasks" { - if {$debug} {send_user "\nmatch5\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat not responding\n" - set exit_code 1 - } - eof { - wait - } - } - - if {$matches != 5} { - send_user "\nFAILURE: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches - } - if { $soption == "h" || $soption == "-help" } { - spawn $sstat -$soption - expect { - -re "sstat...OPTION" { - if {$debug} {send_user "\nmatch6\n"} - incr matches - exp_continue - } - -re "Valid..OPTION" { - if {$debug} {send_user "\nmatch7\n"} - incr matches - exp_continue - } - -re "-e, --helpformat" { - if {$debug} {send_user "\nmatch8\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat not responding\n" + spawn $sstat -$soption + expect { + -re "sstat...OPTION" { + if {$debug} {send_user "\nmatch6\n"} + incr matches + exp_continue + } + -re "Valid..OPTION" { + if {$debug} {send_user "\nmatch7\n"} + incr matches + exp_continue + } + -re "-e, --helpformat" { + if {$debug} {send_user "\nmatch8\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$matches != 3} { + send_user "\nFAILURE: sstat -$soption failed ($matches)\n" set exit_code 1 } - eof { - wait - } - } - - if {$matches != 3} { - send_user "\nFAILURE: sstat -$soption failed ($matches)\n" - set exit_code 1 - } return $matches } if { $soption == "-usage" } { - spawn $sstat -$soption - expect { - -re "Usage: sstat .options. -j .job..stepid." { - if {$debug} {send_user "\nmatch9\n"} - incr matches - exp_continue - } - -re "Use --help for help" { - if {$debug} {send_user "\nmatch10\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat not responding\n" + spawn $sstat -$soption + expect { + -re "Usage: sstat .options. -j .job..stepid." { + if {$debug} {send_user "\nmatch9\n"} + incr matches + exp_continue + } + -re "Use --help for help" { + if {$debug} {send_user "\nmatch10\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$matches != 2} { + send_user "\nFAILURE: sstat -$soption failed ($matches)\n" set exit_code 1 } - eof { - wait - } - } - - if {$matches != 2} { - send_user "\nFAILURE: sstat -$soption failed ($matches)\n" - set exit_code 1 - } return $matches } if { $soption == "V" || $soption == "-version" } { - spawn $sstat -$soption - expect { - -re "slurm ($number).($number)." { - if {$debug} {send_user "\nmatch11\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat not responding\n" + spawn $sstat -$soption + expect { + -re "slurm ($number).($number)." { + if {$debug} {send_user "\nmatch11\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$matches != 1} { + send_user "\nFAILURE: sstat -$soption failed ($matches)\n" set exit_code 1 } - eof { - wait - } - } - - if {$matches != 1} { - send_user "\nFAILURE: sstat -$soption failed ($matches)\n" - set exit_code 1 - } return $matches } } ################################################################ -set matches [sstat_job e ] -if {$matches != 5} { - send_user "\nFAILURE: sstat -e failed ($matches)\n" - set exit_code 1 - } else { - send_user "\nsstat -e test GOOD!\n" -} - -set matches [sstat_job -helpformat ] -if {$matches != 5} { - send_user "\nFAILURE: sstat --helpformat failed ($matches)\n" - set exit_code 1 - } else { - send_user "\nsstat --helpformat test GOOD!\n" -} - set matches [sstat_job h ] if {$matches != 3} { send_user "\nFAILURE: sstat -h failed ($matches)\n" set exit_code 1 - } else { - send_user "\nsstat -h test GOOD!\n" +} else { + send_user "\nsstat -h test GOOD!\n" } set matches [sstat_job -help ] if {$matches != 3} { send_user "\nFAILURE: sstat --help failed ($matches)\n" set exit_code 1 - } else { - send_user "\nsstat --help test GOOD!\n" +} else { + send_user "\nsstat --help test GOOD!\n" } set matches [sstat_job -usage ] if {$matches != 2} { send_user "\nFAILURE: sstat --usage failed ($matches)\n" set exit_code 1 - } else { - send_user "\nsstat --usage test GOOD!\n" +} else { + send_user "\nsstat --usage test GOOD!\n" } set matches [sstat_job V ] if {$matches != 1} { send_user "\nFAILURE: sstat -V failed ($matches)\n" set exit_code 1 - } else { - send_user "\nsstat -V test GOOD!\n" +} else { + send_user "\nsstat -V test GOOD!\n" } set matches [sstat_job -version ] if {$matches != 1} { send_user "\nFAILURE: sstat --version failed ($matches)\n" set exit_code 1 - } else { - send_user "\nsstat --version test GOOD!\n" +} else { + send_user "\nsstat --version test GOOD!\n" } diff --git a/testsuite/expect/test23.2 b/testsuite/expect/test23.2 index 7c8a493274f..3cb187ad369 100755 --- a/testsuite/expect/test23.2 +++ b/testsuite/expect/test23.2 @@ -1,13 +1,13 @@ #!/usr/bin/expect ############################################################################ -# Purpose: Test of SLURM functionality -# Test sstat --helpformat option. +# Purpose: Test of SLURM sstat functionality +# sstat a, n, o, p, P and v options. # # 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 Lawrence Livermore National Security. +# Copyright (C) 2009 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. @@ -34,80 +34,631 @@ source ./globals set test_id "23.2" set exit_code 0 -set matches 0 -set not_support 0 - +set file_in1 "test.$test_id.input1" +set file_in2 "test.$test_id.input2" +set file_in3 "test.$test_id.input3" +set test_acct "test_acct" +set timeout 60 print_header $test_id +set ac AveCPU +set ap AvePages +set ar AveRSS +set av AveVMSize +set ji JobID +set mp MaxPages +set mpn MaxPagesNode +set mpt MaxPagesTask +set mr MaxRSS +set mrn MaxRSSNode +set mrt MaxRSSTask +set mvs MaxVMSize +set mvn MaxVMSizeNode +set mvt MaxVMSizeTask +set mc MinCPU +set mn MinCPUNode +set mt MinCPUTask +set nt NTasks + # -# Report the sstat --helpformat option +# 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 +} -spawn $sstat --helpformat +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 "AveCPU *AvePages *AveRSS *AveVMSize" { - incr matches + -re "($alpha_numeric_under)" { + set user_name $expect_out(1,string) exp_continue } - -re "JobID *MaxPages *MaxPagesNode *MaxPagesTask" { - incr matches + eof { + wait + } +} + +spawn $bin_id -u +expect { + -re "($alpha_numeric_under)" { + set user_gid $expect_out(1,string) exp_continue } - -re "MaxRSS *MaxRSSNode *MaxRSSTask *MaxVMSize" { - incr matches + 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 } - -re "MaxVMSizeNode *MaxVMSizeTask *MinCPU *MinCPUNode" { - incr matches + 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 "MinCPUTask *NTasks" { - incr matches + -re "Nothing new added" { + send_user "\nWARNING: vestigial account $test_acct found\n" + incr aamatches exp_continue } timeout { - send_user "\nFAILURE: sstat not responding\n" + 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 +} -if {$matches != 5} { - send_user "\nFAILURE: sstat --helpformat failed ($matches)\n" - set exit_code 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 + } } # -# Report the sstat -e option +# Build input script file1 +# +make_bash_script $file_in1 " +$srun $file_in2 + +" + +# +# Build input script file2 +# +make_bash_script $file_in2 " +$srun $file_in3 + +" + +# +# Build input script file3 # -set matches 0 +make_bash_script $file_in3 " +$srun sleep 10 + +" -spawn $sstat -e +# +# Spawn a job via srun using this account +# +set job_id3 0 +spawn $sbatch -N1 -v --account=$test_acct $file_in1 expect { - -re "AveCPU *AvePages *AveRSS *AveVMSize" { - incr matches + -re "Submitted batch job ($number)" { + set job_id3 $expect_out(1,string) + send_user "\nFOUND JobID to be $job_id3\n" exp_continue } - -re "JobID *MaxPages *MaxPagesNode *MaxPagesTask" { - incr matches - exp_continue + timeout { + send_user "\nFAILURE: sbatch not responding\n" + set exit_code 1 } - -re "MaxRSS *MaxRSSNode *MaxRSSTask *MaxVMSize" { - incr matches - exp_continue + eof { + wait } - -re "MaxVMSizeNode *MaxVMSizeTask *MinCPU *MinCPUNode" { - incr matches - exp_continue +} +if {$job_id3 == 0} { + send_user "\nFAILURE: did not get srun job_id3\n" + set exit_code 1 +} else { + set matches 0 + spawn $scontrol show job $job_id3 + 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 + } +} + +# +# Wait for job to start running, then signal it +# +if {[wait_for_job $job_id3 "RUNNING"] != 0} { + send_user "\nFAILURE: waiting for job to start running\n" + exit 1 +} +################################################################ +# +# Proc: sstat_job +# +# Purpose: Pass sstat options and test +# +# Returns: Number of matches. +# +# Input: Switch options not requiring arguments +# +################################################################ + +proc sstat_job { soption job_id} { + global sstat + set debug 0 + set exit_code 0 + set matches 0 + set not_support 0 + send_user "sstat -$soption -p -j $job_id\n" + + if { $soption == "-allsteps" || $soption == "a" } { + + spawn $sstat -$soption -p -j $job_id + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "$job_id.0" { + if {$debug} {send_user "\nmatch1\n"} + incr matches + exp_continue + } + -re "$job_id.1" { + if {$debug} {send_user "\nmatch2\n"} + incr matches + exp_continue + } + -re "$job_id.2" { + if {$debug} {send_user "\nmatch3\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches +} + + if { $soption == "-noheader" || $soption == "n" } { + + spawn $sstat -$soption -p -j $job_id + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JobID|MaxVMSize|MaxVMSizeNode|MaxVMSizeTask| \ + AveVMSize|MaxRSS|MaxRSSNode|MaxRSSTask|AveRSS| \ + MaxPages|MaxPagesNode|MaxPagesTask|AvePages| \ + MinCPU|MinCPUNode|MinCPUTask|AveCPU|NTasks" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$job_id" { + if {$debug} {send_user "\nmatch5\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches +} + + if { $soption == "-parsable" || $soption == "p" } { + + spawn $sstat -$soption -p -j $job_id + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JobID\\|MaxVMSize\\|MaxVMSizeNode\\|MaxVMSizeTask\\|AveVMSize\\|MaxRSS\\|" { + if {$debug} {send_user "\nmatch6\n"} + incr matches + exp_continue + } + -re "MaxRSSNode\\|MaxRSSTask\\|AveRSS\\|MaxPages\\|MaxPagesNode\\|MaxPagesTask\\|" { + if {$debug} {send_user "\nmatch7\n"} + incr matches + exp_continue + } + -re "AvePages\\|MinCPU\\|MinCPUNode\\|MinCPUTask\\|AveCPU\\|NTasks\\|" { + if {$debug} {send_user "\nmatch8\n"} + incr matches + exp_continue + } + -re "$job_id..\\|" { + if {$debug} {send_user "\nmatch9\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches +} + + if { $soption == "-parsable2" || $soption == "P" } { + + spawn $sstat -$soption -j $job_id + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JobID\\|MaxVMSize\\|MaxVMSizeNode\\|MaxVMSizeTask\\|AveVMSize\\|MaxRSS\\|" { + if {$debug} {send_user "\nmatch10\n"} + incr matches + exp_continue + } + -re "MaxRSSNode\\|MaxRSSTask\\|AveRSS\\|MaxPages\\|MaxPagesNode\\|MaxPagesTask\\|" { + if {$debug} {send_user "\nmatch11\n"} + incr matches + exp_continue + } + -re "AvePages\\|MinCPU\\|MinCPUNode\\|MinCPUTask\\|AveCPU\\|NTasks" { + if {$debug} {send_user "\nmatch12\n"} + incr matches + exp_continue + } + -re "$job_id..\\|" { + if {$debug} {send_user "\nmatch13\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat not responding\n" + set exit_code 1 + } + eof { + wait + } } - -re "MinCPUTask *NTasks" { - incr matches + + if {$not_support != 0} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 4} { + send_user "\nFAILURE: sstat -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + + if { $soption == "-verbose" || $soption == "v" } { + + spawn $sstat -$soption -p -j $job_id + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JobID.MaxVMSize.MaxVMSizeNode.MaxVMSizeTask.AveVMSize.MaxRSS" { + if {$debug} {send_user "\nmatch14\n"} + incr matches + exp_continue + } + -re "MaxRSSNode.MaxRSSTask.AveRSS.MaxPages.MaxPagesNode.MaxPagesTask" { + if {$debug} {send_user "\nmatch15\n"} + incr matches + exp_continue + } + -re "AvePages.MinCPU.MinCPUNode.MinCPUTask.AveCPU.NTasks" { + if {$debug} {send_user "\nmatch16\n"} + incr matches + exp_continue + } + -re "$job_id" { + if {$debug} {send_user "\nmatch17\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + + +} + +################################################################ +# +# Proc: sstat_vargs +# +# Purpose: Pass sstat options with arguments and test +# +# Returns: Number of matches. +# +# Input: Switch options with argument +# +################################################################ + +proc sstat_vargs { soption vargs job_id} { + global sstat + set debug 0 + set exit_code 0 + set matches 0 + set not_support 0 + send_user "sstat -$soption $vargs -p -j $job_id\n" + + if { $soption == "o" || $soption == "-format" } { + + spawn $sstat -$soption $vargs -p -j $job_id + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "AveCPU.AvePages.AveRSS.AveVMSize" { + if {$debug} {send_user "\nmatch18\n"} + incr matches + exp_continue + } + -re "JobID.MaxPages.MaxPagesNode.MaxPagesTask" { + if {$debug} {send_user "\nmatch19\n"} + incr matches + exp_continue + } + -re "MaxRSS.MaxRSSNode.MaxRSSTask.MaxVMSize" { + if {$debug} {send_user "\nmatch20\n"} + incr matches + exp_continue + } + -re "MaxVMSizeNode.MaxVMSizeTask.MinCPU.MinCPUNode" { + if {$debug} {send_user "\nmatch21\n"} + incr matches + exp_continue + } + -re "MinCPUTask.NTasks" { + if {$debug} {send_user "\nmatch22\n"} + incr matches + exp_continue + } + -re "$job_id" { + if {$debug} {send_user "\nmatch23\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sstat 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 != 6} { + send_user "\nFAILURE: sstat -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } +} +################################################################ +sleep 1 +set matches [sstat_job a $job_id3] +if {$matches != 3} { + send_user "\nFAILURE: sstat -a failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job -allsteps $job_id3] +if {$matches != 3} { + send_user "\nFAILURE: sstat --allsteps failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job n $job_id3] +if {$matches != 1} { + send_user "\nFAILURE: sstat -n failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job -noheader $job_id3] +if {$matches != 1} { + send_user "\nFAILURE: sstat --noheader failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job p $job_id3] +if {$matches != 4} { + send_user "\nFAILURE: sstat -p failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job -parsable $job_id3] +if {$matches != 4} { + send_user "\nFAILURE: sstat --parsable failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job P $job_id3] +if {$matches != 4} { + send_user "\nFAILURE: sstat -P failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job -parsable2 $job_id3] +if {$matches != 4} { + send_user "\nFAILURE: sstat --parsable2 failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job v $job_id3] +if {$matches != 4} { + send_user "\nFAILURE: sstat -v failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_job -verbose $job_id3] +if {$matches != 4} { + send_user "\nFAILURE: sstat --verbose failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_vargs o $ac,$ap,$ar,$av,$ji,$mp,$mpn,$mpt,$mr,$mrn,$mrt,$mvs,$mvn,$mvt,$mc,$mn,$mt,$nt $job_id3] +if {$matches != 6} { + send_user "\nFAILURE: sstat -o failed ($matches)\n" + set exit_code 1 +} + +set matches [sstat_vargs -format $ac,$ap,$ar,$av,$ji,$mp,$mpn,$mpt,$mr,$mrn,$mrt,$mvs,$mvn,$mvt,$mc,$mn,$mt,$nt $job_id3] +if {$matches != 6} { + send_user "\nFAILURE: sstat --format failed ($matches)\n" + set exit_code 1 +} + + +# +# Use sacctmgr to delete the test account (shouldn't work, because of running jobs) +# +set damatches 0 +set needtodel 0 +set sadel_pid [spawn $sacctmgr -i delete account $test_acct] +expect { + -re "Deleting account" { + incr damatches exp_continue } + "Job(s) running, cancel job(s) before remove" { + send_user "This error was expected, no worries\n" + set needtodel 1 + } + timeout { - send_user "\nFAILURE: sstat not responding\n" + send_user "\nFAILURE: sacctmgr delete not responding\n" + slow_kill $sadel_pid set exit_code 1 } eof { @@ -115,12 +666,48 @@ expect { } } -if {$matches != 5} { - send_user "\nFAILURE: sstat -e failed ($matches)\n" +if {$needtodel == 1} { + # + # Use scancel to quite jobs + # + spawn $scancel -A $test_acct + expect { + eof { + wait + } + } + + sleep 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 problems deleting the account\n" set exit_code 1 } if {$exit_code == 0} { + exec $bin_rm -f $file_in1 $file_in2 $file_in3 send_user "\nSUCCESS\n" } exit $exit_code diff --git a/testsuite/expect/test23.3 b/testsuite/expect/test23.3 deleted file mode 100755 index afca05cd842..00000000000 --- a/testsuite/expect/test23.3 +++ /dev/null @@ -1,713 +0,0 @@ -#!/usr/bin/expect -############################################################################ -# Purpose: Test of SLURM sstat functionality -# sstat a, n, o, p, P and v options. -# -# 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) 2009 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://computing.llnl.gov/linux/slurm/>. -# 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 - -set test_id "23.3" -set exit_code 0 -set file_in1 "test.$test_id.input1" -set file_in2 "test.$test_id.input2" -set file_in3 "test.$test_id.input3" -set test_acct "test_acct" -set timeout 60 -print_header $test_id - -set ac AveCPU -set ap AvePages -set ar AveRSS -set av AveVMSize -set ji JobID -set mp MaxPages -set mpn MaxPagesNode -set mpt MaxPagesTask -set mr MaxRSS -set mrn MaxRSSNode -set mrt MaxRSSTask -set mvs MaxVMSize -set mvn MaxVMSizeNode -set mvt MaxVMSizeTask -set mc MinCPU -set mn MinCPUNode -set mt MinCPUTask -set nt NTasks - -# -# 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 - } -} - -# -# Build input script file1 -# -make_bash_script $file_in1 " -$srun $file_in2 - -" - -# -# Build input script file2 -# -make_bash_script $file_in2 " -$srun $file_in3 - -" - -# -# Build input script file3 -# -make_bash_script $file_in3 " -$srun sleep 10 - -" - -# -# Spawn a job via srun using this account -# -set job_id3 0 -spawn $sbatch -N1 -v --account=$test_acct $file_in1 -expect { - -re "Submitted batch job ($number)" { - set job_id3 $expect_out(1,string) - send_user "\nFOUND JobID to be $job_id3\n" - exp_continue - } - timeout { - send_user "\nFAILURE: sbatch not responding\n" - set exit_code 1 - } - eof { - wait - } -} -if {$job_id3 == 0} { - send_user "\nFAILURE: did not get srun job_id3\n" - set exit_code 1 -} else { - set matches 0 - spawn $scontrol show job $job_id3 - 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 - } -} - -# -# Wait for job to start running, then signal it -# -if {[wait_for_job $job_id3 "RUNNING"] != 0} { - send_user "\nFAILURE: waiting for job to start running\n" - exit 1 -} -################################################################ -# -# Proc: sstat_job -# -# Purpose: Pass sstat options and test -# -# Returns: Number of matches. -# -# Input: Switch options not requiring arguments -# -################################################################ - -proc sstat_job { soption job_id} { - global sstat - set debug 0 - set exit_code 0 - set matches 0 - set not_support 0 - send_user "sstat -$soption -p -j $job_id\n" - - if { $soption == "-allsteps" || $soption == "a" } { - - spawn $sstat -$soption -p -j $job_id - expect { - -re "SLURM accounting storage is disabled" { - set not_support 1 - exp_continue - } - -re "$job_id.0" { - if {$debug} {send_user "\nmatch1\n"} - incr matches - exp_continue - } - -re "$job_id.1" { - if {$debug} {send_user "\nmatch2\n"} - incr matches - exp_continue - } - -re "$job_id.2" { - if {$debug} {send_user "\nmatch3\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches -} - - if { $soption == "-noheader" || $soption == "n" } { - - spawn $sstat -$soption -p -j $job_id - expect { - -re "SLURM accounting storage is disabled" { - set not_support 1 - exp_continue - } - -re "JobID|MaxVMSize|MaxVMSizeNode|MaxVMSizeTask| \ - AveVMSize|MaxRSS|MaxRSSNode|MaxRSSTask|AveRSS| \ - MaxPages|MaxPagesNode|MaxPagesTask|AvePages| \ - MinCPU|MinCPUNode|MinCPUTask|AveCPU|NTasks" { - if {$debug} {send_user "\nmatch4\n"} - incr matches - exp_continue - } - -re "$job_id" { - if {$debug} {send_user "\nmatch5\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches -} - - if { $soption == "-parsable" || $soption == "p" } { - - spawn $sstat -$soption -p -j $job_id - expect { - -re "SLURM accounting storage is disabled" { - set not_support 1 - exp_continue - } - -re "JobID\\|MaxVMSize\\|MaxVMSizeNode\\|MaxVMSizeTask\\|AveVMSize\\|MaxRSS\\|" { - if {$debug} {send_user "\nmatch6\n"} - incr matches - exp_continue - } - -re "MaxRSSNode\\|MaxRSSTask\\|AveRSS\\|MaxPages\\|MaxPagesNode\\|MaxPagesTask\\|" { - if {$debug} {send_user "\nmatch7\n"} - incr matches - exp_continue - } - -re "AvePages\\|MinCPU\\|MinCPUNode\\|MinCPUTask\\|AveCPU\\|NTasks\\|" { - if {$debug} {send_user "\nmatch8\n"} - incr matches - exp_continue - } - -re "$job_id..\\|" { - if {$debug} {send_user "\nmatch9\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches -} - - if { $soption == "-parsable2" || $soption == "P" } { - - spawn $sstat -$soption -j $job_id - expect { - -re "SLURM accounting storage is disabled" { - set not_support 1 - exp_continue - } - -re "JobID\\|MaxVMSize\\|MaxVMSizeNode\\|MaxVMSizeTask\\|AveVMSize\\|MaxRSS\\|" { - if {$debug} {send_user "\nmatch10\n"} - incr matches - exp_continue - } - -re "MaxRSSNode\\|MaxRSSTask\\|AveRSS\\|MaxPages\\|MaxPagesNode\\|MaxPagesTask\\|" { - if {$debug} {send_user "\nmatch11\n"} - incr matches - exp_continue - } - -re "AvePages\\|MinCPU\\|MinCPUNode\\|MinCPUTask\\|AveCPU\\|NTasks" { - if {$debug} {send_user "\nmatch12\n"} - incr matches - exp_continue - } - -re "$job_id..\\|" { - if {$debug} {send_user "\nmatch13\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches - } - - if { $soption == "-verbose" || $soption == "v" } { - - spawn $sstat -$soption -p -j $job_id - expect { - -re "SLURM accounting storage is disabled" { - set not_support 1 - exp_continue - } - -re "JobID.MaxVMSize.MaxVMSizeNode.MaxVMSizeTask.AveVMSize.MaxRSS" { - if {$debug} {send_user "\nmatch14\n"} - incr matches - exp_continue - } - -re "MaxRSSNode.MaxRSSTask.AveRSS.MaxPages.MaxPagesNode.MaxPagesTask" { - if {$debug} {send_user "\nmatch15\n"} - incr matches - exp_continue - } - -re "AvePages.MinCPU.MinCPUNode.MinCPUTask.AveCPU.NTasks" { - if {$debug} {send_user "\nmatch16\n"} - incr matches - exp_continue - } - -re "$job_id" { - if {$debug} {send_user "\nmatch17\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat 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: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches - } - - -} - -################################################################ -# -# Proc: sstat_vargs -# -# Purpose: Pass sstat options with arguments and test -# -# Returns: Number of matches. -# -# Input: Switch options with argument -# -################################################################ - -proc sstat_vargs { soption vargs job_id} { - global sstat - set debug 0 - set exit_code 0 - set matches 0 - set not_support 0 - send_user "sstat -$soption $vargs -p -j $job_id\n" - - if { $soption == "o" || $soption == "-format" } { - - spawn $sstat -$soption $vargs -p -j $job_id - expect { - -re "SLURM accounting storage is disabled" { - set not_support 1 - exp_continue - } - -re "AveCPU.AvePages.AveRSS.AveVMSize" { - if {$debug} {send_user "\nmatch18\n"} - incr matches - exp_continue - } - -re "JobID.MaxPages.MaxPagesNode.MaxPagesTask" { - if {$debug} {send_user "\nmatch19\n"} - incr matches - exp_continue - } - -re "MaxRSS.MaxRSSNode.MaxRSSTask.MaxVMSize" { - if {$debug} {send_user "\nmatch20\n"} - incr matches - exp_continue - } - -re "MaxVMSizeNode.MaxVMSizeTask.MinCPU.MinCPUNode" { - if {$debug} {send_user "\nmatch21\n"} - incr matches - exp_continue - } - -re "MinCPUTask.NTasks" { - if {$debug} {send_user "\nmatch22\n"} - incr matches - exp_continue - } - -re "$job_id" { - if {$debug} {send_user "\nmatch23\n"} - incr matches - exp_continue - } - timeout { - send_user "\nFAILURE: sstat 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 != 6} { - send_user "\nFAILURE: sstat -$soption failed ($matches)\n" - set exit_code 1 - } - return $matches - } -} -################################################################ -sleep 1 -set matches [sstat_job a $job_id3] -if {$matches != 3} { - send_user "\nFAILURE: sstat -a failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job -allsteps $job_id3] -if {$matches != 3} { - send_user "\nFAILURE: sstat --allsteps failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job n $job_id3] -if {$matches != 1} { - send_user "\nFAILURE: sstat -n failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job -noheader $job_id3] -if {$matches != 1} { - send_user "\nFAILURE: sstat --noheader failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job p $job_id3] -if {$matches != 4} { - send_user "\nFAILURE: sstat -p failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job -parsable $job_id3] -if {$matches != 4} { - send_user "\nFAILURE: sstat --parsable failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job P $job_id3] -if {$matches != 4} { - send_user "\nFAILURE: sstat -P failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job -parsable2 $job_id3] -if {$matches != 4} { - send_user "\nFAILURE: sstat --parsable2 failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job v $job_id3] -if {$matches != 4} { - send_user "\nFAILURE: sstat -v failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_job -verbose $job_id3] -if {$matches != 4} { - send_user "\nFAILURE: sstat --verbose failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_vargs o $ac,$ap,$ar,$av,$ji,$mp,$mpn,$mpt,$mr,$mrn,$mrt,$mvs,$mvn,$mvt,$mc,$mn,$mt,$nt $job_id3] -if {$matches != 6} { - send_user "\nFAILURE: sstat -o failed ($matches)\n" - set exit_code 1 -} - -set matches [sstat_vargs -format $ac,$ap,$ar,$av,$ji,$mp,$mpn,$mpt,$mr,$mrn,$mrt,$mvs,$mvn,$mvt,$mc,$mn,$mt,$nt $job_id3] -if {$matches != 6} { - send_user "\nFAILURE: sstat --format failed ($matches)\n" - set exit_code 1 -} - - -# -# Use sacctmgr to delete the test account (shouldn't work, because of running jobs) -# -set damatches 0 -set needtodel 0 -set sadel_pid [spawn $sacctmgr -i delete account $test_acct] -expect { - -re "Deleting account" { - incr damatches - exp_continue - } - "Job(s) running, cancel job(s) before remove" { - send_user "This error was expected, no worries\n" - set needtodel 1 - } - - timeout { - send_user "\nFAILURE: sacctmgr delete not responding\n" - slow_kill $sadel_pid - set exit_code 1 - } - eof { - wait - } -} - -if {$needtodel == 1} { - # - # Use scancel to quite jobs - # - spawn $scancel -A $test_acct - expect { - eof { - wait - } - } - - sleep 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 problems deleting the account\n" - set exit_code 1 -} - -if {$exit_code == 0} { - exec $bin_rm -f $file_in1 $file_in2 $file_in3 - send_user "\nSUCCESS\n" -} -exit $exit_code -- GitLab