#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # Validate that sinfo -O (--Format) option displays the # correct user specified values. ############################################################################ # Copyright (C) 2015 SchedMD LLC # Written by Nathan Yee # # This file is part of Slurm, a resource management program. # For details, see . # 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 source ./globals_accounting set test_acct "test$test_id\_acct" set test_part "test$test_id\_part" set test_node [get_idle_node_in_part] set exit_code 0 array set node_sinfo_vals { } array set part_sinfo_vals { } array set node_info { AllocMem allocmem CPUTot cpus CPULoad cpusload CoresPerSocket cores TmpDisk disk Features features FreeMem freemem Gres gres NodeAddr nodeaddr NodeHostName nodehost RealMemory memory State statelong Sockets sockets ThreadsPerCore threads Version version Weight weight } array set part_info { State available MaxCPUsPerNode maxcpuspernode Nodes nodelist TotalNodes nodes PreemptMode preemptmode PriorityJobFactor priorityjobfactor PriorityTier prioritytier OverSubscribe oversubscribe RootOnly root } proc cleanup { } { global scontrol test_part exit_code spawn $scontrol delete partitionname=$test_part expect { timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } } if { ![test_super_user] } { skip "This test can't be run without being a super user of the cluster" } log_info "=== Testing Node Information ===" set first_option 1 foreach option [array names node_info] { if {$first_option == 1} { set first_option 0 } else { log_user 0 } spawn $scontrol show node $test_node expect { -re "\\m$option=($re_word_str)\\M" { set node_sinfo_vals($node_info($option)) $expect_out(1,string) exp_continue } timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } log_user 1 } set first_option 1 foreach option [array names node_sinfo_vals] { # Gres option (and potentially others) may include "(" and ")" as # characters, they need to be escaped to be used as part of a regexp set regexp [string map {\( \\( \) \\)} $node_sinfo_vals($option)] set match 0 spawn $sinfo -n$test_node -O$option:256 -h expect { -nocase -re "$regexp" { set match 1 exp_continue } timeout { log_error "sinfo is not responding" set exit_code 1 } eof { wait } } if {$match != 1} { log_error "Node information $option output does not match sinfo output. Looking for value: $option = $node_sinfo_vals($option)" set exit_code 1 } } # # Add test partition # spawn $scontrol create partitionname=$test_part nodes=$test_node expect { timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } set match 0 spawn $scontrol show partitionname=$test_part expect { -re "PartitionName=$test_part" { set match 1 exp_continue } timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } if {$match != 1} { fail "Test partition was not created" } log_info "=== Testing Partition Information ===" set first_option 1 foreach option [array names part_info] { set part_sinfo_vals($part_info($option)) "UNKNOWN" set match 0 if {$first_option == 1} { set first_option 0 } else { log_user 0 } spawn $scontrol show partition $test_part expect { -re "\\m$option=($re_word_str)\\M" { set part_sinfo_vals($part_info($option)) \ $expect_out(1,string) exp_continue } timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } log_user 1 } set first_option 1 foreach option [array names part_sinfo_vals] { set match 0 spawn $sinfo -p$test_part -O$option -h expect { -nocase -re "$part_sinfo_vals($option)" { set match 1 exp_continue } timeout { log_error "sinfo is not responding" set exit_code 1 } eof { wait } } if {$match != 1} { log_error "Partition information $option output does not match sinfo output. Looking for value: $option = $part_sinfo_vals($option)" set exit_code 1 } } cleanup if {$exit_code != 0} { fail "Test failed due to previous errors" }