From 3465a30c0175a96e4eafaa9082296f1f26ac17fc Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez <alex@schedmd.com> Date: Fri, 19 Feb 2016 15:00:43 -0800 Subject: [PATCH] test basic functionality of bsub --- testsuite/expect/README | 1 + testsuite/expect/globals | 1 + testsuite/expect/test36.4 | 121 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100755 testsuite/expect/test36.4 diff --git a/testsuite/expect/README b/testsuite/expect/README index d354be0757e..a2c4cac750c 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -789,3 +789,4 @@ test36.# Testing of openlava/LSF wrappers and Perl APIs. test36.1 lsid wrapper test test36.2 bjobs wrapper test test36.3 bkill wrapper test +test36.4 bsub wrapper test diff --git a/testsuite/expect/globals b/testsuite/expect/globals index 33f62f45f65..d3280875229 100755 --- a/testsuite/expect/globals +++ b/testsuite/expect/globals @@ -115,6 +115,7 @@ cset qrerun "${slurm_dir}/bin/qrerun" cset lsid "${slurm_dir}/bin/lsid" cset bjobs "${slurm_dir}/bin/bjobs" cset bkill "${slurm_dir}/bin/bkill" +cset bsub "${slurm_dir}/bin/bsub" # If length of string partition is zero, use output of function # default_partition, otherwise use the partition explicitly diff --git a/testsuite/expect/test36.4 b/testsuite/expect/test36.4 new file mode 100755 index 00000000000..eadd63b3b43 --- /dev/null +++ b/testsuite/expect/test36.4 @@ -0,0 +1,121 @@ +#!/usr/bin/env expect +############################################################################ +# Purpose: Test of SLURM functionality +# bsub wrapper test +# +# 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) 2016 SchedMD LLC +# Written by Alejandro Sanchez <alex@schedmd.com> +# +# This file is part of SLURM, a resource management program. +# For details, see <http://slurm.schedmd.com/>. +# 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 test_id "36.4" +set exit_code 0 +set file_err "test$test_id.error" +set file_in "test$test_id.input" +set file_out "test$test_id.output" + +print_header $test_id + +if {[file executable $bsub] == 0} { + send_user "\nWARNING: $bsub not found\n" + exit 0 +} + +if {[file executable $bkill] == 0} { + send_user "\nWARNING: $bkill not found\n" + exit 0 +} + +set job_id 0 +exec rm -f $file_out $file_err +make_bash_script $file_in "$bin_echo HELLO; $bin_cat /dummy_file" +spawn $bsub -W 01:00 -e $file_err -o $file_out $file_in +expect { + -re "($number)" { + set job_id $expect_out(1,string) + exp_continue + } + timeout { + send_user "\nFAILURE: bsub not responding\n" + set exit_code 1 + } + eof { + wait + } +} +if {$job_id == 0} { + send_user "\nFAILURE: bsub failed to submit job\n" + exit 1 +} + +if {[wait_for_file $file_out] != 0} { + send_user "\nFAILURE: bsub output file not found\n" + catch {exec $bkill $job_id} + exit 1 +} +set matches 0 +spawn $bin_cat $file_out +expect { + -re "HELLO" { + incr matches + exp_continue + } + eof { + wait + } +} +if {$matches != 1} { + send_user "\nFAILURE: unexpected bsub output file contents\n" + set exit_code 1 +} + +if {[wait_for_file $file_err] != 0} { + send_user "\nFAILURE: bsub error file not found\n" + catch {exec $qdel $job_id} + exit 1 +} +set matches 0 +spawn $bin_cat $file_err +expect { + -re "No such file" { + send_user "message from cat expected, no worries.\n" + incr matches + exp_continue + } + eof { + wait + } +} +if {$matches != 1} { + send_user "\nFAILURE: unexpected bsub error file contents\n" + set exit_code 1 +} + +if {$exit_code == 0} { + exec $bin_rm -f $file_in $file_out $file_err + send_user "\nSUCCESS\n" +} +exit $exit_code -- GitLab