#!/usr/bin/expect ############################################################################ # Purpose: Test of Slurm functionality # Confirm that FLEX flag of reservations works correctly ############################################################################ # Copyright (C) 2002 The Regents of the University of California. # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). # Written by Marcin Stolarek # CODE-OCEC-09-009. All rights reserved. # # 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 job_id 0 set user_name [get_my_user_name] set default_partition [default_partition] set res_name "res_$test_name" proc cleanup {} { global scontrol res_name job_id cancel_job $job_id run_command "$scontrol delete reservation=$res_name" } proc setup {use_flex {start_time ""}} { global res_name user_name default_partition if {$use_flex} { log_info "Creting a reservation with Flags=FLEX" set flags "Flags=FLEX" } else { log_info "Creting a reservation WITHOUT Flags=FLEX" set flags "" } if {[create_res $res_name "StartTime=now$start_time Duration=1 NodeCnt=1 partition=$default_partition user=$user_name $flags"]} { fail "Unable to create a reservation with flags=FLEX" } } set nb_nodes [get_node_cnt_in_part] if {$nb_nodes < 2} { skip "Need 2 or more nodes in default partition" } proc test_flex {use_flex submit_active} { global res_name job_id log_info "SUBTEST: Job using more nodes than reservation" cleanup if {$submit_active} { setup $use_flex "" wait_for {[get_resvation_param $res_name State] eq "ACTIVE"} {} } else { setup $use_flex "+5" } set job_id [submit_job -none "-N2 --reservation=$res_name --wrap 'sleep 30'"] if {$use_flex} { if {[wait_for_job -timeout 30 $job_id RUNNING]} { fail "Job didn't start while it should because with FLEX more nodes can be requested" } } else { if {$submit_active} { if {$job_id} { fail "Job submitted but it shouldn't because requested more nodes than in reservation without FLEX and ACTIVE" } log_debug "Previous submission error expected, don't worry" } else { if {![wait_for_job -timeout 30 $job_id RUNNING]} { fail "Job started but it shouldn't because requested more nodes than in reservation without FLEX" } } } log_info "SUBTEST: Job with EndTime after reservation end" cleanup if {$submit_active} { setup $use_flex "" wait_for {[get_resvation_param $res_name State] eq "ACTIVE"} {} } else { setup $use_flex "+5" } set job_id [submit_job -fail "-N1 --reservation=$res_name -t 120 --wrap 'sleep 100'"] if {[wait_for_job -timeout 30 $job_id RUNNING]} { fail "Job didn't start while it should" } if {[wait_for_job -timeout 200 -pollinterval 10 $job_id DONE]} { fail "Job didn't end" } if {$use_flex} { if { [get_job_param $job_id JobState] ne "COMPLETED" } { fail "Job didn't complete successfully and it should with FLEX" } } else { if { [get_job_param $job_id JobState] ne "TIMEOUT" } { fail "Job didn't TIMEOUT it should without FLEX" } } log_info "SUBTEST: Job start before reservation StartTime" cleanup setup $use_flex "+60" set job_id [submit_job -fail "-N1 --reservation=$res_name -t 300 --wrap 'sleep 30'"] if {$use_flex} { if {[wait_for_job -timeout 30 $job_id RUNNING]} { fail "Job didn't start before reservation and it should with FLEX." } } else { if {![wait_for_job -timeout 30 $job_id RUNNING]} { fail "Job started before reservation and it shouldn't without FLEX." } } } # Test with FLEX flag and when reservation is ACTIVE test_flex true true # Test with FLEX flag and when reservation is INACTIVE test_flex true false # Test without FLEX flag and when reservation is ACTIVE test_flex false true # Test without FLEX flag and when reservation is INACTIVE test_flex false false if {$exit_code} { fail "Test failed due to previous errors (\$exit_code = $exit_code)" }