diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am index 49b0f9fe4df2f19d97fc57411bab6ca720b86980..f252a52eb3b79f39ec190d91b3d42ee442e4715d 100644 --- a/testsuite/expect/Makefile.am +++ b/testsuite/expect/Makefile.am @@ -278,6 +278,7 @@ EXTRA_DIST = \ test7.17_configs/test7.17.6/slurm.conf \ test7.17_configs/test7.17.7/gres.conf \ test7.17_configs/test7.17.7/slurm.conf \ + test7.19 \ test8.1 \ test8.2 \ test8.3 \ diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in index 2b11ecb7bcddbe0b40f3b8b180ec2cd1627d782c..403ffcbc62b9c2f76d6afa9c97d829a817b17d49 100644 --- a/testsuite/expect/Makefile.in +++ b/testsuite/expect/Makefile.in @@ -705,6 +705,7 @@ EXTRA_DIST = \ test7.17_configs/test7.17.6/slurm.conf \ test7.17_configs/test7.17.7/gres.conf \ test7.17_configs/test7.17.7/slurm.conf \ + test7.19 \ test8.1 \ test8.2 \ test8.3 \ diff --git a/testsuite/expect/README b/testsuite/expect/README index d6932d0b95898f9e21e53b7967a2d9a468849d9d..33db812ba99d0e73810310e5f6622da394b7b903 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -364,6 +364,7 @@ test7.14 Verify the ability to modify the Derived Exit Code/String fields test7.15 Verify signal mask of tasks have no ignored signals. test7.16 Verify that auth/munge credential is properly validated. test7.17 Test GRES APIs. +test7.19 Test sbatch/srun/salloc path resolving test8.# Test of Blue Gene specific functionality. diff --git a/testsuite/expect/test7.19 b/testsuite/expect/test7.19 new file mode 100755 index 0000000000000000000000000000000000000000..916abe31eb6f4f20900a8e96225d47adf911db55 --- /dev/null +++ b/testsuite/expect/test7.19 @@ -0,0 +1,223 @@ +#!/usr/bin/env expect +############################################################################ +# Purpose: Test sbatch/srun/salloc path resolving +# +# 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) 2019 SchedMD LLC. +# Written by Nathan Rini <nate@schedmd.com> +# +# This file is part of Slurm, a resource management program. +# For details, see <https://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 "7.19" +set file_in "bash" + +print_header $test_id + +proc test_sbatch { local } { + global sbatch number file_in + + set rc -12345 + set job_id 0 + + if { $local } { + set file_in_loc "./$file_in" + set exp_rc 0 + } else { + set file_in_loc "$file_in" + set exp_rc 1 + } + spawn $sbatch -W -t1 --wrap "$file_in_loc -c /bin/false" + expect { + -re "Submitted batch job ($number)" { + set job_id $expect_out(1,string) + exp_continue + } + -re "error" { + log_warn "sbatch job was not submitted" + return 1 + } + timeout { + log_error "sbatch not responding" + return 1 + } + eof { + lassign [wait] pid spawnid os_error_flag rc + } + } + + if { $job_id == 0 } { + log_error "batch submit failure" + return 1 + } + + if {$rc != 0 } { + send_user "\nThis error is expected, not a problem\n" + } + + if { $rc != $exp_rc } { + log_error "sbatch error submitting job $job_id rc: $rc instead of $exp_rc\n" + return 1 + } + + return 0 +} + +proc test_salloc { local } { + global salloc number file_in + + set rc -12345 + set job_id 0 + + if { $local } { + set file_in_loc "./$file_in" + set exp_rc 0 + } else { + set file_in_loc "$file_in" + set exp_rc 1 + } + spawn $salloc -t1 $file_in_loc -c /bin/false + expect { + -re "salloc: Granted job allocation ($number)" { + set job_id $expect_out(1,string) + exp_continue + } + -re "error" { + log_warn "FAILURE: Job was not submitted" + return 1 + } + timeout { + log_error "salloc not responding" + return 1 + } + eof { + lassign [wait] pid spawnid os_error_flag rc + } + } + + if { $job_id == 0 } { + log_error "FAILURE: salloc submit failure" + return 1 + } + + if {$rc != 0 } { + send_user "\nThis error is expected, not a problem\n" + } + + if { $rc != $exp_rc } { + log_error "salloc error submitting job $job_id rc: $rc instead of $exp_rc\n" + return 1 + } + + return 0 +} + +proc test_srun { local } { + global srun number file_in + + set rc -12345 + set job_id 0 + + if { $local } { + set file_in_loc "./$file_in" + set exp_rc 0 + } else { + set file_in_loc "$file_in" + set exp_rc 1 + } + spawn $srun -v -t1 $file_in_loc -c /bin/false + expect { + -re "launching ($number).($number)" { + set job_id $expect_out(1,string) + exp_continue + } + timeout { + log_error "srun not responding" + return 1 + } + eof { + lassign [wait] pid spawnid os_error_flag rc + } + } + + + if { $job_id == 0 } { + log_error "srun submit failure" + return 1 + } + + if {$rc != 0 } { + send_user "\nThis error is expected, not a problem\n" + } + + if { $rc != $exp_rc } { + log_error "srun error submitting job $job_id rc: $rc instead of $exp_rc\n" + return 1 + } + + return 0 +} + +set ::env(PATH) "/bin:/usr/bin" + +make_bash_script $file_in "/bin/true" + +# Test tools expecting bash to be used instead of our local 'bash' script +if { [test_sbatch 0] } { + exec $bin_rm $file_in + exit 1 +} + +if { [test_salloc 0] } { + exec $bin_rm $file_in + exit 1 +} + +if { [test_srun 0] } { + exec $bin_rm $file_in + exit 1 +} + +# Test tools expecting our local 'bash' script to override the system bash +if { [test_sbatch 1] } { + exec $bin_rm $file_in + exit 1 +} + +if { [test_salloc 1] } { + exec $bin_rm $file_in + exit 1 +} + +if { [test_srun 1] } { + exec $bin_rm $file_in + exit 1 +} + +#cleanup +exec $bin_rm $file_in + +send_user "\nSUCCESS\n" + +exit 0