From df16f6421d17843a2b1ed2fce5376b84b6c1beed Mon Sep 17 00:00:00 2001 From: Chad Vizino <chad@schedmd.com> Date: Thu, 18 Jul 2019 16:19:40 -0600 Subject: [PATCH] Add test case to confirm standalone srun is not ignoring --mem-per-cpu. Bug 7277 --- testsuite/expect/Makefile.am | 1 + testsuite/expect/Makefile.in | 1 + testsuite/expect/README | 1 + testsuite/expect/test1.116 | 96 ++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100755 testsuite/expect/test1.116 diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am index 984c5070487..b597f3fd08b 100644 --- a/testsuite/expect/Makefile.am +++ b/testsuite/expect/Makefile.am @@ -133,6 +133,7 @@ EXTRA_DIST = \ test1.113 \ test1.114 \ test1.115 \ + test1.116 \ test2.1 \ test2.2 \ test2.3 \ diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in index e3679717225..9fb5bf65402 100644 --- a/testsuite/expect/Makefile.in +++ b/testsuite/expect/Makefile.in @@ -541,6 +541,7 @@ EXTRA_DIST = \ test1.113 \ test1.114 \ test1.115 \ + test1.116 \ test2.1 \ test2.2 \ test2.3 \ diff --git a/testsuite/expect/README b/testsuite/expect/README index f68dcfdd9df..ad16b8d61a8 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -221,6 +221,7 @@ test1.112 Test of --deadline and --begin option and time not changed test1.113 Test of --use-min-nodes option. test1.114 Test of srun --spread-job option. test1.115 Test of srun not hanging on ignored stdin. +test1.116 Test of standalone srun not ignoring --mem-per-cpu test2.# Testing of scontrol options (to be run as unprivileged user). ======================================================================== diff --git a/testsuite/expect/test1.116 b/testsuite/expect/test1.116 new file mode 100755 index 00000000000..b7fcbe2e9f2 --- /dev/null +++ b/testsuite/expect/test1.116 @@ -0,0 +1,96 @@ +#!/usr/bin/env expect +############################################################################ +# Purpose: Test of Slurm functionality +# Confirm that memory per cpu properly set on an srun job that +# does not have a preexisting allocation. +# +# Output: "TEST: #.#" followed by "SUCCESS" if test was successful, OR +# "FAILURE: ..." otherwise with an explanation of the failure, OR +# anything else indicates a failure mode that must be investigated. +############################################################################ +# Copyright (C) 2019 SchedMD LLC +# Written by Chad Vizino <chad@schedmd.com> +# +# 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 test_id "1.116" +set timeout $max_job_delay +set job_id 0 +set mem_spec "100M" +set job_min_memory_cpu 0 + +print_header $test_id + +# +# submit srun job with a specific mem-per-cpu request +# +set srun_pid [spawn $srun --mem-per-cpu=$mem_spec $bin_bash -c "echo SLURM_JOB_ID=\$SLURM_JOB_ID"] +expect { + -re {SLURM_JOB_ID=([0-9]+)} { + set job_id $expect_out(1,string) + } + timeout { + send_user "\nFAILURE: srun not responding\n" + slow_kill $srun_pid + exit 1 + } + eof { + wait + } +} + +# +# check to make sure a job id was set +# +if {$job_id == 0} { + send_user "\nFAILURE: Did not get job id\n" + exit 1 +} + +# +# get job memory info +# +spawn $scontrol show job $job_id +expect { + -re {MinMemoryCPU=([0-9]+.?)} { + set job_min_memory_cpu $expect_out(1,string) + } + timeout { + send_user "\nFAILURE: scontrol not responding\n" + exit 1 + } + eof { + wait + } +} + +# +# check that the memory reported matches the requested value +# +if {[string compare $job_min_memory_cpu $mem_spec] != 0} { + send_user "\nFAILURE: job MinMemoryCPU $job_min_memory_cpu != $mem_spec\n" + exit 1 +} + +print_success $test_id +exit 0 + + -- GitLab