diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am index 9f7d1a85f1f9b6a7a9d72839ae85d614ffffa017..d03f889f86e24bdaf5f262c3d6ffa04b988d344d 100644 --- a/testsuite/expect/Makefile.am +++ b/testsuite/expect/Makefile.am @@ -630,7 +630,8 @@ EXTRA_DIST = \ test38.6 \ test38.6.prog.c \ test38.7 \ - test38.7.prog.c + test38.7.prog.c \ + test38.9 distclean-local: rm -rf *error *output diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in index dade8d2556830993f833c7075918a464040081c2..8f75952cfcf92d67257528ed6251952a77d2641f 100644 --- a/testsuite/expect/Makefile.in +++ b/testsuite/expect/Makefile.in @@ -1054,7 +1054,8 @@ EXTRA_DIST = \ test38.6 \ test38.6.prog.c \ test38.7 \ - test38.7.prog.c + test38.7.prog.c \ + test38.9 all: all-am diff --git a/testsuite/expect/README b/testsuite/expect/README index 5b314ecc0408244c4b372c6328d77758c291a05e..a86d0f5c75773922b224e6de46588da96d4e7922 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -824,3 +824,4 @@ test38.4 Validate salloc heterogeneous job environment variables. test38.5 Validate squeue heterogeneous job fields test38.6 Test of SPANK plugin with heterogeneous jobs test38.7 Test of MPI with heterogeneous jobs. +test38.9 Validate srun --pack-group option. diff --git a/testsuite/expect/test38.9 b/testsuite/expect/test38.9 new file mode 100755 index 0000000000000000000000000000000000000000..ccec955a56840e76416f985f8f1111d88702e446 --- /dev/null +++ b/testsuite/expect/test38.9 @@ -0,0 +1,306 @@ +#!/usr/bin/env expect +############################################################################ +# Purpose: Test of SLURM functionality +# Test of --pack-group option. +# +# 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) 2017 SchedMD LLC. +# Written by Isaac Hartung <ihartung@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 "38.9" + +print_header $test_id +set prompt "PROMPT:" + +set timeout 60 + +if {[test_front_end]} { + send_user "\nWARNING: This test is incompatible with front-end systems\n" + exit $exit_code +} elseif {[test_serial]} { + set task_num 1 +} else { + set task_num 2 +} + +set def_part_name [default_partition] +set nb_nodes [get_node_cnt_in_part $def_part_name] +if {$nb_nodes < 3} { + send_user "\nWARNING: Need 3 or more nodes in default partition\n" + exit $exit_code +} + +proc end_it { exit_code } { + global pack_job_id scancel + if {$pack_job_id > 0} { + exec $scancel $pack_job_id + } + exit $exit_code +} + +set pack_job_id 0 +set matches 0 +set index 0 +set component(0) 0 +set timeout $max_job_delay +set sid [spawn $salloc -t1 --exclusive -N1 : --exclusive -N1 : --exclusive -N1 $bin_bash] +expect { + -re "Granted job allocation ($number)" { + set pack_job_id $expect_out(1,string) + send "export PS1=\"$prompt\"\r" + exp_continue + } + -re "export PS1=\"$prompt\"\r" { + # skip this, just echo of setting prompt" + exp_continue + } + -re "$prompt" { + #send_user "Job initiated\n" + } + timeout { + log_error "salloc : allocation not granted in $timeout seconds" + end_it 1 + } +} + +if {$pack_job_id == 0} { + log_error "salloc failure" + end_it 1 +} + +# +# Reading a second prompt is required by some versions of Expect +# +set timeout 1 +expect { + -re $prompt { + exp_continue + } + timeout { + } +} +set timeout 30 + +send_user "\n\nCollect Nodenames\n\n" + +send "$squeue -j $pack_job_id -o%N --noheader \r" +expect { + -re "--noheader" { + exp_continue + } + -re "(\\S+)" { + if {![string match $expect_out(1,string) $prompt]} { + set component($index) $expect_out(1,string) + incr index + exp_continue + } + } + timeout { + log_error "squeue not responding" + end_it 1 + } +} +if {$index != 3} { + log_error "squeue failure ($index != 3)" + end_it 1 +} + +send_user "\n\nTest Sending Jobs To Various Components\n\n" + +set timeout 3 +set matches 0 + +send "$srun --pack-group=0 printenv SLURMD_NODENAME\r" +expect { + -re $component(0) { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 1} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +set matches 0 + +send "$srun --pack-group=1 printenv SLURMD_NODENAME\r" +expect { + -re $component(1) { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 1} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +set matches 0 + +send "$srun --pack-group=2 printenv SLURMD_NODENAME\r" +expect { + -re $component(2) { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 1} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +set matches 0 + +send "$srun --pack-group=0-2 printenv SLURMD_NODENAME\r" +expect { + -re $component(0)|$component(1)|$component(2) { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 3} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +set matches 0 + +send "$srun --pack-group=0,2 printenv SLURMD_NODENAME\r" +expect { + -re $component(2)|$component(0) { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 2} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +send_user "\n\nTesting Error Messages\n\n" + + +set matches 0 + +send "$srun --pack-group=0-3 printenv SLURMD_NODENAME\r" +expect { + -re "srun: error: Attempt to run a job step with pack group value of 3, but the job allocation has maximum value of 2" { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 1} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +set matches 0 +send "$srun --pack-group=0,5 printenv SLURMD_NODENAME\r" +expect { + -re "srun: error: Attempt to run a job step with pack group value of 5, but the job allocation has maximum value of 2" { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 1} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +set matches 0 +send "$srun --pack-group=0 printenv SLURMD_NODENAME : --pack-group=0 env\r" +expect { + -re "srun: fatal: Duplicate pack groups in single srun not supported" { + incr matches + exp_continue + } + -re "$prompt" { + #break + } + timeout { + log_error "srun not responding" + end_it 1 + } +} +if { $matches != 1} { + log_error "srun failure $matches $expect_out(buffer)" + end_it 1 +} + +send "exit\r" + +send_user "\nSUCCESS\n" +exit 0