| #!/usr/bin/env expect |
| ############################################################################ |
| # Purpose: Test of Slurm functionality |
| # Validate that the mcs plugin (mcs/group) is OK with sbatch |
| ############################################################################ |
| # Copyright (C) 2015 CEA/DAM/DIF |
| # Written by Aline Roy <aline.roy@cea.fr> |
| # |
| # 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 cwd "[$bin_pwd]" |
| set config_path "" |
| set tmp_job "$test_dir/script" |
| set file_in "$test_dir/input" |
| set file_out "$test_dir/output" |
| set job_id 0 |
| |
| if {![is_super_user]} { |
| skip "This test can't be run except as SlurmUser" |
| } |
| |
| set config_path [get_conf_path] |
| set config_file $config_path/slurm.conf |
| save_conf $config_file |
| |
| proc cleanup {} { |
| global job_id config_file |
| |
| # Clean up jobs and restore original slurm.conf file |
| cancel_job $job_id |
| restore_conf $config_file |
| reconfigure |
| } |
| |
| log_info "---Checking sbatch uses mcs-label only for some jobs (ondemand mode)---" |
| |
| # |
| # Change the slurm.conf MCSparameters and MCSPlugin |
| # |
| set groups_name 0 |
| log_debug "groups=$groups_name" |
| spawn $bin_bash -c "exec groups \| sed \"s/ /\|/g\"" |
| expect { |
| -re "($re_word_str)" { |
| set groups_name $expect_out(1,string) |
| } |
| eof { |
| wait |
| } |
| } |
| |
| exec $bin_sed -i /^\[\t\s\]*MCSPlugin\[\t\s\]*=/Id $config_file |
| exec $bin_sed -i /^\[\t\s\]*MCSParameters\[\t\s\]*=/Id $config_file |
| exec $bin_sed -i /^\[\t\s\]*PrivateData\[\t\s\]*=/Id $config_file |
| exec $bin_echo -e "\nMCSPlugin=mcs/group" >> $config_file |
| exec $bin_echo MCSParameters=ondemand,select,privatedata:$groups_name >> $config_file |
| exec $bin_echo PrivateData=jobs,nodes >> $config_file |
| reconfigure -fail |
| |
| |
| # |
| # verify slurm conf parameters MCS |
| # |
| set mcs [get_config_param "MCSPlugin"] |
| subtest {$mcs == "mcs/group"} "MCSPlugin parameter should be mcs/group" |
| |
| ###### Check that sbatch fails with a bad mcs-label ###### |
| log_info "---Checking sbatch fails with a bad mcs-label ---" |
| |
| set timeout $max_job_delay |
| make_bash_script $tmp_job "sleep 10" |
| |
| set job_id [submit_job -xfail -subtest "-N1 --mcs-label=foo -t1 $tmp_job"] |
| |
| |
| ###### Check that sbatch uses mcs-label=group ###### |
| log_info "---Checking sbatch uses mcs-label=group---" |
| |
| make_bash_script $tmp_job "sleep 10" |
| set job_id [submit_job -subtest -fail "-N1 -o/dev/null --exclusive=mcs -t1 $tmp_job"] |
| |
| |
| spawn $bin_bash -c "exec groups \| sed \"s/ /\|/g\"" |
| expect { |
| -re "($re_word_str)" { |
| set pipe_idx [expr [string first "|" $expect_out(1,string)] -1] |
| if {$pipe_idx < 0} { |
| set group1 $expect_out(1,string) |
| } else { |
| set group1 [string range $expect_out(1,string) 0 $pipe_idx] |
| } |
| } |
| eof { |
| wait |
| } |
| } |
| |
| set mcslabel [get_job_param $job_id "MCS_label"] |
| subtest {$mcslabel == $group1} "Job should be submitted with MCSLabel $group1" |
| cancel_job $job_id |
| |
| make_bash_script $tmp_job "sleep 30" |
| set job_id [submit_job -fail "-N1 --mcs-label=$group1 --exclusive=mcs -o/dev/null -t10 $tmp_job"] |
| |
| set mcslabel "" |
| set node "" |
| wait_for -subtest {$mcslabel == $group1 && $node != ""} { |
| set job [dict get [get_jobs] $job_id] |
| set mcslabel [dict_getdef $job "MCS_label" ""] |
| set node [dict_getdef $job "NodeList" ""] |
| } |
| |
| # |
| # verify MCS of nodes |
| # |
| set mcslabel "" |
| wait_for -subtest {$mcslabel == $group1} { |
| set mcslabel [get_node_param $node "MCS_label"] |
| } |
| cancel_job $job_id |
| |
| # |
| # Change the slurm.conf MCSparameters and MCSPlugin |
| # test with enforced |
| # |
| log_info "---Checking sbatch uses mcs-label with all jobs (enforced mode)---" |
| exec $bin_sed -i /^\[\t\s\]*MCSPlugin\[\t\s\]*=/Id $config_file |
| exec $bin_sed -i /^\[\t\s\]*MCSParameters\[\t\s\]*=/Id $config_file |
| exec $bin_sed -i /^\[\t\s\]*PrivateData\[\t\s\]*=/Id $config_file |
| exec $bin_echo -e "\nMCSPlugin=mcs/group" >> $config_file |
| exec $bin_echo MCSParameters=enforced,noselect,privatedata:$groups_name >> $config_file |
| exec $bin_echo PrivateData=jobs,nodes >> $config_file |
| reconfigure -fail |
| |
| |
| ###### Check that sbatch uses mcs-label=group ###### |
| log_info "---Checking sbatch uses mcs-label=group---" |
| |
| make_bash_script $tmp_job "sleep 10" |
| |
| set job_id [submit_job -fail "-N1 -o/dev/null -t1 $tmp_job"] |
| |
| set mcslabel "" |
| set node "" |
| wait_for -subtest {$mcslabel == $group1 && $node != ""} { |
| set job [dict get [get_jobs] $job_id] |
| set mcslabel [dict_getdef $job "MCS_label" ""] |
| set node [dict_getdef $job "NodeList" ""] |
| } |
| |
| |
| # |
| # verify MCS of nodes |
| # |
| set mcslabel "" |
| wait_for -subtest {$mcslabel == "N/A"} { |
| set mcslabel [get_node_param $node "MCS_label"] |
| } |