#!/usr/bin/env expect ############################################################################ # Purpose: Test of Slurm functionality # Test that scontrol show license is sorted ############################################################################ # 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 set exit_code 0 set lic_a "lic_a_test$test_id" set lic_b "lic_b_test$test_id" set lic_c "lic_c_test$test_id" set cluster [get_cluster_name] proc add_lic { license } { global sacctmgr exit_code cluster set added 0 spawn $sacctmgr -i add resource name=$license cluster=$cluster count=50 \ percentallowed=10 type=license expect { -re "Adding Resource" { set added 1 exp_continue } timeout { log_error "sacctmgr is not reponding" set exit_code 1 } eof { wait } } if {$added != 1} { log_error "sacctmgr did not add license: $license" set exit_code 1 } } proc delete_lic { license } { global sacctmgr exit_code 1 set deleted 0 spawn $sacctmgr -i delete resource name=$license expect { -re "Deleting resource" { set deleted 1 exp_continue } timeout { log_error "sacctmgr is not responding" set exit_code 1 } eof { wait } } if { $deleted != 1 } { log_error "sacctmgr could not delete license: $license" set exit_code 1 } } if { [test_using_slurmdbd] == 0 } { skip "This test can't be run without AccountStorageType=slurmdbd" } elseif { [test_super_user] == 0} { skip "This test can't be run without superuser permissions" } # Add the licenses in random order add_lic $lic_c add_lic $lic_a add_lic $lic_b set match 0 spawn $scontrol show lic expect { -re "LicenseName=$lic_a" { incr match 1 exp_continue } -re "LicenseName=$lic_b" { incr match 1 exp_continue } -re "LicenseName=$lic_c" { incr match 1 exp_continue } timeout { log_error "scontrol is not responding" set exit_code 1 } eof { wait } } if { $match != 3 } { fail "Licenses are not sorted" } delete_lic $lic_a delete_lic $lic_b delete_lic $lic_c if {$exit_code != 0} { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }