Skip to content

Commit d6507e9

Browse files
committed
tests: add jgf_shorthand graph update test
Problem: there are no tests for reading in jgf_shorthand and using it to update the graph. Add a basic test.
1 parent 700646e commit d6507e9

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

t/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ set(ALL_TESTS
7373
t3038-resource-flexible.t
7474
t3039-resource-force-load-format.t
7575
t3040-jgf-shorthand-match-format.t
76+
t3041-jgf-shorthand-load-format.t
7677
t3300-system-dontblock.t
7778
t3301-system-latestart.t
7879
t4000-match-params.t
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 9999
2+
resources:
3+
- type: node
4+
count: 10
5+
with:
6+
- type: slot
7+
count: 1
8+
label: default
9+
with:
10+
- type: core
11+
count: 8
12+
- type: gpu
13+
count: 2
14+
attributes:
15+
system:
16+
duration: 3600
17+
tasks:
18+
- command: [ \"app\" ]
19+
slot: default
20+
count:
21+
per_slot: 1
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
3+
test_description='Test the jgf_shorthand load format'
4+
5+
. $(dirname $0)/sharness.sh
6+
7+
query="../../resource/utilities/resource-query"
8+
jobspec="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/load_format/t3041.yaml"
9+
10+
test_expect_success 'Generate rv1 with .scheduling key' '
11+
flux R encode --hosts=compute[1-10] --cores=0-7 --gpu=0-1 | jq . > R.json &&
12+
cat R.json | flux ion-R encode > R_JGF.json &&
13+
jq -S "del(.execution.starttime, .execution.expiration)" R.json > R.norm.json
14+
'
15+
16+
test_expect_success 'resource_query can be loaded with jgf_shorthand reader' '
17+
cat > match_jobspec_cmd <<-EOF &&
18+
match allocate ${jobspec}
19+
quit
20+
EOF
21+
jq -S .scheduling R_JGF.json > JGF.json &&
22+
${query} -L JGF.json -f jgf_shorthand -F rv1_nosched -t R1.out -P high < match_jobspec_cmd &&
23+
head -n1 R1.out | jq -S "del(.execution.starttime, .execution.expiration)" > r_match.json &&
24+
test_cmp r_match.json R.norm.json
25+
'
26+
27+
test_expect_success 'generate jgf_shorthand to use to update regular JGF' '
28+
${query} -L JGF.json -f jgf_shorthand -F jgf_shorthand -t jgf1.out -P lonodex < match_jobspec_cmd &&
29+
head -n1 jgf1.out | jq -S . > shorthand.json &&
30+
test_must_fail grep core shorthand.json > /dev/null &&
31+
test_must_fail grep gpu shorthand.json > /dev/null &&
32+
grep node shorthand.json > /dev/null &&
33+
grep compute1 shorthand.json > /dev/null
34+
'
35+
36+
test_expect_success 'update graph to allocate a job using jgf_shorthand' '
37+
cat > update_allocate_cmd <<-EOF &&
38+
update allocate jgf_shorthand shorthand.json 0 0 5
39+
f sched-now=allocated
40+
quit
41+
EOF
42+
jq -S .scheduling R_JGF.json > JGF.json &&
43+
${query} -L JGF.json -f jgf_shorthand -F jgf -t jgf2.out -P high < update_allocate_cmd &&
44+
tail -n4 jgf2.out | head -n1 > allocated.json
45+
'
46+
47+
test_expect_success 'JGF output shows all cores and gpus allocated' '
48+
grep core allocated.json > /dev/null &&
49+
grep gpu allocated.json > /dev/null &&
50+
grep node allocated.json > /dev/null &&
51+
grep compute1 allocated.json > /dev/null &&
52+
jq -e ".graph.nodes[] | select(.metadata.type == \"core\") | .id" allocated.json > cores.json &&
53+
test 80 -eq $(cat cores.json | wc -l) &&
54+
jq -e ".graph.nodes[] | select(.metadata.type == \"gpu\") | .id" allocated.json > gpus.json &&
55+
test 20 -eq $(cat gpus.json | wc -l)
56+
'
57+
58+
test_done

0 commit comments

Comments
 (0)