blob: 8f033ed3f7f50910e04c2aab2e9474fac99c4473 [file] [log] [blame]
#!/usr/bin/expect
############################################################################
# Purpose: Test of SLURM functionality
# Test of nice value specification (--nice 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 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.53"
set exit_code 0
set file_in "test$test_id.input"
set job_id1 0
set job_id2 0
set job_id3 0
set job_prio1 0
set job_prio2 0
set job_prio3 0
print_header $test_id
#
# Build input script file
#
make_bash_script $file_in "$bin_sleep 60"
#
# Submit three jobs with differing nice values
#
set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 $file_in]
expect {
-re "jobid ($number) submitted" {
set job_id1 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
exit 1
}
eof {
wait
}
}
if {$job_id1 == 0} {
send_user "\nFAILURE: srun submit failed\n"
exit 1
}
set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 --nice $file_in]
expect {
-re "jobid ($number) submitted" {
set job_id2 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
cancel_job $job_id1
slow_kill $srun_pid
exit 1
}
eof {
wait
}
}
if {$job_id2 == 0} {
send_user "\nFAILURE: srun submit failed\n"
cancel_job $job_id1
exit 1
}
set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 --nice=200 $file_in]
expect {
-re "jobid ($number) submitted" {
set job_id3 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
cancel_job $job_id1
cancel_job $job_id2
slow_kill $srun_pid
exit 1
}
eof {
wait
}
}
exec $bin_rm -f $file_in
#
# Get the priority of each job job with scontrol
#
spawn $scontrol show job $job_id1
expect {
-re "Priority=($number)" {
set job_prio1 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: scontrol not responding\n"
set exit_code 1
}
eof {
wait
}
}
spawn $scontrol show job $job_id2
expect {
-re "Priority=($number)" {
set job_prio2 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: scontrol not responding\n"
set exit_code 1
}
eof {
wait
}
}
spawn $scontrol show job $job_id3
expect {
-re "Priority=($number)" {
set job_prio3 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: scontrol not responding\n"
set exit_code 1
}
eof {
wait
}
}
#
# Make sure the job priorities are as expected
#
if {$job_prio1 == 0 || $job_prio2 == 0 || $job_prio3 == 0} {
send_user "\nFAILURE: failed to job priorities of each submitted job\n"
set exit_code 1
} else {
set diff2 [expr $job_prio1 - $job_prio2]
set diff3 [expr $job_prio1 - $job_prio3]
# Target for diff2 is 101
if {$diff2 < 91 || $diff2 > 111} {
send_user "\nFAILURE: job2 priority delta bad $diff2\n"
set exit_code 1
}
# Target for diff3 is 202
if {$diff3 < 192 || $diff3 > 212} {
send_user "\nFAILURE: job3 priority delta bad $diff3\n"
set exit_code 1
}
}
cancel_job $job_id1
cancel_job $job_id2
cancel_job $job_id3
if {$exit_code == 0} {
send_user "\nSUCCESS\n"
}
exit $exit_code