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 308 309 310 311 312 313 314 315 316 317 318 319 320
|
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Test that job's node estimation is based off the biggest node
# in the partition
############################################################################
# Copyright (C) 2015 SchedMD LLC
# Written by Nathan Yee <nyee32@schedmd.com>
#
# 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 node_list ""
set highest_cpu_cnt 0
set default_part [default_partition]
set script "$test_dir/job_script"
set job_id 0
set node_l ""
set cpu_l_cnt 0
set node_m ""
set cpu_m_cnt 0
set node_h ""
set cpu_h_cnt 0
set test_part "${test_name}_part"
if {![is_super_user]} {
skip "This test can't be run without being a super user of the cluster"
} elseif {[param_contains [get_config_param "SelectTypeParameters"] "CR_ONE_TASK_PER_CORE"]} {
skip "This test is incompatible SelectTypeParameters=CR_ONE_TASK_PER_CORE"
}
proc cleanup {} {
global job_id scontrol test_part
cancel_job $job_id
run_command "$scontrol delete partition=$test_part"
}
proc sub_job {cpu_cnt part} {
global script job_id
set job_id [submit_job -fail "-t1 -H -p$part -n$cpu_cnt -o/dev/null $script"]
}
proc check_node_cnt { exp_nodes } {
global squeue
set match 0
spawn $squeue -h -o%D
expect {
-re "$exp_nodes" {
set match 1
exp_continue
}
timeout {
fail "squeue is not responding"
}
eof {
wait
}
}
subtest {$match} "Job should make proper node estimation" "expected = $exp_nodes"
}
proc update_job { job_id part } {
global scontrol
spawn $scontrol update jobid=$job_id partition=$part
expect {
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
}
proc test_and_check { job_id part exp_nodes } {
update_job $job_id $part
check_node_cnt $exp_nodes
}
make_bash_script $script "sleep 10"
# only works when job is in hold. should also work when jobs are waiting
################## Test with existing default partition ##################
spawn $bin_bash -c "$scontrol show partition $default_part | $bin_grep -w Nodes"
expect {
-re "Nodes=($re_word_str)" {
set node_list $expect_out(1,string)
exp_continue
}
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
set node_cnt 0
spawn $bin_bash -c "$scontrol show nodes $node_list | grep CPUTot"
expect {
-re "CPUTot=($number)" {
incr node_cnt
if { $expect_out(1,string) > $highest_cpu_cnt } {
set highest_cpu_cnt $expect_out(1,string)
}
exp_continue
}
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
# Choose a CPU count equal to the highest CPU node (job should use 1 node)
set cpu_test_cnt $highest_cpu_cnt
sub_job $cpu_test_cnt $default_part
set exp_nodes [expr ($cpu_test_cnt - 1)/$highest_cpu_cnt + 1]
check_node_cnt $exp_nodes
cancel_job $job_id
# Choose a CPU count greater then highest CPU node (job should use 2 nodes)
if {$node_cnt >= 2} {
set cpu_test_cnt [expr $highest_cpu_cnt + 1]
sub_job $cpu_test_cnt $default_part
set exp_nodes [expr ($cpu_test_cnt - 1)/$highest_cpu_cnt + 1]
check_node_cnt $exp_nodes
cancel_job $job_id
}
# Choose a CPU count greater then highest CPU node (job should use 5 nodes)
if {$node_cnt >= 5} {
set cpu_test_cnt [expr $highest_cpu_cnt * 4 + 1]
sub_job $cpu_test_cnt $default_part
set exp_nodes [expr ($cpu_test_cnt - 1)/$highest_cpu_cnt + 1]
check_node_cnt $exp_nodes
cancel_job $job_id
}
################## Test with new partition ##################
# Get the smallest node in the system
log_user 0
set tmp_cnt 99999
set tmp_name ""
set node_name ""
spawn $sinfo -h -o%N=%c -N
expect {
-re "($re_word_str)=($number)" {
if { $expect_out(2,string) < $tmp_cnt } {
set tmp_cnt $expect_out(2,string)
set node_name $expect_out(1,string)
}
exp_continue
}
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
# Set node to node with least CPUs
set node_l $node_name
set cpu_l_cnt $tmp_cnt
set node_m $node_name
set cpu_m_cnt $tmp_cnt
set node_h $node_name
set cpu_h_cnt $tmp_cnt
# Get highest node of different
spawn $sinfo -h -o%N=%c -N
expect {
-re "($re_word_str)=($number)" {
if { $expect_out(2,string) > $cpu_l_cnt &&
$expect_out(2,string) > $cpu_h_cnt } {
set cpu_h_cnt $expect_out(2,string)
set node_h $expect_out(1,string)
}
exp_continue
}
timeout {
fail "sinfo is not responding"
}
eof {
wait
}
}
# Get node between highest and lowest
spawn $sinfo -h -o%N=%c -N
expect {
-re "($re_word_str)=($number)" {
if { $expect_out(2,string) > $cpu_l_cnt &&
$expect_out(2,string) < $cpu_h_cnt } {
set cpu_m_cnt $expect_out(2,string)
set node_m $expect_out(1,string)
}
exp_continue
}
timeout {
fail "sinfo is not responding"
}
eof {
wait
}
}
log_user 1
log_debug "L:$node_l:$cpu_l_cnt M:$node_m:$cpu_m_cnt H:$node_h:$cpu_h_cnt"
if {$cpu_l_cnt == $cpu_h_cnt} {
log_debug "The rest of this test expects to have three different nodes \
each with different cpu counts -- finishing test now."
pass
}
# Create partition with the smallest node in the system
spawn $scontrol create partitionname=$test_part nodes=$node_l
expect {
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
set match 0
spawn $sinfo -h -o%P
expect {
-re "$test_part" {
set match 1
exp_continue
}
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
if {!$match} {
fail "Partition ($test_part) was not created"
}
# Choose a cpu count greater then highest cpu node
set cpu_test_cnt [expr $cpu_l_cnt + $cpu_m_cnt + $cpu_h_cnt]
set exp_nodes [expr ($cpu_test_cnt - 1)/$cpu_l_cnt + 1]
sub_job $cpu_test_cnt $default_part
sleep 4
test_and_check $job_id $test_part $exp_nodes
sleep 4
cancel_job $job_id
# Update the partition with a new node
spawn $scontrol update partitionname=$test_part nodes=$node_l,$node_m
expect {
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
set exp_nodes [expr ($cpu_test_cnt - 1)/$cpu_m_cnt + 1]
sub_job $cpu_test_cnt $default_part
sleep 4
test_and_check $job_id $test_part $exp_nodes
sleep 4
cancel_job $job_id
# Update the partition with a new node
spawn $scontrol update partitionname=$test_part nodes=$node_l,$node_m,$node_h
expect {
timeout {
fail "scontrol is not responding"
}
eof {
wait
}
}
set exp_nodes [expr ($cpu_test_cnt - 1)/$cpu_h_cnt + 1]
sub_job $cpu_test_cnt $default_part
sleep 4
test_and_check $job_id $test_part $exp_nodes
|