File: test12.3

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 (197 lines) | stat: -rwxr-xr-x 5,671 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
#          Test sacct filtering of records by account and job name.
############################################################################
# Copyright (C) 2012 SchedMD LLC.
# Copyright (C) 2008-2010 Lawrence Livermore National Security.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Joseph Donaghy <donaghy1@llnl.gov> and
#            Nathan Yee <nyee32@schedmd.com>
# 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
source ./globals_accounting
source ./inc12.3.1
source ./inc12.3.2

set job_id_1    0
set job_id_2    0
set job_name_1  "JOB1"
set job_name_2  "JOB2"
set test_acct	"${test_name}-account.1"
set step_id     0

if {[get_config_param "FrontendName"] ne "MISSING"} {
	skip "This test can't be run on a front end system"
}

#
# 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_admin_level] ne "Administrator"} {
	skip "This test can't be run without being an Accounting administrator. Use: sacctmgr mod user \$USER set admin=admin"
}

#
# Make sure we have enough nodes to test functionality
#
set nodes [get_nodes_by_request "-N3"]
if {[llength $nodes] != 3} {
	skip "This test requires to be able to run a job on as least 3 nodes"
}
lassign $nodes node1 node2 node3

proc cleanup {} {
	global sacctmgr test_acct

	run_command "$sacctmgr -i delete account $test_acct"
}

#
# Identify the user and his current default account
#
set acct_name ""
set user_name [get_my_user_name]
spawn $sacctmgr show user $user_name
expect {
	-re "$user_name *($re_word_str)" {
		set acct_name $expect_out(1,string)
		exp_continue
	}
	timeout {
		fail "sacctmgr add not responding"
	}
	eof {
		wait
	}
}

#
# Use sacctmgr to add a test account
#
set aamatches 0
spawn $sacctmgr -i add account $test_acct
expect {
	-re "Adding Account" {
		incr aamatches
		exp_continue
	}
	-re "Nothing new added" {
		log_warn "Vestigial account $test_acct found"
		incr aamatches
		exp_continue
	}
	timeout {
		fail "sacctmgr add not responding"
	}
	eof {
		wait
	}
}
if {$aamatches != 1} {
	fail "sacctmgr had a problem adding account ($aamatches != 1)"
}

#
# Add self to this new account
#
spawn $sacctmgr -i create user name=$user_name account=$test_acct
expect {
	 timeout {
		fail "sacctmgr add not responding"
	}
	eof {
		wait
	}
}

#
# Submit two slurm jobs to capture job info
#
set job_1_node_inx 0
set timeout $max_job_delay
spawn $srun -N2 -w$node1,$node2 -t1 -A $test_acct -J $job_name_1 -v $bin_id
expect {
	-re "launching StepId=($number)\\.$re_word_str on host ($re_word_str)," {
		set job_id_1 $expect_out(1,string)
		incr job_1_node_inx
		exp_continue
	}
	timeout {
		fail "srun not responding"
	}
	eof {
		wait
	}
}
subtest {$job_1_node_inx == 2} "Verify host count for job 1" "srun host count bad ($job_1_node_inx != 2)"

#
# Second job includes one node from the first job and another different node
#
set job_2_node_inx 0
spawn $srun -N2 -w$node2,$node3 -t1 -A $test_acct -J $job_name_2 -v $bin_id
expect {

	-re "launching StepId=($number)\\.$re_word_str on host ($re_word_str)," {
		set job_id_2 $expect_out(1,string)
		incr job_2_node_inx
		exp_continue
	}
	timeout {
		fail "srun not responding"
	}
	eof {
		wait
	}
}
subtest {$job_2_node_inx == 2} "Verify host count for job 2" "srun host count bad ($job_2_node_inx != 2)"

#
# Wait for accounting data to be propagated to slurmdbd
# NOTE: Sometimes the complete RPC reaches the DB before the start RPC.
#       We use sacct -S to ensure that the start time is stored in the DB.
#       Note that subsequent sacct -N queries will need start time stored to
#       work properly because they need that to search for active node indexes
#       along with the events table.
#
if [wait_for_command_match "$sacct -A ${test_name}-account.1 --name=$job_name_1 -X -n -P -j $job_id_1 -S now-60 -o jobid,jobname" "$job_id_1.$job_name_1"] {
	fail "Accounting data for job 1 ($job_id_1) not propogated to slurmdbd"
}
if [wait_for_command_match "$sacct -A ${test_name}-account.1 --name=$job_name_2 -X -n -P -j $job_id_2 -S now-60 -o jobid,jobname" "$job_id_2.$job_name_2"] {
	fail "Accounting data for job 2 ($job_id_2) not propogated to slurmdbd"
}

# Only run these sub-tests if we haven't failed already
if {[get_subtest_fail_count] == 0} {
	#
	# Execute sub-tests based upon these jobs
	#
	inc12_3_1 $job_id_1 $job_id_2 $job_name_1 $job_name_2 $test_acct

	inc12_3_2 $job_id_1 $job_id_2 $job_name_1 $job_name_2 $test_acct \
		$node1 $node2 $node3
}