blob: a6c77fed54f2f6b48b57a62f248bf7f9153e0dba [file] [log] [blame]
#!/usr/bin/expect
############################################################################
# Purpose: Test of SLURM functionality
# Test of srun task-prolog and task-epilog option.
#
# 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 Morris Jette <jette1@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.49"
set exit_code 0
set cwd "[$bin_pwd]"
set tasks 4
set file_in "$cwd/test$test_id.in"
set task_prolog "$cwd/test$test_id.prolog"
set task_epilog "$cwd/test$test_id.epilog"
set file_out_pre "$cwd/test$test_id.output_pre"
set file_out_post "$cwd/test$test_id.output_post"
print_header $test_id
#
# Delete left-over scripts and rebuild,
# The sleep command just forces slurmd to kill the user's (long running) epilog
#
file delete $task_prolog $task_epilog
file delete $file_out_pre $file_out_post
exec $bin_touch $file_out_pre
exec $bin_touch $file_out_post
make_bash_script $task_prolog "
$bin_id >> $file_out_pre
echo export TEST=prolog_qa
"
make_bash_script $task_epilog "
$bin_id >> $file_out_post
$bin_sleep 200
"
make_bash_script $file_in "
echo TEST==\$TEST
#env
"
#
# Submit a slurm job that will execute $tasks tasks
# Note: If running on more than one node and writing to an
# NFS file, overwritting of data has been observed, this
# causes the test to fail
#
set matches 0
set timeout $max_job_delay
if { [test_bluegene] } {
set node_cnt 1-1024
} else {
set node_cnt 1-1
}
set srun_pid [spawn $srun -N$node_cnt -n$tasks -O -t1 --task-prolog=$task_prolog --task-epilog=$task_epilog $file_in]
expect {
-re "TEST==prolog_qa" {
incr matches
exp_continue
}
-re "error" {
send_user "\nFAILURE: Error running srun\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
}
}
if {$exit_code != 0} {
exit $exit_code
}
if {$matches != $tasks} {
send_user "\nFAILURE: prolog exported env var failure ($matches != $tasks)\n"
set exit_code 1
}
#
# Get my id to compare with output
#
set my_uid -1
spawn $bin_id
expect {
-re "uid=($number)" {
set my_uid $expect_out(1,string)
exp_continue
}
eof {
wait
}
}
#
# Make sure we have two records in both prolog and epilog output (one for each task)
# Wait a few seconds for various delays
#
set matches 0
if {[wait_for_file $file_out_pre] == 0} {
set timeout 5
spawn $bin_cat $file_out_pre
expect {
"uid=$my_uid" {
incr matches
exp_continue
}
eof {
wait
}
}
}
if {$matches != $tasks} {
send_user "\nFAILURE: task prolog output is missing or uid mismatch ($matches:$tasks)\n"
set exit_code 1
}
set matches 0
spawn $bin_cat $file_out_post
expect {
"uid=$my_uid" {
incr matches
exp_continue
}
eof {
wait
}
}
if {$matches != $tasks} {
send_user "\nFAILURE: task epilog output is missing or uid mismatch ($matches:$tasks)\n"
set exit_code 1
}
if {$exit_code == 0} {
exec $bin_rm -f $task_prolog $task_epilog $file_in
exec $bin_rm -f $file_out_pre $file_out_post
send_user "\nSUCCESS\n"
}
exit $exit_code