File: test38.4

package info (click to toggle)
slurm-wlm 22.05.8-4%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 48,492 kB
  • sloc: ansic: 475,246; exp: 69,020; sh: 8,862; javascript: 6,528; python: 6,444; makefile: 4,185; perl: 4,069; pascal: 131
file content (167 lines) | stat: -rwxr-xr-x 4,248 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env expect
############################################################################
# Purpose: Validate salloc hetjob environment variables.
#
# Reqs:    1. Using slurmdbd accounting storage type and is up
#          2. controllers are up and running.
############################################################################
# Copyright (C) 2017 SchedMD LLC.
# Written by Isaac Hartung <ihartung@schedmd.com>
#
# 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 timeout     60
set job_id      0
set file_out    "$test_dir/output"

if {[get_config_param "SchedulerType"] ne "sched/backfill"} {
	skip "This test requires SchedulerType = sched/backfill"
}

# find out if we have enough nodes to test functionality
set node_count [get_partition_param [default_partition] "TotalNodes"]
if { $node_count < 3 } {
	skip "Insufficient nodes in default partition ($node_count < 3)"
}

proc salloc {} {
	global number salloc bin_sleep file_out job_id

	set matches 0
	set job_id  0
	set command "$salloc --cpus-per-task=4 --mem-per-cpu=10 --ntasks=1 -t1 :\
			     --cpus-per-task=2 --mem-per-cpu=2  --ntasks=1 -t1 :\
			     --cpus-per-task=1 --mem-per-cpu=6  --ntasks=1 -t1 \
				env"

	log_file -noappend $file_out
	spawn {*}$command
	expect {
		-re "Job submit/allocate failed" {
			skip "Unable to execute test due to system configuration"
		}
		-re "Granted job allocation ($number)" {
			incr matches
			if {$job_id == 0} {
				set job_id $expect_out(1,string)
			}
			exp_continue
		}

		timeout {
			fail "salloc not responding"
		}
	}
	log_file
}

proc test_env {value} {
	global bin_grep file_out

	set matches 0
	log_user 0
	spawn $bin_grep "$value" $file_out
	expect {
		-re "$value" {
			incr matches
			exp_continue
		}
		eof {
			wait
		}
	}
	log_user 1
	if {$matches != 1} {
		fail "Output of env $value incorrect ($matches != 1)"
	}
}

proc cleanup { } {
	global job_id

	cancel_job $job_id
}

# Start test

log_info "\n################################################################\n"
log_info "Salloc hetjob and verify output from scontrol show job"
log_info "\n################################################################\n"

salloc
if {$job_id == 0} {
	fail "Error submitting job ($job_id)"
}

#
# Check for desired output
#
wait_for_job -fail $job_id DONE
wait_for_file -fail $file_out

set matches 0
spawn $bin_grep "SLURM_HET_SIZE" $file_out
expect {
	-re "SLURM_HET_SIZE=3" {
		incr matches
		exp_continue
	}
	eof {
		wait
	}
}
if {$matches != 1} {
	fail "Output of env SLURM_HET_SIZE=3 incorrect ($matches != 1)"
}

set matches 0
log_user 0
spawn $bin_grep "SLURM_JOB_PARTITION_HET_GROUP" $file_out
expect {
	-re "SLURM_JOB_PARTITION_HET_GROUP" {
		incr matches
		exp_continue
	}
	eof {
		wait
	}
}
log_user 1
if {$matches != 3} {
	fail "Output of env SLURM_JOB_PARTITION_HET_GROUP incorrect ($matches != 3)"
}

test_env "SLURM_CPUS_PER_TASK_HET_GROUP_0=4"
test_env "SLURM_CPUS_PER_TASK_HET_GROUP_1=2"
test_env "SLURM_CPUS_PER_TASK_HET_GROUP_2=1"

test_env "SLURM_JOB_ID_HET_GROUP_0=$job_id"
test_env "SLURM_JOB_ID_HET_GROUP_1="
test_env "SLURM_JOB_ID_HET_GROUP_2="

test_env "SLURM_MEM_PER_CPU_HET_GROUP_0=10"
test_env "SLURM_MEM_PER_CPU_HET_GROUP_1=2"
test_env "SLURM_MEM_PER_CPU_HET_GROUP_2=6"

test_env "SLURM_NTASKS_HET_GROUP_0=1"
test_env "SLURM_NTASKS_HET_GROUP_1=1"
test_env "SLURM_NTASKS_HET_GROUP_2=1"