1#!/usr/bin/env expect 2############################################################################ 3# Purpose: Test hetjob: squeue 4# 5# Reqs: 1. Using slurmdbd accounting storage type and is up 6# 2. controllers are up and running. 7############################################################################ 8# Copyright (C) 2017 SchedMD LLC. 9# Written by Isaac Hartung <ihartung@schedmd.com> 10# 11# This file is part of Slurm, a resource management program. 12# For details, see <https://slurm.schedmd.com/>. 13# Please also read the included file: DISCLAIMER. 14# 15# Slurm is free software; you can redistribute it and/or modify it under 16# the terms of the GNU General Public License as published by the Free 17# Software Foundation; either version 2 of the License, or (at your option) 18# any later version. 19# 20# Slurm is distributed in the hope that it will be useful, but WITHOUT ANY 21# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 23# details. 24# 25# You should have received a copy of the GNU General Public License along 26# with Slurm; if not, write to the Free Software Foundation, Inc., 27# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 28############################################################################ 29 30source ./globals 31source ./globals_het_jobs 32 33set file_in "test$test_id.in" 34set file_out "test$test_id.out" 35set job_id 0 36 37if {[get_config_param "SchedulerType"] ne "sched/backfill"} { 38 skip "This test requires SchedulerType = sched/backfill" 39} 40if [in_fed] { 41 skip "This test should not be run in a federation" 42} 43 44proc sbatch {} { 45 global number sbatch file_in file_out bin_sleep 46 47 set matches 0 48 set job_id 0 49 set command "$sbatch -o $file_out $file_in" 50 51 spawn {*}$command 52 expect { 53 -re "Batch job submission failed" { 54 skip "Unable to execute test due to system configuration" 55 } 56 -re "Submitted batch job ($number)" { 57 incr matches 58 set job_id $expect_out(1,string) 59 } 60 timeout { 61 fail "sbatch not responding" 62 } 63 eof { 64 wait 65 } 66 } 67 if {$matches != 1} { 68 fail "batch submit failure" 69 } 70 71 return $job_id 72} 73 74proc cleanup { } { 75 global job_id user_name bin_rm file_in file_out 76 77 cancel_job $job_id 78 79 exec $bin_rm -f $file_in $file_out 80} 81 82#start test 83 84make_bash_script $file_in "#SBATCH --cpus-per-task=4 --mem-per-cpu=10 --ntasks=1 -t1 85#SBATCH hetjob 86#SBATCH --cpus-per-task=2 --mem-per-cpu=2 --ntasks=1 -t1 87#SBATCH hetjob 88#SBATCH --cpus-per-task=1 --mem-per-cpu=6 --ntasks=1 -t1 89 90$bin_sleep 10" 91 92log_info "\n################################################################\n" 93log_info "Submit hetjob and verify output from scontrol show job" 94log_info "\n################################################################\n" 95 96set job_id [sbatch] 97 98set matches 0 99set id_set 0 100set id_regex "\[0-9,-\]+" 101 102set format "jobid:.16,hetjoboffset:.16,hetjobid:.16,hetjobidset:.25" 103set regex "$job_id\\s+0\\s+$job_id\\s+($id_regex)" 104set header "JOBID\\s+HET_JOB_OFFSET\\s+HET_JOB_ID\\s+HET_JOB_ID_SET" 105 106spawn $squeue -j $job_id --Format=$format 107expect { 108 -re $header { 109 incr matches 110 exp_continue 111 } 112 -re $regex { 113 set id_set $expect_out(1,string) 114 incr matches 115 exp_continue 116 } 117 timeout { 118 fail "squeue not responding" 119 } 120 eof { 121 wait 122 } 123} 124if {$matches != 2 } { 125 fail "Problem with squeue test 1 ($matches != 2)" 126} else { 127 log_debug "Test 1 OK" 128} 129 130set js [parse_id_set $id_set $job_id] 131 132set j2 [lindex $js 0] 133set j3 [lindex $js 1] 134 135set matches 0 136set regex "$j2\\s+1\\s+$job_id\\s+$id_set" 137 138spawn $squeue --noheader -j $j2 --Format=$format 139expect { 140 -re $regex { 141 incr matches 142 exp_continue 143 } 144 timeout { 145 fail "squeue not responding" 146 } 147 eof { 148 wait 149 } 150} 151if {$matches != 1 } { 152 fail "Problem with squeue test 2 ($matches != 1)" 153} else { 154 log_debug "Test 2 OK" 155} 156 157set matches 0 158set regex "$j3\\s+2\\s+$job_id\\s+$id_set" 159 160spawn $squeue --noheader -j $j3 --Format=$format 161expect { 162 -re $regex { 163 incr matches 164 exp_continue 165 } 166 timeout { 167 fail "squeue not responding" 168 } 169 eof { 170 wait 171 } 172} 173if {$matches != 1 } { 174 fail "Problem with squeue test 3 ($matches != 1)" 175} else { 176 log_debug "Test 3 OK" 177} 178