#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # test for #BSUB entry functionality ############################################################################ # Copyright (C) 2015 SchedMD LLC # Written by Nathan Yee # # This file is part of Slurm, a resource management program. # For details, see . # Please also read the included file: DISCLAIMER. # # 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 exit_code 0 set file_in "test$test_id\.sh" set job_name "test$test_id\_job" set partition [default_partition] set job_time 1 set stdout "/dev/null" set stderr "/tmp/err" set job_id 0 set node_list [get_idle_node_in_part $partition] if {[test_select_type_params "MEMORY"]} { set job_mem 100 } else { set job_mem 1 } array set check_list { } set check_list(JobName) $job_name set check_list(TimeLimit) 00:0$job_time\:00 set check_list(Partition) $partition set check_list(BatchHost) $node_list set check_list(MinMemoryCPU) $job_mem set check_list(StdErr) $stderr set check_list(StdOut) $stdout make_bash_script $file_in " #BSUB -o$stdout -e$stderr #BSUB -m\"$node_list\" #BSUB -J$job_name -M$job_mem #BSUB -W$job_time -x -q$partition sleep 10 " # Run the job with sbatch spawn $sbatch $file_in expect { -re "Submitted batch job ($number)" { set job_id $expect_out(1,string) exp_continue } timeout { log_error "sbatch is not responding" set exit_code 1 } eof { wait } } if {$job_id == 0} { exec $bin_rm -fr $file_in fail "sbatch did not submit job" } # Wait for the job to finish if {[wait_for_job $job_id "DONE"] != 0} { log_error "Error waiting for job $job_id to complete" cancel_job $job_id set exit_code 1 } foreach option [array names check_list] { #log_debug "$option=$check_list($option)" if {[string compare $option "BatchHost"] == 0 && [test_front_end] != 0} { continue } set match 0 log_user 0 spawn $scontrol show job $job_id expect { -re "$option=$check_list($option)" { set match 1 exp_continue } timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } log_user 1 # Check that each value is found if {$match != 1} { log_error "$option was not found. Could be due to small configured MinJobAge value" set exit_code 1 } } cancel_job $job_id if {$exit_code == 0} { exec $bin_rm -fr $file_in } else { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }