1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
|
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Test squeue filtering (--jobs, --nodelist, --states, --steps and
# --user options).
############################################################################
# Copyright (C) 2002 The Regents of the University of California.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Morris Jette <jette1@llnl.gov>
# CODE-OCEC-09-009. All rights reserved.
#
# This file is part of Slurm, a resource management program.
# For details, see <https://slurm.schedmd.com/>.
# 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 file_in "$test_dir/input"
set job_id1 0
set job_id2 0
set step_id 0
set job_name1 "$test_name.job1"
set job_name2 "$test_name.job2"
set node_cnt 1-1
if {[param_contains [get_config_param "JobSubmitPlugins"] "all_partitions"]} {
skip "This test is incompatible with JobSubmitPlugins=all_partitions"
}
proc cleanup {} {
global job_id1 job_id2
cancel_job [list $job_id1 $job_id2]
}
#
# Build input script file
#
make_bash_script $file_in "$srun $bin_sleep $max_job_delay"
#
# Submit a couple of jobs so we have something to look at
#
set job_id1 [submit_job -fail "-N$node_cnt -J$job_name1 --output=/dev/null --error=/dev/null -t5 $file_in"]
set job_id2 [submit_job -fail "-N$node_cnt -J$job_name2 --output=/dev/null --error=/dev/null --hold -t5 $file_in"]
#
# Check the squeue job filter option
#
set job_found 0
spawn $squeue --format=%i --jobs $job_id2
expect {
-re "($number)" {
set tmp_id $expect_out(1,string)
if {$tmp_id == $job_id2} {
set job_found 1
} else {
fail "squeue reported invalid job_id"
}
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
subtest {$job_found != 0} "Check the squeue job filter option" "squeue failed to locate desired job"
#
# Check the squeue state filter option
#
spawn $squeue --format=%t --noheader --states=PD
expect {
-re "($re_word_str)" {
subtest {$expect_out(1,string) eq "PD"} "Check the squeue state filter option"
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
#
# Check the squeue user filter option with name
#
set this_user [get_my_user_name]
spawn $squeue --format=%u --noheader --user=$this_user
expect {
-re "($re_word_str)" {
subtest {$expect_out(1,string) eq $this_user} "Check the squeue user filter option with name"
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
#
# Check the squeue user filter option with id
#
set this_uid [get_my_uid]
spawn $squeue --format=%u --noheader --user=$this_uid
expect {
-re "($re_word_str)" {
subtest {$expect_out(1,string) eq $this_user} "Check the squeue user filter option with id"
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
#
# Check the squeue node filter option
#
set match 0
spawn $squeue --format=%u --noheader --user=$this_uid --nodelist=dummy_name
expect {
-re "Invalid node name dummy_name" {
log_debug "No worries. This error is expected"
incr match
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
subtest {$match == 1} "Check the squeue node filter option"
# The node filtering really only works if the job has begun execution
set node_name_set 0
spawn $squeue --format=%N --noheader --jobs=$job_id1 --states=RUNNING
expect {
-re "($re_word_str)" {
set node_name $expect_out(1,string)
set node_name_set 1
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
if {$node_name_set == 1} {
spawn $squeue --format=%u --noheader --user=$this_uid --nodelist=$node_name
expect {
-re "($re_word_str)" {
set node_name_set 0
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
}
subtest {$node_name_set != 1} "Check squeue node name filtering"
#
# Check the squeue partition filter option
#
# First get partition name(s)
set partition1 ""
set partition2 ""
spawn $squeue --format=%P --noheader
expect {
-re "($re_word_str)" {
if {$partition1 eq ""} {
set partition1 $expect_out(1,string)
exp_continue
}
if {$expect_out(1,string) eq $partition1} {
set partition2 $expect_out(1,string)
}
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
if {$partition2 eq ""} {
set partition2 $partition1
}
spawn $squeue --format=%P --noheader --partitions=$partition1
expect {
-re "($re_word_str)" {
subtest {$expect_out(1,string) eq $partition1} "Check the squeue partition filter option"
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
#
# Wait long enough to make sure the job step is running and has
# started its job steps. Check the squeue job step filter option
#
wait_for_job -fail $job_id1 "RUNNING"
exec $bin_sleep 10
set job_found 0
spawn $squeue --format=%i --steps $job_id1.$step_id
expect {
-re "($number)\\.($number)" {
set tmp_id $expect_out(1,string)
if {$tmp_id == $job_id1} {
set job_found 1
} else {
fail "squeue reported invalid job_step_id"
}
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
subtest {$job_found != 0} "Check the squeue job step filter option" "squeue failed to locate desired job step"
#
# Filters the name associated with the job
#
set job_found 0
spawn $squeue --format=%i --name $job_name1
expect {
-re "($number)" {
set tmp_id $expect_out(1,string)
if {$tmp_id == $job_id1} {
set job_found 1
} else {
fail "squeue reported unexpected job_id ($tmp_id != $job_id1)"
}
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
subtest {$job_found != 0} "squeue filters the name associated with job1" "squeue failed to locate job1"
set job_found 0
spawn $squeue --format=%i --name $job_name2
expect {
-re "($number)" {
set tmp_id $expect_out(1,string)
if {$tmp_id == $job_id2} {
set job_found 1
} else {
fail "squeue reported unexpected job_id ($tmp_id != $job_id2)"
}
exp_continue
}
timeout {
fail "squeue not responding"
}
eof {
wait
}
}
subtest {$job_found != 0} "squeue filters the name associated with job2" "squeue failed to locate job2"
|