blob: 2ed45800cf41315e41637b0c93f3cd3ed2c02c27 [file]
#!/usr/bin/env expect
############################################################################
# Purpose: Validate salloc hetjob options.
#
# Reqs: 1. Using slurmdbd accounting storage type and is up
# 2. controllers are up and running.
############################################################################
# Copyright (C) SchedMD LLC.
#
# 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
source ./globals_het_jobs
set job_id 0
set timeout 60
if {[get_config_param "SchedulerType"] ne "sched/backfill"} {
skip "This test requires SchedulerType = sched/backfill"
}
proc salloc {} {
global number salloc bin_sleep job_id
set job_id 0
set iter 0
set command "$salloc --cpus-per-task=4 --mem-per-cpu=10 --ntasks=1 :\
--cpus-per-task=2 --mem-per-cpu=2 --ntasks=1 :\
--cpus-per-task=1 --mem-per-cpu=6 --ntasks=1 -t1 \
$bin_sleep 1"
set regex "Granted job allocation ($number)"
spawn {*}$command
expect {
-re "Job submit/allocate failed" {
skip "Unable to execute test due to system configuration"
}
-re "Pending job allocation ($number)" {
set job_id $expect_out(1,string)
# exp_continue
}
-re "Granted job allocation ($number)" {
if {$job_id == 0} {
set job_id $expect_out(1,string)
}
# exp_continue
}
timeout {
fail "salloc not responding"
}
eof {
wait
}
}
if {$job_id == 0} {
fail "salloc failure"
}
return $job_id
}
proc cleanup { } {
global job_id bin_rm test_name
cancel_job $job_id
exec $bin_rm -f $test_name*.out
}
# Submit hetjob with salloc, and wait until running
set job_id [salloc]
# Get all the jobs, and the HetJobIdSet from the job id
set jobs [get_jobs]
set j1 [dict get $jobs $job_id]
set id_set [dict_getdef $j1 "HetJobIdSet" ""]
if { $id_set == "" } {
fail "Unable to obtain HetJobIdSet from job $job_id"
}
# Obtain the other two components from the HetJobIdSet
set js [parse_id_set $id_set $job_id]
set j2 [dict_getdef $jobs [lindex $js 0] {}]
set j3 [dict_getdef $jobs [lindex $js 1] {}]
# Verify values of all components
subtest {[dict_getdef $j1 "HetJobId" 0] == $job_id} "First component should have HetJobId=$job_id"
subtest {[dict_getdef $j1 "HetJobOffset" -1] == 0} "First component should have HetJobOffset=0"
subtest {[dict_getdef $j1 "CPUs/Task" 0] == 4} "First component should have CPUs/Task=4"
subtest {[dict_getdef $j1 "MinMemoryCPU" 0M] == "10M"} "First component should have MinMemoryCPU=10M"
subtest {[dict_getdef $j2 "HetJobId" 0] == $job_id} "Second component should have HetJobId=$job_id"
subtest {[dict_getdef $j2 "HetJobOffset" -1] == 1} "Second component should have HetJobOffset=1"
subtest {[dict_getdef $j2 "HetJobIdSet" ""] == $id_set} "Second component should have HetJobIdSet=$id_set"
subtest {[dict_getdef $j2 "CPUs/Task" 0] == 2} "Second component should have CPUs/Task=2"
subtest {[dict_getdef $j2 "MinMemoryCPU" 0M] == "2M"} "Second component should have MinMemoryCPU=2M"
subtest {[dict_getdef $j3 "HetJobId" 0] == $job_id} "Third component should have HetJobId=$job_id"
subtest {[dict_getdef $j3 "HetJobOffset" -1] == 2} "Third component should have HetJobOffset=2"
subtest {[dict_getdef $j3 "HetJobIdSet" ""] == $id_set} "Third component should have HetJobIdSet=$id_set"
subtest {[dict_getdef $j3 "CPUs/Task" 0] == 1} "Third component should have CPUs/Task=1"
subtest {[dict_getdef $j3 "MinMemoryCPU" 0M] == "6M"} "Third component should have MinMemoryCPU=6M"