-
Notifications
You must be signed in to change notification settings - Fork 41
/
t3025-resource-find.t
executable file
·312 lines (285 loc) · 11 KB
/
t3025-resource-find.t
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#!/bin/sh
test_description='Test Resource Find On Tiny Machine Configuration'
. $(dirname $0)/sharness.sh
sock1_job="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/find/sock1.yaml"
c1g1m1_job="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/find/c1g1m1.yaml"
node1_job="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/find/node1.yaml"
full_job="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/find/full.yaml"
cmd_dir="${SHARNESS_TEST_SRCDIR}/data/resource/commands/find"
exp_dir="${SHARNESS_TEST_SRCDIR}/data/resource/expected/find"
grugs="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/tiny.graphml"
query="../../resource/utilities/resource-query"
skip_all_unless_have jq
remove_times() {
cat ${1} | jq 'del (.execution.starttime) | del (.execution.expiration)'
}
test_expect_success 'a jobspec requesting all resources works' '
cat > cmds001 <<-EOF &&
match allocate ${full_job}
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t full.out < cmds001 &&
cat full.out | grep -v "INFO" > full.json &&
remove_times full.json > full.filt.json
'
test_expect_success 'find status=up returns the entire system' '
cat > cmds002 <<-EOF &&
find status=up
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t up.out < cmds002 &&
cat up.out | grep -v "INFO" > up.json &&
remove_times up.json > up.filt.json &&
test_cmp up.filt.json full.filt.json
'
test_expect_success 'mark down 3 cores and find status=down' '
cat > cmds003 <<-EOF &&
set-status /tiny0/rack0/node0/socket0/core3 down
set-status /tiny0/rack0/node0/socket0/core4 down
set-status /tiny0/rack0/node0/socket0/core7 down
find status=down
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t down.out < cmds003 &&
cat down.out | grep -v "INFO" > down.json &&
cores=$(cat down.json | jq " .execution.R_lite[].children.core ") &&
test ${cores} = "\"3-4,7\""
'
test_expect_success 'mark down all but 1 socket and find status=up' '
cat > cmds004 <<-EOF &&
set-status /tiny0/rack0/node0 down
set-status /tiny0/rack0/node1/socket1 down
find status=up
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t down2.out < cmds004 &&
cat down2.out | grep -v "INFO" > down2.json &&
cores=$(cat down2.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat down2.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-17\"" &&
test ${gpus} = "\"0\""
'
test_expect_success 'mark down 1 node and find status=up and status=down' '
cat > cmds005 <<-EOF &&
set-status /tiny0/rack0/node1 down
find status=up and status=down
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t down3.out < cmds005 &&
test $(wc -l <down3.out) -eq 3
'
test_expect_success 'mark down 1 node and find status=up or status=down' '
cat > cmds006 <<-EOF &&
set-status /tiny0/rack0/node0 down
find status=up or status=down
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t down4.out < cmds006 &&
cat down4.out | grep -v "INFO" > down4.json &&
remove_times down4.json > down4.filt.json &&
test_cmp down4.filt.json full.filt.json
'
test_expect_success 'allocate 1 core and 1 gpu and find sched-now=allocated' '
cat > cmds007 <<-EOF &&
match allocate ${c1g1m1_job}
find sched-now=allocated
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t alloc.out < cmds007 &&
cat alloc.out | awk "{if(NR==1) print \$0}" > alloc.1.json &&
cat alloc.out | awk "{if(NR==7) print \$0}" > alloc.2.json &&
remove_times alloc.1.json > alloc.1.filt.json &&
remove_times alloc.2.json > alloc.2.filt.json &&
test_cmp alloc.1.filt.json alloc.2.filt.json
'
test_expect_success 'allocate 1 node and 1 socket and find sched-now=free' '
cat > cmds008 <<-EOF &&
match allocate ${node1_job}
match allocate ${sock1_job}
find sched-now=free
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t alloc2.out < cmds008 &&
cat alloc2.out | tail -n4 | grep -v "INFO" > alloc2.1.json &&
cores=$(cat alloc2.1.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat alloc2.1.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-17\"" &&
test ${gpus} = "\"0\""
'
test_expect_success 'reserve 1 core and 1 gpu and find sched-future=reserved' '
cat > cmds009 <<-EOF &&
match allocate ${full_job}
match allocate_orelse_reserve ${c1g1m1_job}
find sched-future=reserved
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t reserve.out < cmds009 &&
cat reserve.out | tail -n4 | grep -v "INFO" > reserve.json &&
cores=$(cat reserve.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat reserve.json | jq " .execution.R_lite[].children.gpu ") &&
echo $cores > cores &&
echo $gpus > gpus &&
test ${cores} = "\"35\"" &&
test ${gpus} = "\"1\""
'
test_expect_success 'reserve 1 node and 1 socket and find sched-future=free' '
cat > cmds010 <<-EOF &&
match allocate ${full_job}
match allocate_orelse_reserve ${node1_job}
match allocate_orelse_reserve ${sock1_job}
find sched-future=free
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t reserve2.out < cmds010 &&
cat reserve2.out | tail -n4 | grep -v "INFO" > reserve2.json &&
cores=$(cat reserve2.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat reserve2.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-17\"" &&
test ${gpus} = "\"0\""
'
test_expect_success 'compound expression (status=down sched-now=allocated) works' '
cat > cmds011 <<-EOF &&
match allocate ${full_job}
set-status /tiny0/rack0/node0 down
match allocate_orelse_reserve ${node1_job}
match allocate_orelse_reserve ${sock1_job}
find status=down sched-now=allocated
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t mixed.out < cmds011 &&
cat mixed.out | tail -n4 | grep -v "INFO" > mixed.json &&
cores=$(cat mixed.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat mixed.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-35\"" &&
test ${gpus} = "\"0-1\""
'
test_expect_success 'compound expression (sched-future=reserved status=up) works' '
cat > cmds012 <<-EOF &&
match allocate ${full_job}
set-status /tiny0/rack0/node0 down
match allocate_orelse_reserve ${node1_job}
match allocate_orelse_reserve ${sock1_job}
find sched-future=reserved status=up
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t mixed2.out < cmds012 &&
cat mixed2.out | tail -n4 | grep -v "INFO" > mixed2.json &&
cores=$(cat mixed2.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat mixed2.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-35\"" &&
test ${gpus} = "\"0-1\""
'
# NOTE: this should never happen because on second DOWN, the reservation
# will be freed by the qmanager. But fluxion resource infrastructure
# is external driven so this condition can be tested.
test_expect_success 'status=up (sched-now=allocated sched-future=reserved)' '
cat > cmds013 <<-EOF &&
match allocate ${full_job}
set-status /tiny0/rack0/node0 down
match allocate_orelse_reserve ${sock1_job}
set-status /tiny0/rack0/node1/socket1/core19 down
find status=up (sched-now=allocated sched-future=reserved)
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t mixed3.out < cmds013 &&
cat mixed3.out | tail -n4 | grep -v "INFO" > mixed3.json &&
cores=$(cat mixed3.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat mixed3.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"18,20-35\"" &&
test ${gpus} = "\"1\""
'
test_expect_success 'status=up sched-now=allocated or sched-future=reserved)' '
cat > cmds014 <<-EOF &&
match allocate ${node1_job}
match allocate ${sock1_job}
set-status /tiny0/rack0/node1 down
set-status /tiny0/rack0/node0/socket1 down
match allocate ${sock1_job}
match allocate_orelse_reserve ${sock1_job}
set-status /tiny0/rack0/node0/socket1 up
set-status /tiny0/rack0/node0/socket1/core19 down
set-status /tiny0/rack0/node0/socket0/core16 down
find (status=up and sched-now=allocated) or sched-future=reserved
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t mixed4.out < cmds014 &&
cat mixed4.out | tail -n4 | grep -v "INFO" > mixed4.json &&
cores=$(cat mixed4.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat mixed4.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-18,20-35\"" &&
test ${gpus} = "\"0-1\""
'
test_expect_success 'status=up (sched-now=allocated or sched-future=reserved)' '
cat > cmds015 <<-EOF &&
match allocate ${node1_job}
match allocate ${sock1_job}
set-status /tiny0/rack0/node1 down
set-status /tiny0/rack0/node0/socket1 down
match allocate_orelse_reserve ${sock1_job}
set-status /tiny0/rack0/node0/socket1 up
set-status /tiny0/rack0/node0/socket1/core19 down
set-status /tiny0/rack0/node0/socket0/core16 down
find status=up and (sched-now=allocated or sched-future=reserved)
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t mixed5.out < cmds015 &&
cat mixed5.out | tail -n4 | grep -v "INFO" > mixed5.json &&
cores=$(cat mixed5.json | jq " .execution.R_lite[].children.core ") &&
gpus=$(cat mixed5.json | jq " .execution.R_lite[].children.gpu ") &&
test ${cores} = "\"0-15,17-18,20-35\"" &&
test ${gpus} = "\"0-1\""
'
test_expect_success 'mix upper and lower cases for predicate values' '
cat > cmds016 <<-EOF &&
set-status /tiny0/rack0/node0 down
find status=UP or status=Down
quit
EOF
${query} -L ${grugs} -F rv1_nosched -S CA -P high -t down5.out < cmds016 &&
cat down5.out | grep -v "INFO" > down5.json &&
remove_times down5.json > down5.filt.json &&
test_cmp down5.filt.json full.filt.json
'
test_expect_success 'find status=up works with simple writer' '
cat > cmds017 <<-EOF &&
set-status /tiny0/rack0/node0/socket0/core0 down
find status=down
quit
EOF
${query} -L ${grugs} -F simple -S CA -P high -t down17.out < cmds017 &&
grep core0 down17.out &&
grep node0 down17.out
'
test_expect_success 'find status=up works with pretty_simple writer' '
cat > cmds018 <<-EOF &&
set-status /tiny0/rack0/node0/socket0/core0 down
find status=down
quit
EOF
${query} -L ${grugs} -F pretty_simple -S CA -P high -t down18.out \
< cmds018 &&
grep core0 down18.out &&
grep node0 down18.out
'
test_expect_success 'find status=up works with jgf writer' '
cat > cmds019 <<-EOF &&
set-status /tiny0/rack0/node0/socket0/core0 down
find status=down
quit
EOF
${query} -L ${grugs} -F jgf -S CA -P high -t down19.out < cmds019 &&
grep core0 down19.out &&
grep node0 down19.out
'
test_expect_success 'find status=up works with rlite writer' '
cat > cmds020 <<-EOF &&
set-status /tiny0/rack0/node0/socket0/core0 down
find status=down
quit
EOF
${query} -L ${grugs} -F rlite -S CA -P high -t down20.out < cmds020 &&
grep -v INFO down20.out > down20.filt.out &&
core=$(cat down20.filt.out | jq " .[].children.core ") &&
test ${core} = "\"0\""
'
test_done