blob: 45e0d299ff5314d9d7b94547a97c09339d1ffe77 [file] [log] [blame]
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Test of MPI with heterogeneous jobs.
############################################################################
# Copyright (C) 2002 The Regents of the University of California.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Morris Jette <jette1@llnl.gov>
# CODE-OCEC-09-009. All rights reserved.
#
# 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 file_in "$test_dir/input"
set file_out "$test_dir/output"
set file_err "$test_dir/error"
set test_prog "$test_name.prog"
set skips 0
set job_id 0
set mpi_arg "--mpi=pmix"
proc run_pmix_het_job {comp_count} {
global eol max_job_delay number srun mpi_arg
set het_comps ""
set sep ""
for {set i 1} {$i <= $comp_count} {incr i} {
set het_comps "${het_comps}${sep}echo J$i"
set sep " : "
}
# since het jobs are started by the backfill scheduler, they
# may need a bit more time to start
set output [run_command_output -fail -timeout [expr $max_job_delay * 3] "$srun $mpi_arg $het_comps"]
set comp_found [regexp -all "J$number$eol" $output]
if {$comp_found != $comp_count} {
fail "srun hetjob failed with $comp_count components"
}
}
#
# Test MPI setup
#
if {![check_mpi "pmix"]} {
skip "This test needs a working MPI with PMIX setup"
}
if {[get_config_param "SchedulerType"] ne "sched/backfill"} {
skip "This test requires SchedulerType = sched/backfill"
}
set nb_nodes [get_partition_param [default_partition] "TotalNodes"]
if {$nb_nodes < 2} {
skip "Need 2 or more nodes in default partition"
}
proc cleanup {} {
global job_id test_prog file_err test_status STATUS_FAIL
cancel_job $job_id
file delete $test_prog ${test_prog}.o
if {$test_status == $STATUS_FAIL && [file exists $file_err] && [file size $file_err] != 0} {
set matches [regexp "Error creating CQ" [run_command_output "head $file_err"]]
if {$matches != 0} {
log_warn "If using MVAPICH then configure \"PropagateResourceLimitsExcept=MEMLOCK\". Also start slurmd with \"ulimit -l unlimited\""
} else {
log_debug "Check contents of $file_err"
}
}
}
#
# Delete left-over program and rebuild it
#
run_command -fail "$mpicc -o $test_prog ${test_prog}.c"
########################################################################
# TEST OF HET GROUP 0
########################################################################
log_info "TEST OF HET GROUP 0"
# Delete left-over stdout/err files
file delete $file_out $file_err
#
# Build input script file
#
make_bash_script $file_in "
$bin_date
$bin_echo HET GROUP 0
$srun $mpi_arg --het-group=0 ./$test_prog
$bin_date
$bin_echo TEST_COMPLETE
"
#
# Spawn an sbatch job that uses stdout/err and confirm their contents
#
set job_id [submit_job -fail "-N1 -n2 --output=$file_out --error=$file_err -t1 : -N1 -n2 $file_in"]
wait_for_job -fail $job_id "DONE"
#
# Check for desired output in stdout
#
wait_for_file -fail $file_out
set complete 0
set expected_sum 2
set expected_msg 2
set matches 0
set rank_sum 0
spawn $bin_cat $file_out
expect {
-re "Rank.($number). on $re_word_str just received msg from Rank ($number)" {
incr rank_sum $expect_out(1,string)
incr rank_sum $expect_out(2,string)
incr matches
exp_continue
}
-re "TEST_COMPLETE" {
incr complete
exp_continue
}
eof {
wait
}
}
if {$matches == 0} {
fail "No MPI communications occurred. The version of MPI you are using may be incompatible with the configured switch. Core files may be present from failed MPI tasks"
} elseif {$matches != $expected_msg} {
fail "Unexpected output ($matches of $expected_msg)"
} elseif {$complete == 0} {
fail "Test failed to complete"
} elseif {$rank_sum != $expected_sum} {
fail "Invalid rank values ($rank_sum != $expected_sum)"
}
########################################################################
# TEST OF HET GROUP 1
########################################################################
log_info "TEST OF HET GROUP 1"
# Delete left-over stdout/err files
file delete $file_out $file_err
#
# Build input script file
#
make_bash_script $file_in "
$bin_date
$bin_echo HET GROUP 1
$srun $mpi_arg --het-group=1 ./$test_prog
$bin_date
$bin_echo TEST_COMPLETE
"
#
# Spawn an sbatch job that uses stdout/err and confirm their contents
#
set job_id [submit_job -fail "-N1 -n2 --output=$file_out --error=$file_err -t1 : -N1 -n2 $file_in"]
wait_for_job -fail $job_id "DONE"
#
# Check for desired output in stdout
#
wait_for_file -fail $file_out
set complete 0
set expected_sum 2
set expected_msg 2
set matches 0
set rank_sum 0
spawn $bin_cat $file_out
expect {
-re "Rank.($number). on $re_word_str just received msg from Rank ($number)" {
incr rank_sum $expect_out(1,string)
incr rank_sum $expect_out(2,string)
incr matches
exp_continue
}
-re "TEST_COMPLETE" {
incr complete
exp_continue
}
eof {
wait
}
}
if {$matches == 0} {
fail "No MPI communications occurred. The version of MPI you are using may be incompatible with the configured switch. Core files may be present from failed MPI tasks"
} elseif {$matches != $expected_msg} {
fail "Unexpected output ($matches of $expected_msg)"
} elseif {$complete == 0} {
fail "Test failed to complete"
} elseif {$rank_sum != $expected_sum} {
fail "Invalid rank values ($rank_sum != $expected_sum)"
}
########################################################################
# TEST OF HET GROUP 0,1
########################################################################
########################################################################
# TEST OF HET JOB WITH PMIX (to reproduce bug 8990)
########################################################################
log_info "TEST OF SRUN HETJOB WITH PMIX"
foreach comp_count {2 3 4} {
run_pmix_het_job $comp_count
}
#
# OpenMPI can only run in multi-slurmd mode if no more than one node has
# more than one task. Individual nodes with more than one task use shared
# memory for communications and if more than one node is doing that, their
# shared memory use collides. That means these MPI tests will work if five
# nodes or more are available, otherwise some tests will fail. See test1.116
# for a variation of this test that will work with OpenMPI and multi-slurmd
# mode.
#
if {[get_config_param "MULTIPLE_SLURMD"] eq "yes"} {
skip "This test is incompatible with multiple slurmd systems"
}
log_info "TEST OF HET GROUP 0,1"
# Delete left-over stdout/err files
file delete $file_out $file_err
#
# Build input script file
#
make_bash_script $file_in "
$bin_date
$bin_echo HET GROUP 0,1
$srun $mpi_arg --het-group=0,1 ./$test_prog
$bin_date
$bin_echo TEST_COMPLETE
"
#
# Spawn an sbatch job that uses stdout/err and confirm their contents
#
set job_id 0
set no_start 0
spawn $sbatch -N1 -n2 --output=$file_out --error=$file_err -t1 : -N1 -n2 $file_in
expect {
-re "Submitted batch job ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
-re "Batch job submission failed" {
set no_start 1
exp_continue
}
-re "Unable to contact" {
fail "Slurm appears to be down"
}
timeout {
fail "srun not responding"
}
eof {
wait
}
}
if {$no_start != 0} {
skip "Partition too small for test"
}
if {$job_id == 0} {
fail "Batch submit failure"
}
#
# Wait for job to complete
#
wait_for_job -fail $job_id "DONE"
#
# Check for desired output in stdout
#
wait_for_file -fail $file_out
set complete 0
set expected_sum 12
set expected_msg 4
set matches 0
set rank_sum 0
spawn $bin_cat $file_out
expect {
-re "Rank.($number). on $re_word_str just received msg from Rank ($number)" {
incr rank_sum $expect_out(1,string)
incr rank_sum $expect_out(2,string)
incr matches
exp_continue
}
-re "TEST_COMPLETE" {
incr complete
exp_continue
}
eof {
wait
}
}
if {$matches == 0} {
fail "No MPI communications occurred. The version of MPI you are using may be incompatible with the configured switch. Core files may be present from failed MPI tasks"
} elseif {$matches != $expected_msg} {
fail "Unexpected output ($matches of $expected_msg)"
} elseif {$complete == 0} {
fail "Test failed to complete"
} elseif {$rank_sum != $expected_sum} {
fail "Invalid rank values ($rank_sum != $expected_sum)"
}
########################################################################
# TEST OF HET GROUP 1 THEN 0,1
########################################################################
log_info "TEST OF HET GROUP 1 THEN 0,1"
# Delete left-over stdout/err files
file delete $file_out $file_err
#
# Build input script file
#
make_bash_script $file_in "
$bin_date
$bin_echo HET GROUP 1
$srun $mpi_arg --het-group=1 ./$test_prog
$bin_echo HET GROUP 0,1
$srun $mpi_arg --het-group=0,1 ./$test_prog
$bin_date
$bin_echo TEST_COMPLETE
"
#
# Spawn an sbatch job that uses stdout/err and confirm their contents
#
set job_id 0
set no_start 0
spawn $sbatch -N1 -n2 --output=$file_out --error=$file_err -t1 : -N1 -n2 $file_in
expect {
-re "Submitted batch job ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
-re "Batch job submission failed" {
set no_start 1
exp_continue
}
-re "Unable to contact" {
fail "Slurm appears to be down"
}
timeout {
fail "srun not responding"
}
eof {
wait
}
}
if {$no_start != 0} {
skip "Partition too small for test"
}
if {$job_id == 0} {
fail "Batch submit failure"
}
#
# Wait for job to complete
#
wait_for_job -fail $job_id "DONE"
#
# Check for desired output in stdout
#
wait_for_file -fail $file_out
set complete 0
set expected_sum 14
set expected_msg 6
set matches 0
set rank_sum 0
spawn $bin_cat $file_out
expect {
-re "Rank.($number). on $re_word_str just received msg from Rank ($number)" {
incr rank_sum $expect_out(1,string)
incr rank_sum $expect_out(2,string)
incr matches
exp_continue
}
-re "TEST_COMPLETE" {
incr complete
exp_continue
}
eof {
wait
}
}
if {$matches == 0} {
fail "No MPI communications occurred. The version of MPI you are using may be incompatible with the configured switch. Core files may be present from failed MPI tasks"
} elseif {$matches != $expected_msg} {
fail "Unexpected output ($matches of $expected_msg)"
} elseif {$complete == 0} {
fail "Test failed to complete"
} elseif {$rank_sum != $expected_sum} {
fail "Invalid rank values ($rank_sum != $expected_sum)"
}