blob: 7c6b8bfe18076b13f1587978e96477ed913434c9 [file] [log] [blame]
#!/usr/bin/expect
############################################################################
# Purpose: Test of SLURM functionality
# Tests #SLURM entry functionality in a batch script.
#
# 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) 2005-2006 The Regents of the University of California.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Danny Auble <da@llnl.gov>
# UCRL-CODE-226842.
#
# This file is part of SLURM, a resource management program.
# For details, see <http://www.llnl.gov/linux/slurm/>.
#
# 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 "1.47"
set exit_code 0
set file_in "test$test_id.input"
set file_out "test$test_id.output"
set job_acct "TEST_ACCT"
set job_name "TEST_NAME"
set delay 1
print_header $test_id
make_bash_script $file_in "
#SLURM --job-name=$job_name
#SLURM --account=$job_acct
$bin_sleep $delay
"
set timeout $max_job_delay
set job_id 0
set srun_pid [spawn $srun -o $file_out -b $file_in]
expect {
-re "jobid ($number) submitted" {
set job_id $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
set exit_code 1
exp_continue
}
eof {
wait
}
}
if {$job_id == 0} {
send_user "\nFAILURE: batch submit failure\n"
exit 1
}
set matches 0
spawn $scontrol show job $job_id
expect {
-re "Name=$job_name" {
incr matches
exp_continue
}
-re "Account=$job_acct" {
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: scontrol not responding\n"
set exit_code 1
exp_continue
}
eof {
wait
}
}
if {$matches != 2} {
send_user "\nFAILURE: did not set job name and account from batch script\n"
set exit_code 1
}
#
# Build input script file
# NOTE: The initial sleep is so that all of the submissions have time
# to occur before contending with a multitude of job step creations.
# This is especially important on very slow systems (e.g. AIX).
#
make_bash_script $file_in "
#SLURM -N1000000k
$bin_sleep $delay
"
set matches 0
set srun_pid [spawn $srun -o $file_out -b $file_in]
expect {
-re "More .* requested than permitted" {
send_user "This error was expected, no worries\n\n"
incr matches
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
set exit_code 1
}
eof {
wait
}
}
if {$matches != 1} {
send_user "\nFAILURE: srun didn't read the correct options from batch file\n"
set exit_code 1
}
make_bash_script $file_in "
#SLURM -N650000
$bin_sleep $delay
"
set srun_pid [spawn $srun -N1 -o $file_out -b $file_in]
expect {
-re "More nodes requested than permitted" {
send_user "\nFAILURE: srun read from the batch file options"
send_user "over writing the commandline options\n"
set exit_code 1
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
set exit_code 1
}
eof {
wait
}
}
#
# Post-processing
#
if {$exit_code == 0} {
exec $bin_rm -f $file_in $file_out
send_user "\nSUCCESS\n"
}
exit $exit_code