diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am index c0558d0e994bd1d8f8d7d280802547eab059f127..844d326c8e73e07e8e56fa4e3e82fdc7b9893413 100644 --- a/testsuite/expect/Makefile.am +++ b/testsuite/expect/Makefile.am @@ -353,6 +353,7 @@ EXTRA_DIST = \ test24.1.prog.c \ test24.2 \ test25.1 \ + test26.1 \ usleep distclean-local: diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in index fc02f76563d0f1ed37d6809c14008ab0dd8bb091..03f8b8f725f308e2d8b76ab90d636a2c4efca8e8 100644 --- a/testsuite/expect/Makefile.in +++ b/testsuite/expect/Makefile.in @@ -627,6 +627,7 @@ EXTRA_DIST = \ test24.1.prog.c \ test24.2 \ test25.1 \ + test26.1 \ usleep all: all-am diff --git a/testsuite/expect/README b/testsuite/expect/README index c159e973290a1ce1ffd63e9f9ca924787cc9aded..d3e759d83c83f164e156ae305648e8839331d737 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -572,3 +572,7 @@ test24.2 sshare h, n, p, P, v, and V options. test25.# Testing of sprio command and options. ================================================= test25.1 sprio all options + +test26.# Test of Cray specific functionality. +================================================ +test26.1 Validate scontrol update command for nodes is disabled. diff --git a/testsuite/expect/test26.1 b/testsuite/expect/test26.1 new file mode 100755 index 0000000000000000000000000000000000000000..61deee2327d28e0754ec09b5bad6c07d3755a408 --- /dev/null +++ b/testsuite/expect/test26.1 @@ -0,0 +1,163 @@ +#!/usr/bin/expect +############################################################################ +# Purpose: Test of SLURM functionality +# Validate scontrol update command for nodes is disabled. +# +# 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) 2002-2007 The Regents of the University of California. +# 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://computing.llnl.gov/linux/slurm/>. +# 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 "26.1" +set exit_code 0 +set node_list "" +set node_name "" + +print_header $test_id + +if {![test_cray]} { + send_user "\nWARNING: This test is only compatible with Cray systems\n" + exit $exit_code +} + +# +# Identify a node and its state +# +spawn $sinfo --noheader -o "NodeName=%N State=%t " +expect { + -re "NodeName=($alpha_numeric_nodelist) State=idle " { + if {[string compare $node_list ""] == 0} { + set node_list $expect_out(1,string) + } + exp_continue + } + -re "NodeName=($alpha_numeric_nodelist) State=allocated " { + if {[string compare $node_list ""] == 0} { + set node_list $expect_out(1,string) + } + exp_continue + } + timeout { + send_user "\nFAILURE: sinfo not responding\n" + set exit_code 1 + } + eof { + wait + } +} +if {[string compare $node_list ""] == 0} { + send_user "\nWARNING: no nodes in usable state for this test\n" + exit 0 +} + +# +# Convert node list to a single node name +# +log_user 0 +spawn $scontrol show hostnames $node_list +expect { + -re "($alpha_numeric_nodelist)" { + set node_name $expect_out(1,string) + } + timeout { + send_user "\nFAILURE: scontrol not responding\n" + set exit_code 1 + } + eof { + wait + } +} +log_user 1 +if {[string compare $node_name ""] == 0} { + send_user "\nWARNING: no nodes in usable state for this test\n" + exit 0 +} + +# +# Change that node's state +# +set mod_error 0 +spawn $scontrol update NodeName=$node_name State=DRAIN Reason=TESTING +expect { + -re "can not be changed through SLURM" { + set mod_error 1 + exp_continue + } + -re "slurm_update error: ($alpha_numeric_under) ($alpha_numeric_under)" { + set access_err 0 + set err_msg1 $expect_out(1,string) + set err_msg2 $expect_out(2,string) + if {[string compare $err_msg1 "Invalid"] == 0} { + set access_err 1 + } + if {[string compare $err_msg2 "user"] == 0} { + set access_err 1 + } + if {$access_err == 1} { + send_user "\nWARNING: user not authorized\n" + exit $exit_code + } else { + set mod_error 1 + } + exp_continue + } + timeout { + send_user "\nFAILURE: scontrol not responding\n" + set exit_code 1 + } + eof { + wait + } +} +if {$mod_error == 1} { + send_user "\nThis error was expected, no worries\n" +} else { + send_user "\nFAILURE: scontrol did not get an error trying to change node state\n" + set exit_code 1 +} + +# +# Validate node's state +# +spawn $scontrol show node $node_name +expect { + -re "($alpha_numeric_nodelist)" { + set node_name $expect_out(1,string) + } + timeout { + send_user "\nFAILURE: scontrol not responding\n" + set exit_code 1 + } + eof { + wait + } +} + +if {$exit_code == 0} { + send_user "\nSUCCESS\n" +} +exit $exit_code