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
|
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Basic sattach functionality test (--layout, --verbose, --label
# and --output-filter options).
############################################################################
# Copyright (C) 2002-2006 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_prog "$test_name.prog"
set job_id 0
set matches 0
if {[get_config_param "LaunchType"] ne "launch/slurm"} {
skip "This test is only compatible with systems using launch/slurm"
}
proc cleanup {} {
global job_id file_prog
cancel_job $job_id
file delete $file_prog
}
set node_cnt 1-4
set task_cnt 4
#
# Delete left-over program and rebuild it
#
exec $bin_cc -O -o $file_prog ${file_prog}.c
exec $bin_chmod 700 $file_prog
#
# Spawn initial program via srun
#
set timeout $max_job_delay
spawn $salloc -N $node_cnt -t2 $srun -n $task_cnt --overcommit ./$file_prog
set init_id $spawn_id
expect {
-i $init_id
-re "Granted job allocation ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
-re "WAITING" {
incr matches
if {$matches != $task_cnt} {
exp_continue
}
}
timeout {
fail "salloc not responding"
}
eof {
wait
}
}
if {$job_id == 0} {
fail "Job submit failure"
}
if {$matches != $task_cnt} {
fail "Job run time failure"
}
# Wait for startup to complete (including RESPONSE_LAUNCH_TASKS message to srun)
# before attempting to attach
sleep 0.1
#
# Get task layout information
#
set matches 0
spawn $sattach --layout $job_id.0
set attach_id $spawn_id
expect {
-i $attach_id
-re "($number) tasks, ($number) nodes" {
incr matches
exp_continue
}
timeout {
fail "sattach not responding"
}
eof {
wait
}
}
if {$matches == 0} {
fail "Layout information not printed"
}
#
# Attach to initial program, just get one tasks output
#
set matches 0
set timeout 10
set attach_pid [spawn $sattach -l --output-filter=[expr $task_cnt - 1] $job_id.0]
set attach_id $spawn_id
expect {
-i $attach_id
-re "($number): WAITING" {
if {$expect_out(1,string) != [expr $task_cnt - 1]} {
fail "Output filtering by task failed"
} else {
incr matches
exec $bin_kill -KILL $attach_pid
}
exp_continue
}
timeout {
fail "sattach not responding"
}
eof {
wait
}
}
if {$matches == 0} {
fail "Failed to filter task output"
}
#
# Attach to initial program
#
set matches 0
set timeout 10
spawn $sattach -vv -l $job_id.0
set attach_id $spawn_id
expect {
-i $attach_id
-re "verbose *: 2" {
incr matches
exp_continue
}
-re "($number): WAITING" {
incr matches
if {$matches == [expr $task_cnt + 1]} {
send -i $attach_id "exit\r"
}
exp_continue
}
timeout {
fail "sattach not responding"
}
eof {
wait
}
}
if {$matches != [expr $task_cnt + 1]} {
fail "Job run time failure ($matches != [expr $task_cnt + 1])"
}
#
# Make sure initial program terminates too
#
# Explicitly reset spawn_id for wait call
set spawn_id $init_id
expect {
timeout {
fail "srun not terminating"
}
eof {
wait
}
}
|