blob: c9d9c88056c7846eae3196140111942960a8a2ff [file] [log] [blame]
#!/usr/bin/expect
############################################################################
# Purpose: Test of SLURM functionality
# Test squeue filtering (--jobs, --node, --states, --steps and
# --user options).
#
# 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) 2002 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 "5.6"
set exit_code 0
set file_in "test$test_id.input"
set job_id1 0
set job_id2 0
print_header $test_id
#
# Build input script file
#
make_bash_script $file_in "$srun $bin_sleep $max_job_delay"
if { [test_bluegene] } {
set node_cnt 512-512
} else {
set node_cnt 1-1
}
#
# Submit a couple of job so we have something to look at
#
set srun_pid [spawn $srun --batch -N$node_cnt --output=/dev/null --error=/dev/null -t5 $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 job submit failure\n"
exit 1
}
set srun_pid [spawn $srun --batch -N$node_cnt --output=/dev/null --error=/dev/null --hold -t5 $file_in]
expect {
-re "jobid ($number) submitted" {
set job_id2 $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
cancel_job $job_id1
exit 1
}
eof {
wait
}
}
if {$job_id2 == 0} {
send_user "\nFAILURE: srun job submit failure\n"
cancel_job $job_id1
exit 1
}
#
# Check the squeue job filter option
#
set job_found 0
spawn $squeue --format=%i --jobs $job_id2
expect {
-re "($number)" {
set tmp_id $expect_out(1,string)
if {$tmp_id == $job_id2} {
set job_found 1
} else {
send_user "\nFAILURE: squeue reported invalid job_id\n"
set exit_code 1
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$job_found == 0} {
send_user "\nFAILURE: squeue failed to locate desired job\n"
set exit_code 1
}
#
# Check the squeue state filter option
#
spawn $squeue --format=%t --noheader --states=PD
expect {
-re "($alpha_cap)" {
if {[string compare $expect_out(1,string) "PD"]} {
send_user "\nFAILURE: squeue state filter failure\n"
set exit_code 1
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
#
# Check the squeue user filter option with name
#
spawn $bin_id -un
expect {
-re "($alpha_numeric)" {
set this_user $expect_out(1,string)
exp_continue
}
eof {
wait
}
}
spawn $squeue --format=%u --noheader --user=$this_user
expect {
-re "($alpha_numeric)" {
if {[string compare $expect_out(1,string) $this_user]} {
send_user "\nFAILURE: squeue user filter failure\n"
set exit_code 1
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
#
# Check the squeue user filter option with id
#
spawn $bin_id -u
expect {
-re "($number)" {
set this_uid $expect_out(1,string)
exp_continue
}
eof {
wait
}
}
spawn $squeue --format=%u --noheader --user=$this_uid
expect {
-re "($alpha_numeric)" {
if {[string compare $expect_out(1,string) $this_user]} {
send_user "\nFAILURE: squeue user filter failure\n"
set exit_code 1
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
#
# Check the squeue node filter option
#
spawn $squeue --format=%u --noheader --user=$this_uid --node=dummy_name
expect {
-re "($alpha_numeric)" {
send_user "\nFAILURE: squeue node filter failure\n"
set exit_code 1
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
# The node filtering really only works if the job has begun execution
set node_name_set 0
spawn $squeue --format=%N --noheader --jobs=$job_id1 --states=RUNNING
expect {
-re "($alpha_numeric)" {
set node_name $expect_out(1,string)
set node_name_set 1
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$node_name_set == 1} {
spawn $squeue --format=%u --noheader --user=$this_uid --node=$node_name
expect {
-re "($alpha_numeric)" {
set node_name_set 0
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
}
if {$node_name_set == 1} {
send_user "\nFAILURE: squeue node name filtering failed\n"
set exit_code 1
}
#
# Check the squeue partition filter option
#
# First get partition name(s)
set partition1 ""
set partition2 ""
spawn $squeue --format=%P --noheader
expect {
-re "($alpha_numeric)" {
if {![string compare $partition1 ""]} {
set partition1 $expect_out(1,string)
}
if {[string compare $expect_out(1,string) $partition1]} {
set partition2 $expect_out(1,string)
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {[string compare partition2 ""]} {
set partition1 $partition2
}
spawn $squeue --format=%P --noheader --partitions=$partition1
expect {
-re "($alpha_numeric)" {
if {[string compare $expect_out(1,string) $partition1]} {
send_user "\nFAILURE: squeue partition filter error\n"
set exit_code 1
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
#
# Wait long enough to make sure the job step is running and has
# started its job steps. Check the squeue job step filter option
#
wait_for_job $job_id1 "RUNNING"
exec $bin_sleep 10
set job_found 0
spawn $squeue --format=%i --steps $job_id1.0
expect {
-re "($number).($number)" {
set tmp_id $expect_out(1,string)
if {$tmp_id == $job_id1} {
set job_found 1
} else {
send_user "\nFAILURE: squeue reported invalid job_step_id\n"
set exit_code 1
}
exp_continue
}
timeout {
send_user "\nFAILURE: squeue not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$job_found == 0} {
send_user "\nFAILURE: squeue failed to locate desired job step\n"
set exit_code 1
}
cancel_job $job_id2
cancel_job $job_id1
exec $bin_rm -f $file_in
if {$exit_code == 0} {
send_user "\nSUCCESS\n"
}
exit $exit_code