#!/usr/bin/env expect ############################################################################ # Purpose: Test label option with hetjob allocation. ############################################################################ # Copyright (C) 2017 SchedMD LLC. # Written by Isaac Hartung # 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 prompt "PROMPT: " set timeout 60 if {[test_front_end]} { skip "This test is incompatible with front-end systems" } if {[test_hetjob_step] == 0} { skip "Heterogeneous steps not currently supported" } set nb_nodes [get_node_cnt_in_part] if {$nb_nodes < 3} { skip "Need 3 or more nodes in default partition" } proc end_it { exit_code } { global het_job_id scancel if {$het_job_id > 0} { exec $scancel $het_job_id } if {$exit_code != 0} { fail "Test failed due to previous errors (\$exit_code = $exit_code)" } pass } set het_job_id 0 set component(0) 0 set matches 0 set index 0 set timeout $max_job_delay spawn $salloc -t1 -N1 : -N1 : -N1 $bin_bash expect { -re "job ($number) has been allocated resources" { set het_job_id $expect_out(1,string) send "export PS1=\"$prompt\"\r" exp_continue } -re "\"$prompt" { # skip this, just echo of setting prompt" exp_continue } -re "$prompt" { #log_debug "Job initiated" } timeout { log_error "salloc: allocation not granted in $timeout seconds" end_it 1 } eof { wait } } if {$het_job_id == 0} { log_error "salloc failure" end_it 1 } log_debug "Collect Nodenames" send "$squeue -j $het_job_id -o\"NAME=%N\" --noheader\r" expect { -re "--noheader" { exp_continue } -re "NAME=($re_word_str)" { set component($index) $expect_out(1,string) incr index exp_continue } -re "$prompt" { #break } timeout { log_error "squeue not responding" end_it 1 } } if {$index != 3} { log_error "squeue failure ($index != 3)" end_it 1 } log_info "Test Sending Srun w/ --label To Various Components" set matches 0 send "$srun --label --mpi=none --het-group=0-2 printenv SLURMD_NODENAME\r" expect { -re "2: $component(2)" { incr matches exp_continue } -re "$prompt" { #break } timeout { log_error "srun not responding" end_it 1 } eof { wait } } if {$matches != 1} { log_error "srun failure ($matches != 1)" end_it 1 } set matches 0 send "$srun --label --mpi=none --het-group=1-2 printenv SLURMD_NODENAME\r" expect { -re "1: $component(2)" { incr matches exp_continue } -re "$prompt" { #break } timeout { log_error "srun not responding" end_it 1 } eof { wait } } if {$matches != 1} { log_error "srun failure ($matches != 1)" end_it 1 } set matches 0 send "$srun --label --mpi=none -O -n3 : -O -n4 : -n1 printenv SLURMD_NODENAME\r" expect { -re "7: $component(2)" { incr matches exp_continue } -re "$prompt" { #break } timeout { log_error "srun not responding" end_it 1 } eof { wait } } if {$matches != 1} { log_error "srun failure ($matches != 1)" end_it 1 } set matches 0 send "$srun --label --mpi=none -O -n3 : -O -n4 : -n1 printenv SLURMD_NODENAME\r" expect { -re "\[3-6\]: $component(1)" { incr matches exp_continue } -re "$prompt" { #break } timeout { log_error "srun not responding" end_it 1 } eof { wait } } if {$matches != 4} { log_error "srun failure ($matches != 4)" end_it 1 } set matches 0 send "$srun --label --mpi=none -O -n3 : -O -n4 : -n1 printenv SLURMD_NODENAME\r" expect { -re "\[0-2\]: $component(0)" { incr matches exp_continue } -re "$prompt" { #break } timeout { log_error "srun not responding" end_it 1 } eof { wait } } if {$matches != 3} { log_error "srun failure ($matches != 3)" end_it 1 } for {set inx 0} {$inx < 3} {incr inx} { set matches 0 send "$srun -O -n3 --label --mpi=none --het-group=$inx printenv SLURMD_NODENAME\r" expect { -re "\[0-2\]: $component($inx)" { incr matches exp_continue } -re "$prompt" { #break } timeout { log_error "srun not responding" end_it 1 } eof { wait } } if {$matches != 3} { log_error "srun failure ($matches != 3)" end_it 1 } } send "exit\r" expect { timeout { log_error "srun not responding" end_it 1 } eof { wait } } end_it 0