|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/expect |
| 2 |
############################################################################ |
| 3 |
# Purpose: Test of SLURM functionality |
| 4 |
# Validate that the scontrol requeuehold option requeues a |
| 5 |
# job back to pending state and puts it on hold. |
| 6 |
# |
| 7 |
# |
| 8 |
# Output: "TEST: #.#" followed by "SUCCESS" if test was successful, OR |
| 9 |
# "FAILURE: ..." otherwise with an explanation of the failure, OR |
| 10 |
# anything else indicates a failure mode that must be investigated. |
| 11 |
############################################################################ |
| 12 |
# Copyright (C) 2013 SchedMD LLC |
| 13 |
# Written by Nathan Yee <nyee32@schedmd.com> |
| 14 |
# |
| 15 |
# This file is part of SLURM, a resource management program. |
| 16 |
# For details, see <http://slurm.schedmd.com/>. |
| 17 |
# Please also read the included file: DISCLAIMER. |
| 18 |
# |
| 19 |
# SLURM is free software; you can redistribute it and/or modify it under |
| 20 |
# the terms of the GNU General Public License as published by the Free |
| 21 |
# Software Foundation; either version 2 of the License, or (at your option) |
| 22 |
# any later version. |
| 23 |
# |
| 24 |
# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY |
| 25 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 26 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 27 |
# details. |
| 28 |
# |
| 29 |
# You should have received a copy of the GNU General Public License along |
| 30 |
# with SLURM; if not, write to the Free Software Foundation, Inc., |
| 31 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 32 |
############################################################################ |
| 33 |
source ./globals |
| 34 |
|
| 35 |
set test_id "2.22" |
| 36 |
set script "test$test_id.bash" |
| 37 |
set job_id 0 |
| 38 |
set exit_code 0 |
| 39 |
|
| 40 |
print_header $test_id |
| 41 |
|
| 42 |
# Remove any vestigial scripts |
| 43 |
exec $bin_rm -f $script |
| 44 |
|
| 45 |
make_bash_script $script " |
| 46 |
sleep 20 |
| 47 |
" |
| 48 |
|
| 49 |
proc check_hold { job } { |
| 50 |
|
| 51 |
global scontrol exit_code |
| 52 |
|
| 53 |
set hold 0 |
| 54 |
spawn $scontrol show job $job |
| 55 |
expect { |
| 56 |
-re "Priority=0" { |
| 57 |
set hold 1 |
| 58 |
exp_continue |
| 59 |
} |
| 60 |
timeout { |
| 61 |
send_user "\nFAILURE scontrol is not responding\n" |
| 62 |
set exit_code 1 |
| 63 |
} |
| 64 |
eof { |
| 65 |
wait |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
if { $hold != 1 } { |
| 70 |
send_user "\nFAILURE scontrol did not hold job after it was requeued\n" |
| 71 |
set exit_code 1 |
| 72 |
} |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
proc check_release { job } { |
| 77 |
|
| 78 |
global scontrol number exit_code |
| 79 |
|
| 80 |
set priority 0 |
| 81 |
spawn $scontrol show job $job |
| 82 |
expect { |
| 83 |
-re "Priority=($number)" { |
| 84 |
set priority $expect_out(1,string) |
| 85 |
exp_continue |
| 86 |
} |
| 87 |
timeout { |
| 88 |
send_user "\nFAILURE: scontrol is not responding\n" |
| 89 |
set exit_code 1 |
| 90 |
} |
| 91 |
eof { |
| 92 |
wait |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
if { $priority == 0 } { |
| 97 |
send_user "\nFAILURE: priority was not set to a non zero value after it was released\n" |
| 98 |
set exit_code 1 |
| 99 |
} |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
proc check_state { job } { |
| 104 |
|
| 105 |
global scontrol exit_code |
| 106 |
|
| 107 |
set job_state 0 |
| 108 |
spawn $scontrol show job $job |
| 109 |
expect { |
| 110 |
-re "JobState=PENDING" { |
| 111 |
set job_state 1 |
| 112 |
exp_continue |
| 113 |
} |
| 114 |
timeout { |
| 115 |
send_user "\nFAILURE: scontrol is not responding\n" |
| 116 |
set exit_code 0 |
| 117 |
} |
| 118 |
eof { |
| 119 |
wait |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
if {$job_state != 1} { |
| 124 |
send_user "\nFAILURE: Job $job state was not PENDING after it was requeued\n" |
| 125 |
set exit_code 1 |
| 126 |
} |
| 127 |
|
| 128 |
} |
| 129 |
|
| 130 |
spawn $sbatch -N1 -t1 -o /dev/null -e /dev/null $script |
| 131 |
expect { |
| 132 |
-re "Submitted batch job ($number)" { |
| 133 |
set job_id $expect_out(1,string) |
| 134 |
exp_continue |
| 135 |
} |
| 136 |
timeout { |
| 137 |
send_user "\nFAILURE sbatch is not responding\n" |
| 138 |
set exit_code 1 |
| 139 |
} |
| 140 |
eof { |
| 141 |
wait |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
if {$job_id == 0} { |
| 146 |
send_user "\nFAILURE: sbatch did not submit job\n" |
| 147 |
set exit_code 1 |
| 148 |
} |
| 149 |
|
| 150 |
wait_for_job $job_id DONE |
| 151 |
|
| 152 |
spawn $scontrol requeuehold $job_id |
| 153 |
expect { |
| 154 |
timeout { |
| 155 |
send_user "\nFAILURE scontrol is not responding\n" |
| 156 |
set exit_code 1 |
| 157 |
} |
| 158 |
eof { |
| 159 |
wait |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
# Check if the job is in hold |
| 164 |
check_hold $job_id |
| 165 |
|
| 166 |
# Check that the job state is pending after released |
| 167 |
check_state $job_id |
| 168 |
|
| 169 |
spawn $scontrol release $job_id |
| 170 |
expect { |
| 171 |
timeout { |
| 172 |
send_user "\nFAILURE: scontrol is not responding\n" |
| 173 |
set exit_code 1 |
| 174 |
} |
| 175 |
eof { |
| 176 |
wait |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
check_release $job_id |
| 181 |
|
| 182 |
cancel_job $job_id |
| 183 |
|
| 184 |
if {$exit_code == 0} { |
| 185 |
send_user "\nSUCCESS\n" |
| 186 |
exec $bin_rm $script |
| 187 |
} |
| 188 |
|
| 189 |
exit $exit_code |