#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # Test of MPICH2 task spawn logic ############################################################################ # Copyright (C) 2002 The Regents of the University of California. # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). # Written by Morris Jette # CODE-OCEC-09-009. All rights reserved. # # 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.input" set file_out "test$test_id.output" set file_err "test$test_id.error" set server_prog "test$test_id.server" set client_prog "test$test_id.client" set job_id 0 # # Test for existence of mpi compiler # if {[info exists mpicc] == 0} { skip "Mpicc not defined, can't perform mpi testing" } if {[file executable $mpicc] == 0} { skip "$mpicc does not exists" } # # Test is only works with mpi/pmi2 plugin. # set invalid 1 log_user 0 spawn $scontrol show config expect { -re "pmi2" { set invalid 0 exp_continue } timeout { log_error "scontrol not responding" set exit_code 1 } eof { wait } } log_user 1 if {$invalid == 1} { skip "Test compatible only with MpiDefault=pmi2" } # # Delete left-over program and rebuild it # exec $bin_rm -f $file_in $file_out $file_err exec $bin_rm -f $server_prog ${server_prog}.o exec $bin_rm -f $client_prog ${client_prog}.o exec $mpicc -o $server_prog ${server_prog}.c exec $mpicc -o $client_prog ${client_prog}.c # Delete left-over stdout/err files file delete $file_out $file_err # # Build input script file # make_bash_script $file_in " $srun -n1 --mem=0 $server_prog $client_prog " # # Spawn an sbatch job that uses stdout/err and confirm their contents # set timeout $max_job_delay set no_start 0 set sbatch_pid [spawn $sbatch -n4 --mem=0 --output=$file_out --error=$file_err -t1 $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 { log_error "srun not responding" slow_kill $sbatch_pid set exit_code 1 } eof { wait } } if {$no_start != 0} { if {$job_id != 0} { cancel_job $job_id } skip "Partition too small for test" } if {$job_id == 0} { fail "Batch submit failure" } # # Wait for job to complete # if {[wait_for_job $job_id "DONE"] != 0} { log_error "Waiting for job to complete" set exit_code 1 } # # Check for desired output in stdout # set expected_msg 4 set expected_sum 12 if {[wait_for_file $file_out] == 0} { set complete 0 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 } eof { wait } } if {$matches == 0} { log_error "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" set exit_code 1 } elseif {$matches != $expected_msg} { log_error "Unexpected output ($matches of $expected_msg)" set exit_code 1 } elseif {$rank_sum != $expected_sum} { log_error "Invalid rank values ($rank_sum != $expected_sum)" set exit_code 1 } } else { set exit_code 1 } if {$exit_code == 0} { exec $bin_rm -f $file_in $file_out $file_err exec $bin_rm -f $server_prog ${server_prog}.o exec $bin_rm -f $client_prog ${client_prog}.o } else { set matches 0 spawn head $file_err expect { -re "Error creating CQ" { incr matches exp_continue } eof { wait } } if {$matches != 0} { log_warn "If using MVAPICH thenc onfigure \"PropagateResourceLimitsExcept=MEMLOCK\". Also start slurmd with \"ulimit -l unlimited\"" } else { log_debug "Check contents of $file_err" } } if {$exit_code != 0} { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }