#!/usr/bin/env expect ############################################################################ # Purpose: Test local and remote job dependencies # # Reqs: 1. Using slurmdbd accounting storage type and is up # 2. fed_slurm_base is defined in globals.local - set to directory that # has access to each federation configure (fedc1, fedc2, fedc3). # Eg. # fedr/slurm/ (src) # fedr/fed1/bin # fedr/fed1/sbin # fedr/fed1/etc # fedr/fed1/... # fedr/fed2/... # fedr/fed3/... # 3. controllers are up and running. ############################################################################ # Copyright (C) 2020 SchedMD LLC. # Written by Marshall Garey # # 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 source ./globals_federation set c1 $fedc1 set c2 $fedc2 set c3 $fedc3 set exit_code 0 set job_id1 0 set job_id2 0 set user_name [get_my_user_name] set file_in_long "test$test_id\_long.in" set file_in_short "test$test_id\_short.in" set my_scancel "${fed_slurm_base}/$c1/bin/scancel" set my_scontrol "${fed_slurm_base}/$c1/bin/scontrol" set reason "" set dependency "" set fed_name "fed_test$test_id" set all_clusters "$c1,$c2,$c3" ############################################################################### # Functions ############################################################################### proc cancel_federation_jobs { } { global user_name c1 c2 c3 my_scancel all_clusters test_id spawn $my_scancel -M$all_clusters --jobname test${test_id}_job expect { eof { wait } } sleep 5 } proc cancel_job { job_id clusters } { global my_scancel spawn $my_scancel $job_id expect { eof { wait } } wait_for_fed_job $job_id "DONE" $clusters } proc cleanup { rc } { global bin_rm file_in_long file_in_short fed_name test_id delete_federations $fed_name cancel_federation_jobs exec $bin_rm -f $file_in_long exec $bin_rm -f $file_in_short } proc submit_job { options cdir file_in } { global bin_sleep sbatch number fed_slurm_base slow_kill test_id set job_id 0 set my_sbatch "${fed_slurm_base}/$cdir/bin/sbatch" if {[test_federation_setup]} { set my_sbatch $sbatch } set command "$my_sbatch --job-name=test$test_id\_job -t1 \ $options --output=/dev/null $file_in" set sbatch_pid [spawn {*}$command] expect { -re "Submitted batch job ($number)" { set job_id $expect_out(1,string) exp_continue } timeout { slow_kill $sbatch_pid fail "sbatch not responding" } eof { wait } } if { $job_id == 0 } { fail "Failed to submit job\n" } return $job_id } proc get_job_dependency { job_id } { global my_scontrol reason dependency re_word_str set reason "" set dependency "" set reason_match "\[a-zA-Z_\]+" # Possible dependency syntax: # :+