diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am index 5825adff87b82d1c77af87129aca86434ac38f28..a8e133394bd92e82d4e1ba1b2a44a483109f4d3d 100644 --- a/testsuite/expect/Makefile.am +++ b/testsuite/expect/Makefile.am @@ -327,6 +327,7 @@ EXTRA_DIST = \ test24.1 \ test24.1.prog.c \ test24.2 \ + test25.1 \ usleep distclean-local: diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in index de5b11925a115034226eeb41870d4ee0b2f59b7b..ab59b71c6ec96bea173f1b1b6f141cbcfeb0406d 100644 --- a/testsuite/expect/Makefile.in +++ b/testsuite/expect/Makefile.in @@ -571,6 +571,7 @@ EXTRA_DIST = \ test24.1 \ test24.1.prog.c \ test24.2 \ + test25.1 \ usleep all: all-am diff --git a/testsuite/expect/README b/testsuite/expect/README index 1c4c2793a971e82701fda84af7e39cdd9a81f5d1..d13ee304c40359c8353f84b50e305a5fd3d93179 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -531,7 +531,7 @@ test22.# Testing of sreport commands and options. These also test the sacctmgr archive dump/load functions. ================================================= test22.1 sreport cluster utilization report -test22.2 sreport h, n, p, P, v, V options +test22.2 sreport h, n, p, P, t, V options test23.# Testing of sstat commands and options. ================================================= @@ -543,3 +543,7 @@ test24.# Testing of sshare/priority multifactor plugin. ================================================= test24.1 multifactor plugin algo test test24.2 sshare h, n, p, P, v, and V options. + +test25.# Testing of sprio command and options. +================================================= +test25.1 sprio all options diff --git a/testsuite/expect/globals b/testsuite/expect/globals index 509ab214e2b36807b0fe473ab3569db7643c2f97..9612cfda6135594c6dec6736b97349d63edefbe1 100755 --- a/testsuite/expect/globals +++ b/testsuite/expect/globals @@ -255,6 +255,38 @@ proc slow_kill { pid } { return 0 } +################################################################ +# +# Proc: get_my_nuid +# +# Purpose: gets the name uid from the running user +# +# Returns: A non-zero return code indicates a failure. +# +# +################################################################ + +proc get_my_nuid { } { + global bin_id alpha alpha_numeric + + set uid -1 + + log_user 0 + spawn $bin_id -nu + expect { + -re "($alpha_numeric|$alpha)" { + set nuid $expect_out(1,string) + exp_continue + } + eof { + wait + } + } + log_user 1 + + return $nuid +} + ################################################################ # # Proc: get_my_uid diff --git a/testsuite/expect/test25.1 b/testsuite/expect/test25.1 new file mode 100755 index 0000000000000000000000000000000000000000..e5191784143913f31af2319c77b872ee495ddb12 --- /dev/null +++ b/testsuite/expect/test25.1 @@ -0,0 +1,772 @@ +#!/usr/bin/expect +############################################################################ +# Purpose: Test of SLURM sprio functionality. +# +# sprio all options all arguments +# +# 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 "25.1" +set exit_code 0 +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 +} + +################################################################ +# +# Proc: sub_job +# +# Purpose: Submit a job +# +# Returns: Job ID +# +################################################################ + +proc sub_job {} { + + global number sbatch + set file_in test25.1.input + +# +# Build input script file +# +make_bash_script $file_in " +$sbatch sleep 5m +wait + +" + +# +# Spawn 5 jobs via sbatch using this account +# +set job_id 0 + + +spawn $sbatch $file_in +expect { + -re "Submitted batch job ($number)" { + set job_id $expect_out(1,string) + send_user "\nFOUND JobID to be $job_id\n" + exp_continue + } + timeout { + send_user "\nFAILURE: sbatch not responding\n" + set exit_code 1 + } + eof { + wait + } +} + +if {$job_id == 0} { + send_user "\nFAILURE: did not get sbatch job_id\n" + exit 1 +} +return $job_id +} + +################################################################ +# +# Proc: sprio_opt +# +# Purpose: Pass sprio options and test +# +# Returns: Number of matches. +# +# Input: Switch options not requiring arguments +# +################################################################ + +proc sprio_opt { soption } { + global number sprio + set debug 0 + set exit_code 0 + set matches 0 + set not_support 0 + send_user "$sprio -$soption \n" + +############# + if { $soption == "-help" } { + + spawn $sprio -$soption + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "noheader.*jobs.*long.*norm.*format.*user.*verbose.*version.*weights" { + if {$debug} {send_user "\nmatch1\n"} + incr matches + exp_continue + } + -re "Help options:" { + if {$debug} {send_user "\nmatch2\n"} + incr matches + exp_continue + } + -re "help *show this help message" { + if {$debug} {send_user "\nmatch3\n"} + incr matches + exp_continue + } + -re "usage *display a brief summary of sprio options" { + if {$debug} {send_user "\nmatch3\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + + if {$matches != 4} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches +} + +############# + if { $soption == "-usage" } { + + spawn $sprio -$soption job sizes + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "Usage: sprio .-j jid.s.. .-u user_name.s.. .-o format. .--usage. .-hlnvVw." { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 1} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches +} + +############# + if { $soption == "-version" || $soption == "V" } { + + spawn $sprio -$soption + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "slurm $number.$number.$number" { + if {$debug} {send_user "\nmatch9\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + + if {$matches != 1} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-weights" || $soption == "w" } { + + spawn $sprio -$soption + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID PRIORITY AGE FAIRSHARE JOBSIZE PARTITION" { + if {$debug} {send_user "\nmatch9\n"} + incr matches + exp_continue + } + -re "Weights.*$number *$number *$number *$number" { + if {$debug} {send_user "\nmatch9\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + + if {$matches != 2} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } +} + +################################################################ +# +# Proc: sprio_args +# +# Purpose: Pass sprio options, arguments and test +# +# Returns: Number of matches. +# +# Input: Switch options requiring arguments +# +################################################################ + +proc sprio_args { soption sargs jobid} { + global number float sprio + set debug 0 + set exit_code 0 + set matches 0 + set not_support 0 + send_user "$sprio -$soption $sargs $jobid\n" + +############# + if { $soption == "-noheader" || $soption == "h" } { + + spawn $sprio -$soption $sargs $jobid + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID|PRIORITY|AGE|FAIRSHARE|JOBSIZE|PARTITION|QOS" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 0} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-jobs" || $soption == "j" } { + + spawn $sprio -$soption $jobid + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID PRIORITY AGE FAIRSHARE JOBSIZE PARTITION" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid *$number *$number *$number *$number *$number *$number" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 2} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-long" || $soption == "l" } { + + spawn $sprio -$soption $sargs $jobid + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID USER PRIORITY AGE FAIRSHARE JOBSIZE PARTITION QOS NICE" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid.*$number *$number *$number *$number *$number *$number *$number" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 2} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-norm" || $soption == "n" } { + + spawn $sprio -$soption $sargs $jobid + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID PRIORITY AGE FAIRSHARE JOBSIZE PARTITION" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid *$float *$float *$float *$float *$float" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 2} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-format" || $soption == "o" } { + + spawn $sprio -$soption "%.7i %.8u %.10y %.10Y %.10a %.10A %.10f %.10F %.10j %.10J %.10p %.10P %.10q %.10Q %.6N" $sargs $jobid + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID USER PRIORITY PRIORITY AGE AGE " { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "FAIRSHARE FAIRSHARE JOBSIZE JOBSIZE PARTITION PARTITION QOS QOS NICE" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid *.* *$float *$number *$float *$number *$float *$number *$float *$number *$float *$number *$float *$number *$number" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 3} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "u" } { + + spawn $sprio -$soption $sargs + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID *USER *PRIORITY *AGE *FAIRSHARE *JOBSIZE *PARTITION" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid *$sargs.*$number *$number *$number *$number *$number" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 2} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-user=" } { + + spawn $sprio -$soption$sargs + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "JOBID *USER *PRIORITY *AGE *FAIRSHARE *JOBSIZE *PARTITION" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid *$sargs.*$number *$number *$number *$number *$number" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 2} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +############# + if { $soption == "-verbose" || $soption == "v" } { + + spawn $sprio -$soption $sargs $jobid + expect { + -re "SLURM accounting storage is disabled" { + set not_support 1 + exp_continue + } + -re "format.*job_flag.*jobs.*$jobid.*verbose" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "JOBID PRIORITY AGE FAIRSHARE JOBSIZE PARTITION" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } + -re "$jobid *$number *$number *$number *$number *$number" { + if {$debug} {send_user "\nmatch4\n"} + incr matches + exp_continue + } timeout { + send_user "\nFAILURE: sprio not responding\n" + set exit_code 1 + } + eof { + wait + } + } + + if {$not_support == 1} { + send_user "\nWARNING: can not test without accounting enabled\n" + exit 0 + } + if {$matches != 3} { + send_user "\nFAILURE: sprio -$soption failed ($matches)\n" + set exit_code 1 + } + return $matches + } + +} + +################################################################ +# Start a group of jobs + +set jobid1 [sub_job] +set jobid2 [sub_job] +set jobid3 [sub_job] +set jobid4 [sub_job] +set jobid5 [sub_job] + send_user "\nFirst job ID is $jobid1\n" + send_user "\nSecond job ID is $jobid2\n" + send_user "\nThird job ID is $jobid3\n" + send_user "\nFourth job ID is $jobid4\n" + send_user "\nFifth job ID is $jobid5\n" +# +# Collect uid +# +set nuid [get_my_nuid] + +# +# Start testing sprio options and arguments +# +set matches [sprio_args h -j $jobid5] +if {$matches != 0} { + send_user "\nFAILURE: sprio -h failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -noheader -j $jobid5] +if {$matches != 0} { + send_user "\nFAILURE: sprio --noheader failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args j j $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio -j failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -jobs j $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio --jobs failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args l -j $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio -l failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -long -j $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio --long failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args n -j $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio -n failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -norm -j $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio -n failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args o -j $jobid5] +if {$matches != 3} { + send_user "\nFAILURE: sprio -o failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -format -j $jobid5] +if {$matches != 3} { + send_user "\nFAILURE: sprio --format failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args u $nuid $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio -u failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -user= $nuid $jobid5] +if {$matches != 2} { + send_user "\nFAILURE: sprio --user failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args v -j $jobid5] +if {$matches != 3} { + send_user "\nFAILURE: sprio -v failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_args -verbose -j $jobid5] +if {$matches != 3} { + send_user "\nFAILURE: sprio --verbose failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_opt V] +if {$matches != 1} { + send_user "\nFAILURE: sprio -V failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_opt -version] +if {$matches != 1} { + send_user "\nFAILURE: sprio --version failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_opt w] +if {$matches != 2} { + send_user "\nFAILURE: sprio -w failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_opt -weights] +if {$matches != 2} { + send_user "\nFAILURE: sprio --weights failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_opt -help] +if {$matches != 4} { + send_user "\nFAILURE: sprio --help failed ($matches)\n" + set exit_code 1 +} + +set matches [sprio_opt -usage] +if {$matches != 1} { + send_user "\nFAILURE: sprio --usage failed ($matches)\n" + set exit_code 1 +} + +cancel_job $jobid1 +cancel_job $jobid2 +cancel_job $jobid3 +cancel_job $jobid4 +cancel_job $jobid5 + +if {$exit_code == 0} { + send_user "\nSUCCESS\n" +} else { + send_user "\nFAILURE\n" +} +exit $exit_code