Skip to content
Snippets Groups Projects
Commit 0367cb1e authored by Nathan Yee's avatar Nathan Yee Committed by Morris Jette
Browse files

Add tests for SINFO_PARTITION env var

bug 1228
parent 5bc6a8e4
No related branches found
No related tags found
No related merge requests found
...@@ -187,6 +187,7 @@ EXTRA_DIST = \ ...@@ -187,6 +187,7 @@ EXTRA_DIST = \
test4.11 \ test4.11 \
test4.12 \ test4.12 \
test4.13 \ test4.13 \
test4.14 \
test5.1 \ test5.1 \
test5.2 \ test5.2 \
test5.3 \ test5.3 \
......
...@@ -586,6 +586,7 @@ EXTRA_DIST = \ ...@@ -586,6 +586,7 @@ EXTRA_DIST = \
test4.11 \ test4.11 \
test4.12 \ test4.12 \
test4.13 \ test4.13 \
test4.14 \
test5.1 \ test5.1 \
test5.2 \ test5.2 \
test5.3 \ test5.3 \
......
...@@ -284,6 +284,7 @@ test4.10 Confirm that sinfo reports a proper version number (--version ...@@ -284,6 +284,7 @@ test4.10 Confirm that sinfo reports a proper version number (--version
test4.11 Test down node reason display (--list-reasons option). test4.11 Test down node reason display (--list-reasons option).
test4.12 Test cpu total and allocation numbers. test4.12 Test cpu total and allocation numbers.
test4.13 Test sinfo's -O (--Format) option. test4.13 Test sinfo's -O (--Format) option.
test4.14 Test that multiple partitions can be specified in the env variable.
test5.# Testing of squeue options. test5.# Testing of squeue options.
......
#!/usr/bin/expect
############################################################################
# Purpose: Test of SLURM functionality
# Validate that multiple partitions can be specified
# in sinfo environment variables
#
#
# 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) 2015 SchedMD LLC
# Written by Nathan Yee <nyee32@schedmd.com>
#
# This file is part of SLURM, a resource management program.
# For details, see <http://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 4.14
set test_part_1 "test$test_id\_partition_1"
set test_part_2 "test$test_id\_partition_2"
set test_node ""
set alpha_num_dot "\[a-zA-Z0-9_.\-\]+"
set default_part default_partition
set exit_code 0
print_header $test_id
if {[test_super_user] == 0} {
send_user "\nWARNING: can not test more unless SlurmUser or root\n"
exit $exit_code
}
proc delete_part { } {
global scontrol exit_code test_part_1 test_part_2
spawn $scontrol delete partition=$test_part_1
expect {
timeout {
send_user "\nFAILURE: scontrol is not responding\n"
set exit_code 1
}
eof {
wait
}
}
spawn $scontrol delete partition=$test_part_2
expect {
timeout {
send_user "\nFAILURE: scontrol is not responding\n"
set exit_code 1
}
eof {
wait
}
}
}
# Remove any vestigial Partitions
delete_part
# get a node for the test partition
spawn $bin_bash -c "$sinfo -h --state=idle -o%n | head -n1"
expect {
-re "($alpha_numeric_under)" {
set test_node $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
# Create test partitions
spawn $scontrol create partition=$test_part_1 nodes=$test_node
expect {
timeout {
send_user "\nFAILURE: scontrol is not responding\n"
set exit_code 1
}
eof {
wait
}
}
spawn $scontrol create partition=$test_part_2 nodes=$test_node
expect {
timeout {
send_user "\nFAILURE: scontrol is not responding\n"
set exit_code 1
}
eof {
wait
}
}
# Check that partitions were created
set found 0
spawn $sinfo -h -p$test_part_1,$test_part_2 -o%P
expect {
-re "$test_part_1" {
incr found
exp_continue
}
-re "$test_part_2" {
incr found
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$found != 2} {
send_user "\nFAILURE: Test partition was not created ($found != 2)\n"
delete_part
exit 1
}
#### Using the Environment Variable ####
set match 0
set found 0
spawn $bin_bash -c "SINFO_PARTITION=$test_part_1,$test_part_2 $sinfo -h -o%P"
expect {
-re "($alpha_num_dot)" {
set str $expect_out(1,string)
if {![string compare $str $test_part_1] || \
![string compare $str $test_part_2] } {
incr match
}
incr found
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$match != 2 || $found != 2} {
send_user "\nFAILURE: partitions do not match (match:$match found:$found != 2)\n"
set exit_code 1
}
#### Test command line option override ####
set match 0
spawn $bin_bash -c "SINFO_PARTITION=$test_part_1,$test_part_2 $sinfo -h -o%P -p$test_part_2"
expect {
-re "($alpha_num_dot)" {
set str $expect_out(1,string)
if {![string compare $str $test_part_1] } {
set match -99
}
if {![string compare $str $test_part_2] } {
incr match
}
incr found
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$match != 1} {
send_user "\nFAILURE: sinfo -p did not override environment variable ($match != 1)\n"
set exit_code 1
}
set match 0
set found 0
spawn $bin_bash -c "SINFO_ALL=1 $sinfo -h -o%P -p$test_part_1,$test_part_2"
expect {
-re "($alpha_num_dot)" {
set str $expect_out(1,string)
if {![string compare $str $test_part_1] || \
![string compare $str $test_part_2]} {
incr match
}
incr found
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$match != 2 || $found != 2} {
send_user "\nFAILURE: sinfo -p did not override env variable (match:$match found:$found != 2)\n"
set exit_code 1
}
set match 0
spawn $bin_bash -c "SINFO_PARTITION=$test_part_1,$test_part_2 $sinfo -h -o%P -a"
expect {
-re "($alpha_num_dot)" {
set str $expect_out(1,string)
if {![string compare $str $test_part_1] || \
![string compare $str $test_part_2]} {
incr match
}
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$match != 2} {
send_user "\nFAILURE: sinfo did not show all partitions ($match != 2)\n"
set exit_code 1
}
#### Test conflicts ####
set match 0
spawn $bin_bash -c "SINFO_PARTITION=$test_part_1,$test_part_2 SINFO_ALL=1 $sinfo"
expect {
-re "Conflicting options" {
send_user "\nThis error is expected, do not worry.\n"
set match 1
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$match != 1} {
send_user "\nFAILURE: sinfo should have produced an error ($match != 1)\n"
set exit_code 1
}
set match 0
spawn $bin_bash -c "SINFO_PARTITION=$test_part_1,$test_part_2 $sinfo -p$test_part_1 -a"
expect {
-re "Conflicting options" {
send_user "\nThis error is expected, do not worry.\n"
set match 1
exp_continue
}
timeout {
send_user "\nFAILURE: sinfo is not responding\n"
set exit_code 1
}
eof {
wait
}
}
if {$match != 1} {
send_user "\nFAILURE: sinfo should have produced an error ($match != 1)\n"
set exit_code 1
}
# Delete test partitions
delete_part
if {$exit_code == 0} {
send_user "\nSUCCESS\n"
}
exit $exit_code
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment