blob: 226d92bfc8a28e18af445d1b3a93129008f5ae62 [file] [log] [blame]
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Test of advanced reservation "replace" option.
############################################################################
# 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
set node_list_new ""
set node_list_orig ""
set resv_name "resv$test_id"
set user_name [get_my_user_name]
if {![is_super_user]} {
skip "This test can't be run except as SlurmUser"
}
set def_part_name [default_partition]
set nb_nodes [get_partition_param $def_part_name "TotalNodes"]
if {$nb_nodes < 3} {
skip "This test requires at least 3 nodes in the cluster"
}
proc cleanup {} {
global resv_name scontrol node_list_new
if [delete_res $resv_name] {
log_warn "Unable to delete reservation ($resv_name)"
}
if {$node_list_new != ""} {
run_command "$scontrol update NodeName=$node_list_new State=RESUME"
}
}
#
# Create the advanced reservation
#
if { [create_res $resv_name "starttime=now duration=2 nodecnt=2 flags=replace partition=$def_part_name users=$user_name"] } {
fail "Error creating reservation"
}
#
# Check the advanced reservation's allocated nodes and "REPLACE" flag
#
set output [run_command_output -fail "$scontrol show ReservationName=$resv_name"]
subtest {[regexp "Flags=REPLACE" $output]} "Verify Reservation REPLACE flag found"
if {[regexp "Nodes=($re_word_str)" $output - node_list_old] != 1} {
fail "Error getting the old node list"
}
#
# Use a node from the reservation, so it gets replaced
#
# TODO: t18772: Remove temporary debug when fixed
set rc [run_command_status "$srun -t1 -n1 --reservation=$resv_name $bin_hostname"]
if {$rc} {
run_command "$scontrol show nodes"
run_command "$scontrol show reservations"
run_command "$scontrol show jobs"
fail "srun not responding"
}
#
# Check that advanced reservation's allocated nodes has been updated
#
set output [run_command -fail "$scontrol show ReservationName=$resv_name"]
if {[regexp "Nodes=($re_word_str)" $output - node_list_new] != 1} {
fail "Error getting the new node list"
}
subtest {$node_list_old ne $node_list_new} "Verify reservation replaces allocated node"
#
# Drain a node from the reservation, so it gets replaced
#
set output [run_command_output -fail "$scontrol update NodeName=$node_list_new State=DRAIN Reason=TESTING"]
if {[regexp "Error|error" $output]} {
fail "Error updating node"
}
set PERIODIC_TIMEOUT 32
set node_list_last $node_list_new
wait_for -timeout $PERIODIC_TIMEOUT {$node_list_last ne $node_list_new} {
set output [run_command_output -fail "$scontrol show ReservationName=$resv_name"]
if {[regexp "Nodes=($re_word_str)" $output - node_list_last] != 1} {
fail "Error getting the last node list"
}
}
subtest {$node_list_last ne $node_list_new} "Verify reservation replaces drain node"