blob: 8191c7fc507ed80d5d19056f18da40b54f6fa203 [file]
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Validate scontrol update command for job steps.
# Copyright (C) 2010 Lawrence Livermore National Security.
# 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_in1 "$test_dir/input1"
set file_in2 "$test_dir/input2"
set file_out "$test_dir/output"
set job_id 0
set step_id 0
proc cleanup {} {
global job_id
cancel_job $job_id
}
#
# Build input batch file
#
make_bash_script $file_in1 "
$bin_echo JOB_BEGIN
$srun -t3 $file_in2
$bin_echo JOB_FINISH
"
#
# Build step file
# The second sleep is because with some proctrack plugins, the bash shell may
# be terminated slightly later than the first sleep process
#
make_bash_script $file_in2 "
$bin_echo STEP_BEGIN
$bin_sleep 120
$bin_sleep 1
$bin_echo STEP_FINISH
"
#
# Submit a job so we have something to work with
#
set job_id [submit_job -fail "--output=$file_out -t5 $file_in1"]
#
# Wait for job _and_ step to start running
#
wait_for_job -fail $job_id "RUNNING"
wait_for_step ${job_id}.${step_id}
#
# Validate original time limits
#
set job {}
set step_batch {}
set step_0 {}
wait_for -subtest { [dict_getdef $job "TimeLimit" ""] == "00:05:00" && \
[dict_getdef $step_0 "TimeLimit" ""] == "00:03:00" && \
[dict_getdef $step_batch "TimeLimit" ""] == "UNLIMITED" } {
set jobs [get_jobs]
set steps [get_steps $job_id]
set job [dict_getdef $jobs $job_id {}]
set step_batch [dict_getdef $steps ${job_id}.batch {}]
set step_0 [dict_getdef $steps ${job_id}.0 {}]
}
#
# Update time limit of the step 0
#
run_command -fail "$scontrol update StepId=${job_id}.0 TimeLimit=1"
#
# Validate new time limits
#
set job {}
set step_batch {}
set step_0 {}
wait_for -subtest { [dict_getdef $job "TimeLimit" ""] == "00:05:00" && \
[dict_getdef $step_0 "TimeLimit" ""] == "00:01:00" && \
[dict_getdef $step_batch "TimeLimit" ""] == "UNLIMITED" } {
set jobs [get_jobs]
set steps [get_steps $job_id]
set job [dict_getdef $jobs $job_id {}]
set step_batch [dict_getdef $steps ${job_id}.batch {}]
set step_0 [dict_getdef $steps ${job_id}.0 {}]
}
#
# Wait for step to exit and check output file
# Look for message generated before and after srun (job step) time limit
#
wait_for_job -fail -timeout 120 $job_id "DONE"
wait_for_file -fail $file_out
set output ""
wait_for -subtest {[regexp "STEP_BEGIN" $output] && \
[regexp "JOB_FINISH" $output] && \
[regexp "DUE TO TIME LIMIT" $output] && \
![regexp "STEP_FINISH" $output] } {
set output [run_command_output -fail "$bin_cat $file_out"]
}