Skip to content
Snippets Groups Projects
Commit c8a43fe5 authored by Morris Jette's avatar Morris Jette
Browse files

Add checks for srun and sbatch --export options

parent 0826fe98
No related branches found
No related tags found
No related merge requests found
...@@ -38,16 +38,40 @@ set test_env_val 123 ...@@ -38,16 +38,40 @@ set test_env_val 123
set exit_code 0 set exit_code 0
set matches 0 set matches 0
global env
set env($test_env_name) $test_env_val
print_header $test_id print_header $test_id
# #
# Spawn a job via srun to print environment variables # Spawn a job via srun to print environment variables
# #
set timeout $max_job_delay set timeout $max_job_delay
set srun_pid [spawn $srun -N1 --export=$test_env_name=$test_env_val -t1 $bin_env]
expect {
-re "$test_env_name=($number)" {
if {$expect_out(1,string) == $test_env_val} {
incr matches
}
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
set exit_code 1
}
eof {
wait
}
}
if {$matches != 1} {
send_user "\nFAILURE: Environment variables not propagated ($matches != 1)\n"
exit 1
}
#
# Spawn a job via srun to print environment variables
#
global env
set env($test_env_name) $test_env_val set env($test_env_name) $test_env_val
set matches 0
set srun_pid [spawn $srun -N1 -t1 $bin_env] set srun_pid [spawn $srun -N1 -t1 $bin_env]
expect { expect {
-re "$test_env_name=($number)" { -re "$test_env_name=($number)" {
...@@ -65,10 +89,61 @@ expect { ...@@ -65,10 +89,61 @@ expect {
wait wait
} }
} }
if {$matches != 1} {
send_user "\nFAILURE: Environment variables not propagated ($matches != 1)\n"
exit 1
}
#
# Spawn a job via srun to print environment variables with --export=ALL
#
set matches 0
set srun_pid [spawn $srun -N1 -t1 --export=ALL $bin_env]
expect {
-re "$test_env_name=($number)" {
if {$expect_out(1,string) == $test_env_val} {
incr matches
}
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
set exit_code 1
}
eof {
wait
}
}
if {$matches != 1} { if {$matches != 1} {
send_user "\nFAILURE: Environment variables not propagated\n" send_user "\nFAILURE: Environment variables not propagated ($matches != 1)\n"
set exit_code 1 exit 1
}
#
# Spawn a job via srun to print environment variables with --export=NONE
#
set matches 0
set srun_pid [spawn $srun -N1 -t1 --export=NONE $bin_env]
expect {
-re "$test_env_name=($number)" {
if {$expect_out(1,string) == $test_env_val} {
incr matches
}
exp_continue
}
timeout {
send_user "\nFAILURE: srun not responding\n"
slow_kill $srun_pid
set exit_code 1
}
eof {
wait
}
}
if {$matches != 0} {
send_user "\nFAILURE: Environment variables not propagated ($matches != 0)\n"
exit 1
} }
if {$exit_code == 0} { if {$exit_code == 0} {
......
...@@ -39,7 +39,6 @@ set exit_code 0 ...@@ -39,7 +39,6 @@ set exit_code 0
set file_in "test$test_id.input" set file_in "test$test_id.input"
set file_out "test$test_id.output" set file_out "test$test_id.output"
set job_id 0 set job_id 0
set matches 0
global env global env
set env($test_env_name) $test_env_val set env($test_env_name) $test_env_val
...@@ -58,6 +57,68 @@ make_bash_script $file_in " ...@@ -58,6 +57,68 @@ make_bash_script $file_in "
# #
# Spawn a job via sbatch to print environment variables # Spawn a job via sbatch to print environment variables
# #
set matches 0
spawn $sbatch -N1 -t1 --export=$test_env_name=$test_env_val --output=$file_out $file_in
expect {
-re "Submitted batch job ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: sbatch not responding\n"
set exit_code 1
exp_continue
}
eof {
wait
}
}
if { $job_id == 0 } {
send_user "\nFAILURE: failed to submit job\n"
exit 1
}
#
# Wait for job to complete
#
if {[wait_for_job $job_id "DONE"] != 0} {
send_user "\nFAILURE: waiting for job to complete\n"
cancel_job $job_id
set exit_code 1
}
#
# Check for desired output
#
if {[wait_for_file $file_out] != 0} {
send_user "\nFAILURE: Output file $file_out is missing\n"
exit 1
}
spawn $bin_cat $file_out
expect {
-re "$test_env_name=($number)" {
if {$expect_out(1,string) == $test_env_val} {
incr matches
} else {
send_user "\nNO MATCHX${expect_out(1,string)}X${test_env_val}X\n"
}
exp_continue
}
eof {
wait
}
}
# Match to "SLURM_EXPORT_ENV=TEST_ENV_17.14=123" and "TEST_ENV_17.14=123"
if {$matches != 2} {
send_user "\nFAILURE: Environment variables not propagated from command line ($matches != 2)\n"
exit 1
}
#
# Spawn a job via sbatch to print environment variables
#
exec $bin_rm -f $file_out
set matches 0
set env($test_env_name) $test_env_val set env($test_env_name) $test_env_val
spawn $sbatch -N1 -t1 --output=$file_out $file_in spawn $sbatch -N1 -t1 --output=$file_out $file_in
expect { expect {
...@@ -107,12 +168,129 @@ expect { ...@@ -107,12 +168,129 @@ expect {
wait wait
} }
} }
if {$matches != 1} {
send_user "\nFAILURE: Environment variables not propagated ($matches != 1)\n"
exit 1
}
#
# Spawn a job via sbatch to print environment variables with --export=ALL
#
exec $bin_rm -f $file_out
set matches 0
set env($test_env_name) $test_env_val
spawn $sbatch -N1 -t1 --export=ALL --output=$file_out $file_in
expect {
-re "Submitted batch job ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: sbatch not responding\n"
set exit_code 1
exp_continue
}
eof {
wait
}
}
if { $job_id == 0 } {
send_user "\nFAILURE: failed to submit job\n"
exit 1
}
#
# Wait for job to complete
#
if {[wait_for_job $job_id "DONE"] != 0} {
send_user "\nFAILURE: waiting for job to complete\n"
cancel_job $job_id
set exit_code 1
}
#
# Check for desired output
#
if {[wait_for_file $file_out] != 0} {
send_user "\nFAILURE: Output file $file_out is missing\n"
exit 1
}
spawn $bin_cat $file_out
expect {
-re "$test_env_name=($number)" {
if {$expect_out(1,string) == $test_env_val} {
incr matches
}
exp_continue
}
eof {
wait
}
}
if {$matches != 1} { if {$matches != 1} {
send_user "\nFAILURE: Environment variables not propagated\n" send_user "\nFAILURE: Environment variables not propagated ($matches != 1)\n"
exit 1
}
#
# Spawn a job via sbatch to print environment variables with --export=NONE
#
exec $bin_rm -f $file_out
set matches 0
set env($test_env_name) $test_env_val
spawn $sbatch -N1 -t1 --export=NONE --output=$file_out $file_in
expect {
-re "Submitted batch job ($number)" {
set job_id $expect_out(1,string)
exp_continue
}
timeout {
send_user "\nFAILURE: sbatch not responding\n"
set exit_code 1
exp_continue
}
eof {
wait
}
}
if { $job_id == 0 } {
send_user "\nFAILURE: failed to submit job\n"
exit 1
}
#
# Wait for job to complete
#
if {[wait_for_job $job_id "DONE"] != 0} {
send_user "\nFAILURE: waiting for job to complete\n"
cancel_job $job_id
set exit_code 1 set exit_code 1
} }
#
# Check for desired output
#
if {[wait_for_file $file_out] != 0} {
send_user "\nFAILURE: Output file $file_out is missing\n"
exit 1
}
spawn $bin_cat $file_out
expect {
-re "$test_env_name=($number)" {
if {$expect_out(1,string) == $test_env_val} {
incr matches
}
exp_continue
}
eof {
wait
}
}
if {$matches != 0} {
send_user "\nFAILURE: Environment variables were propagated ($matches != 0)\n"
exit 1
}
if {$exit_code == 0} { if {$exit_code == 0} {
exec $bin_rm -f $file_in $file_out exec $bin_rm -f $file_in $file_out
send_user "\nSUCCESS\n" send_user "\nSUCCESS\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment