|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/expect |
| 2 |
############################################################################ |
| 3 |
# Purpose: Test of SLURM functionality |
| 4 |
# Test qalter's -o option for changing |
| 5 |
# the stdout path of a job. |
| 6 |
# |
| 7 |
# |
| 8 |
# Output: "TEST: #.#" followed by "SUCCESS" if test was successful, OR |
| 9 |
# "FAILURE: ..." otherwise with an explanation of the failure, OR |
| 10 |
# anything else indicates a failure mode that must be investigated. |
| 11 |
############################################################################ |
| 12 |
# Copyright (C) 2013 SchedMD LLC |
| 13 |
# Written by Nathan Yee <nyee32@schedmd.com> |
| 14 |
# |
| 15 |
# This file is part of SLURM, a resource management program. |
| 16 |
# For details, see <http://slurm.schedmd.com/>. |
| 17 |
# Please also read the included file: DISCLAIMER. |
| 18 |
# |
| 19 |
# SLURM is free software; you can redistribute it and/or modify it under |
| 20 |
# the terms of the GNU General Public License as published by the Free |
| 21 |
# Software Foundation; either version 2 of the License, or (at your option) |
| 22 |
# any later version. |
| 23 |
# |
| 24 |
# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY |
| 25 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 26 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 27 |
# details. |
| 28 |
# |
| 29 |
# You should have received a copy of the GNU General Public License along |
| 30 |
# with SLURM; if not, write to the Free Software Foundation, Inc., |
| 31 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 32 |
############################################################################ |
| 33 |
source ./globals |
| 34 |
|
| 35 |
set test_id "test20.7" |
| 36 |
set file_in "$test_id\.script" |
| 37 |
set out_path "/tmp/null" |
| 38 |
set exit_code 0 |
| 39 |
|
| 40 |
print_header $test_id |
| 41 |
|
| 42 |
if {[file executable $qalter] == 0} { |
| 43 |
send_user "\nWARNING: $qalter does not exist\n" |
| 44 |
exit 0 |
| 45 |
} |
| 46 |
|
| 47 |
if {[file executable $qsub] == 0} { |
| 48 |
send_user "\nWARNING: $qsub does not exits\n" |
| 49 |
exit 0 |
| 50 |
} |
| 51 |
|
| 52 |
# Clean up any vestigial files |
| 53 |
exec $bin_rm -f $file_in |
| 54 |
|
| 55 |
make_bash_script $file_in " |
| 56 |
|
| 57 |
sleep 200 |
| 58 |
" |
| 59 |
|
| 60 |
|
| 61 |
proc check_output { path job_id} { |
| 62 |
|
| 63 |
global scontrol exit_code |
| 64 |
|
| 65 |
set check_out 0 |
| 66 |
spawn $scontrol show job $job_id |
| 67 |
expect { |
| 68 |
-re "Comment=stdout=$path" { |
| 69 |
set check_out 1 |
| 70 |
exp_continue |
| 71 |
} |
| 72 |
timeout { |
| 73 |
send_user "\nFAILURE: scontrol is not responding\n" |
| 74 |
set exit_code 1 |
| 75 |
} |
| 76 |
eof { |
| 77 |
wait |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
if {$check_out != 1} { |
| 82 |
send_user "\nFAILURE: output path for job $job_id was not set" |
| 83 |
send_user " to the correct value\n" |
| 84 |
set exit_code 1 |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
spawn $qsub -o /dev/null $file_in |
| 91 |
expect { |
| 92 |
-re "($number)" { |
| 93 |
set job_id $expect_out(1,string) |
| 94 |
exp_continue |
| 95 |
} |
| 96 |
timeout { |
| 97 |
send_user "\nFAILURE: qsub is not responding\n" |
| 98 |
set exit_code 1 |
| 99 |
} |
| 100 |
eof { |
| 101 |
wait |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
if {$job_id == 0} { |
| 106 |
send_user "\nFAILURE: qsub did not submit job\n" |
| 107 |
set exit_code 1 |
| 108 |
} |
| 109 |
|
| 110 |
set found 0 |
| 111 |
spawn $qalter -o $out_path $job_id |
| 112 |
expect { |
| 113 |
timeout { |
| 114 |
send_user "\nFAILURE: qalter is not responding\n" |
| 115 |
set exit_code 1 |
| 116 |
} |
| 117 |
eof { |
| 118 |
wait |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
check_output $out_path $job_id |
| 123 |
|
| 124 |
cancel_job $job_id |
| 125 |
|
| 126 |
if {$exit_code == 0} { |
| 127 |
exec $bin_rm -f $file_in |
| 128 |
send_user "\nSUCCESS\n" |
| 129 |
} |
| 130 |
exit $exit_code |