|
| 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