| #!/usr/bin/env expect |
| ############################################################################ |
| # Purpose: Test of sacct functionality for heterogeneous jobs. |
| # sacct options j |
| ############################################################################ |
| # Copyright (C) SchedMD LLC. |
| # CODE-OCEC-09-009. All rights reserved. |
| # |
| # 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 het_job_id 0 |
| |
| # |
| # Check accounting config and bail if not found. |
| # |
| if {[get_config_param "AccountingStorageType"] ne "accounting_storage/slurmdbd"} { |
| skip "This test can't be run without a usable AccountStorageType" |
| } |
| |
| if {[get_config_param "SchedulerType"] ne "sched/backfill"} { |
| skip "This test requires SchedulerType = sched/backfill" |
| } |
| |
| set nb_nodes [get_partition_param [default_partition] "TotalNodes"] |
| if {$nb_nodes < 3} { |
| skip "Need 3 or more nodes in default partition" |
| } |
| |
| # If PrologFlags=contain is in slurm.conf, then an "extern" step will be |
| # launched on each node, so we need to check for 2 matches per component |
| # instead of 1. |
| set expected_matches 1 |
| if {[param_contains [get_config_param "PrologFlags"] "Contain"]} { |
| set expected_matches 2 |
| } |
| |
| proc cleanup {} { |
| global het_job_id scancel |
| |
| if {$het_job_id > 0} { |
| exec $scancel $het_job_id |
| } |
| } |
| |
| # Submit the hetjob to test with salloc |
| set timeout $max_job_delay |
| spawn $salloc -t1 -N1 : -N1 : -N1 $bin_bash |
| expect { |
| -re "job ($number) has been allocated resources" { |
| set het_job_id $expect_out(1,string) |
| } |
| timeout { |
| fail "salloc: allocation not granted in $timeout seconds" |
| } |
| eof { |
| wait |
| } |
| } |
| if {$het_job_id == 0} { |
| fail "salloc failure" |
| } |
| |
| expect * |
| |
| log_info "Test Sending Sacct To Various Components" |
| |
| # Wait for accounting records to reach slurmdbd |
| set output "" |
| wait_for -subtest {[regexp -all "\n" $output] == [expr 3*$expected_matches]} { |
| set output [run_command_output -fail "$sacct -nj $het_job_id"] |
| } |
| |
| # Now test sacct |
| subtest {[regexp -all "$het_job_id\\+0" $output] == $expected_matches} "sacct should report component 0" |
| subtest {[regexp -all "$het_job_id\\+1" $output] == $expected_matches} "sacct should report component 1" |
| subtest {[regexp -all "$het_job_id\\+2" $output] == $expected_matches} "sacct should report component 2" |
| |
| for {set inx 0} {$inx < 3} {incr inx} { |
| set output [run_command_output -fail "$sacct -nj $het_job_id+$inx"] |
| subtest {[regexp -all "$het_job_id\\+$inx" $output] == $expected_matches} "sacct for the component $inx should report component $inx" |
| subtest {[regexp -all "\n" $output] == [expr $expected_matches]} "sacct for the component $inx should not report other component $inx" |
| } |