From ed2e53bcd845bd07821b1156662b50015cfdcd9e Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Mon, 16 Dec 2024 19:18:11 -0800 Subject: [PATCH] testsuite: add tests for writing status based on jobid and agfilter Problem: the testsuite doesn't have tests for the new find behavior Add tests. --- .../find-format/jgf.expected.agfilter.json | 41 +++ .../jgf.expected.jobid.alloc.agfilter.json | 41 +++ .../find-format/jgf.expected.jobid.alloc.json | 275 ++++++++++++++++++ .../find-format/jgf.expected.jobid.rsv.json | 275 ++++++++++++++++++ .../jgf.expected.jobid.span.agfilter.json | 41 +++ .../find-format/jgf.expected.jobid.span.json | 35 +++ .../jgf.expected.jobid.tag.agfilter.json | 41 +++ .../find-format/jgf.expected.jobid.tag.json | 275 ++++++++++++++++++ t/t1015-find-format.t | 71 +++++ 9 files changed, 1095 insertions(+) create mode 100644 t/data/resource/expected/find-format/jgf.expected.agfilter.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.alloc.agfilter.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.alloc.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.rsv.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.span.agfilter.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.span.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.tag.agfilter.json create mode 100644 t/data/resource/expected/find-format/jgf.expected.jobid.tag.json diff --git a/t/data/resource/expected/find-format/jgf.expected.agfilter.json b/t/data/resource/expected/find-format/jgf.expected.agfilter.json new file mode 100644 index 000000000..b549f9d97 --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.agfilter.json @@ -0,0 +1,41 @@ +{ + "graph": { + "nodes": [ + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + }, + "agfilter": { + "core": "used:0, total:16" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + }, + "agfilter": { + "core": "used:0, total:16" + } + } + } + ], + "edges": [ + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.alloc.agfilter.json b/t/data/resource/expected/find-format/jgf.expected.jobid.alloc.agfilter.json new file mode 100644 index 000000000..2d659a70f --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.alloc.agfilter.json @@ -0,0 +1,41 @@ +{ + "graph": { + "nodes": [ + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + }, + "agfilter": { + "core": "used:16, total:16" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + }, + "agfilter": { + "core": "used:16, total:16" + } + } + } + ], + "edges": [ + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.alloc.json b/t/data/resource/expected/find-format/jgf.expected.jobid.alloc.json new file mode 100644 index 000000000..01bcf228e --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.alloc.json @@ -0,0 +1,275 @@ +{ + "graph": { + "nodes": [ + { + "id": "2", + "metadata": { + "type": "core", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core0" + } + } + }, + { + "id": "3", + "metadata": { + "type": "core", + "id": 1, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core1" + } + } + }, + { + "id": "4", + "metadata": { + "type": "core", + "id": 2, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core2" + } + } + }, + { + "id": "5", + "metadata": { + "type": "core", + "id": 3, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core3" + } + } + }, + { + "id": "6", + "metadata": { + "type": "core", + "id": 4, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core4" + } + } + }, + { + "id": "7", + "metadata": { + "type": "core", + "id": 5, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core5" + } + } + }, + { + "id": "8", + "metadata": { + "type": "core", + "id": 6, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core6" + } + } + }, + { + "id": "9", + "metadata": { + "type": "core", + "id": 7, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core7" + } + } + }, + { + "id": "10", + "metadata": { + "type": "core", + "id": 8, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core8" + } + } + }, + { + "id": "11", + "metadata": { + "type": "core", + "id": 9, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core9" + } + } + }, + { + "id": "12", + "metadata": { + "type": "core", + "id": 10, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core10" + } + } + }, + { + "id": "13", + "metadata": { + "type": "core", + "id": 11, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core11" + } + } + }, + { + "id": "14", + "metadata": { + "type": "core", + "id": 12, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core12" + } + } + }, + { + "id": "15", + "metadata": { + "type": "core", + "id": 13, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core13" + } + } + }, + { + "id": "16", + "metadata": { + "type": "core", + "id": 14, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core14" + } + } + }, + { + "id": "17", + "metadata": { + "type": "core", + "id": 15, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core15" + } + } + }, + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + } + } + } + ], + "edges": [ + { + "source": "1", + "target": "2" + }, + { + "source": "1", + "target": "3" + }, + { + "source": "1", + "target": "4" + }, + { + "source": "1", + "target": "5" + }, + { + "source": "1", + "target": "6" + }, + { + "source": "1", + "target": "7" + }, + { + "source": "1", + "target": "8" + }, + { + "source": "1", + "target": "9" + }, + { + "source": "1", + "target": "10" + }, + { + "source": "1", + "target": "11" + }, + { + "source": "1", + "target": "12" + }, + { + "source": "1", + "target": "13" + }, + { + "source": "1", + "target": "14" + }, + { + "source": "1", + "target": "15" + }, + { + "source": "1", + "target": "16" + }, + { + "source": "1", + "target": "17" + }, + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.rsv.json b/t/data/resource/expected/find-format/jgf.expected.jobid.rsv.json new file mode 100644 index 000000000..01bcf228e --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.rsv.json @@ -0,0 +1,275 @@ +{ + "graph": { + "nodes": [ + { + "id": "2", + "metadata": { + "type": "core", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core0" + } + } + }, + { + "id": "3", + "metadata": { + "type": "core", + "id": 1, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core1" + } + } + }, + { + "id": "4", + "metadata": { + "type": "core", + "id": 2, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core2" + } + } + }, + { + "id": "5", + "metadata": { + "type": "core", + "id": 3, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core3" + } + } + }, + { + "id": "6", + "metadata": { + "type": "core", + "id": 4, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core4" + } + } + }, + { + "id": "7", + "metadata": { + "type": "core", + "id": 5, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core5" + } + } + }, + { + "id": "8", + "metadata": { + "type": "core", + "id": 6, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core6" + } + } + }, + { + "id": "9", + "metadata": { + "type": "core", + "id": 7, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core7" + } + } + }, + { + "id": "10", + "metadata": { + "type": "core", + "id": 8, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core8" + } + } + }, + { + "id": "11", + "metadata": { + "type": "core", + "id": 9, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core9" + } + } + }, + { + "id": "12", + "metadata": { + "type": "core", + "id": 10, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core10" + } + } + }, + { + "id": "13", + "metadata": { + "type": "core", + "id": 11, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core11" + } + } + }, + { + "id": "14", + "metadata": { + "type": "core", + "id": 12, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core12" + } + } + }, + { + "id": "15", + "metadata": { + "type": "core", + "id": 13, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core13" + } + } + }, + { + "id": "16", + "metadata": { + "type": "core", + "id": 14, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core14" + } + } + }, + { + "id": "17", + "metadata": { + "type": "core", + "id": 15, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core15" + } + } + }, + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + } + } + } + ], + "edges": [ + { + "source": "1", + "target": "2" + }, + { + "source": "1", + "target": "3" + }, + { + "source": "1", + "target": "4" + }, + { + "source": "1", + "target": "5" + }, + { + "source": "1", + "target": "6" + }, + { + "source": "1", + "target": "7" + }, + { + "source": "1", + "target": "8" + }, + { + "source": "1", + "target": "9" + }, + { + "source": "1", + "target": "10" + }, + { + "source": "1", + "target": "11" + }, + { + "source": "1", + "target": "12" + }, + { + "source": "1", + "target": "13" + }, + { + "source": "1", + "target": "14" + }, + { + "source": "1", + "target": "15" + }, + { + "source": "1", + "target": "16" + }, + { + "source": "1", + "target": "17" + }, + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.span.agfilter.json b/t/data/resource/expected/find-format/jgf.expected.jobid.span.agfilter.json new file mode 100644 index 000000000..2d659a70f --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.span.agfilter.json @@ -0,0 +1,41 @@ +{ + "graph": { + "nodes": [ + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + }, + "agfilter": { + "core": "used:16, total:16" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + }, + "agfilter": { + "core": "used:16, total:16" + } + } + } + ], + "edges": [ + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.span.json b/t/data/resource/expected/find-format/jgf.expected.jobid.span.json new file mode 100644 index 000000000..725732344 --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.span.json @@ -0,0 +1,35 @@ +{ + "graph": { + "nodes": [ + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + } + } + } + ], + "edges": [ + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.tag.agfilter.json b/t/data/resource/expected/find-format/jgf.expected.jobid.tag.agfilter.json new file mode 100644 index 000000000..2d659a70f --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.tag.agfilter.json @@ -0,0 +1,41 @@ +{ + "graph": { + "nodes": [ + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + }, + "agfilter": { + "core": "used:16, total:16" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + }, + "agfilter": { + "core": "used:16, total:16" + } + } + } + ], + "edges": [ + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/data/resource/expected/find-format/jgf.expected.jobid.tag.json b/t/data/resource/expected/find-format/jgf.expected.jobid.tag.json new file mode 100644 index 000000000..01bcf228e --- /dev/null +++ b/t/data/resource/expected/find-format/jgf.expected.jobid.tag.json @@ -0,0 +1,275 @@ +{ + "graph": { + "nodes": [ + { + "id": "2", + "metadata": { + "type": "core", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core0" + } + } + }, + { + "id": "3", + "metadata": { + "type": "core", + "id": 1, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core1" + } + } + }, + { + "id": "4", + "metadata": { + "type": "core", + "id": 2, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core2" + } + } + }, + { + "id": "5", + "metadata": { + "type": "core", + "id": 3, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core3" + } + } + }, + { + "id": "6", + "metadata": { + "type": "core", + "id": 4, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core4" + } + } + }, + { + "id": "7", + "metadata": { + "type": "core", + "id": 5, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core5" + } + } + }, + { + "id": "8", + "metadata": { + "type": "core", + "id": 6, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core6" + } + } + }, + { + "id": "9", + "metadata": { + "type": "core", + "id": 7, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core7" + } + } + }, + { + "id": "10", + "metadata": { + "type": "core", + "id": 8, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core8" + } + } + }, + { + "id": "11", + "metadata": { + "type": "core", + "id": 9, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core9" + } + } + }, + { + "id": "12", + "metadata": { + "type": "core", + "id": 10, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core10" + } + } + }, + { + "id": "13", + "metadata": { + "type": "core", + "id": 11, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core11" + } + } + }, + { + "id": "14", + "metadata": { + "type": "core", + "id": 12, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core12" + } + } + }, + { + "id": "15", + "metadata": { + "type": "core", + "id": 13, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core13" + } + } + }, + { + "id": "16", + "metadata": { + "type": "core", + "id": 14, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core14" + } + } + }, + { + "id": "17", + "metadata": { + "type": "core", + "id": 15, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234/core15" + } + } + }, + { + "id": "1", + "metadata": { + "type": "node", + "basename": "cab", + "id": 1234, + "exclusive": true, + "paths": { + "containment": "/cluster0/cab1234" + } + } + }, + { + "id": "0", + "metadata": { + "type": "cluster", + "id": 0, + "exclusive": true, + "paths": { + "containment": "/cluster0" + } + } + } + ], + "edges": [ + { + "source": "1", + "target": "2" + }, + { + "source": "1", + "target": "3" + }, + { + "source": "1", + "target": "4" + }, + { + "source": "1", + "target": "5" + }, + { + "source": "1", + "target": "6" + }, + { + "source": "1", + "target": "7" + }, + { + "source": "1", + "target": "8" + }, + { + "source": "1", + "target": "9" + }, + { + "source": "1", + "target": "10" + }, + { + "source": "1", + "target": "11" + }, + { + "source": "1", + "target": "12" + }, + { + "source": "1", + "target": "13" + }, + { + "source": "1", + "target": "14" + }, + { + "source": "1", + "target": "15" + }, + { + "source": "1", + "target": "16" + }, + { + "source": "1", + "target": "17" + }, + { + "source": "0", + "target": "1" + } + ] + } +} diff --git a/t/t1015-find-format.t b/t/t1015-find-format.t index 5a74bde12..b92f0b46f 100755 --- a/t/t1015-find-format.t +++ b/t/t1015-find-format.t @@ -93,6 +93,77 @@ test_expect_success 'find/status: find status=up format=jgf works' ' test_cmp jgf.query.json jgf.json ' +test_expect_success 'find/agfilter: find agfilter=true format=jgf works' ' + flux ion-resource find --format=jgf agfilter=true \ + | tail -1 > jgf.agfilter.raw.json && + normalize_json < jgf.agfilter.raw.json > jgf.agfilter.json && + test_cmp ${expected_basepath}/jgf.expected.agfilter.json jgf.agfilter.json +' + +test_expect_success 'find/jobid: submit test job' ' + flux run --dry-run -N 1 --exclusive -t 1h sleep 3600 > testjob.json && + jobid=$(flux job submit testjob.json) && + jobid1=$(flux job id ${jobid}) && + flux job wait-event -t 10 ${jobid} start && + jobid=$(flux job submit testjob.json) && + jobid2=$(flux job id ${jobid}) +' + +test_expect_success 'find/jobid: find jobid-alloc format=jgf works' ' + flux ion-resource find --format=jgf jobid-alloc=${jobid1} \ + | tail -1 > jgf.jobid.alloc.raw.json && + normalize_json < jgf.jobid.alloc.raw.json > jgf.jobid.alloc.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.alloc.json jgf.jobid.alloc.json +' + +test_expect_success 'find/jobid: find jobid-alloc,agfilter=t format=jgf works' ' + flux ion-resource find --format=jgf "jobid-alloc=${jobid1} and agfilter=t" \ + | tail -1 > jgf.jobid.alloc.agfilter.raw.json && + normalize_json < jgf.jobid.alloc.agfilter.raw.json > jgf.jobid.alloc.agfilter.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.alloc.agfilter.json jgf.jobid.alloc.agfilter.json +' + +test_expect_success 'find/jobid: find jobid-span format=jgf works' ' + flux ion-resource find --format=jgf jobid-span=${jobid1} \ + | tail -1 > jgf.jobid.span.raw.json && + normalize_json < jgf.jobid.span.raw.json > jgf.jobid.span.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.span.json jgf.jobid.span.json +' + +test_expect_success 'find/jobid: find jobid-span,agfilter=t format=jgf works' ' + flux ion-resource find --format=jgf "jobid-span=${jobid1} and agfilter=t" \ + | tail -1 > jgf.jobid.span.agfilter.raw.json && + normalize_json < jgf.jobid.span.agfilter.raw.json > jgf.jobid.span.agfilter.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.span.agfilter.json jgf.jobid.span.agfilter.json +' + +test_expect_success 'find/jobid: find jobid-tag format=jgf works' ' + flux ion-resource find --format=jgf jobid-tag=${jobid1} \ + | tail -1 > jgf.jobid.tag.raw.json && + normalize_json < jgf.jobid.tag.raw.json > jgf.jobid.tag.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.tag.json jgf.jobid.tag.json +' + +test_expect_success 'find/jobid: find jobid-tag,agfilter=t format=jgf works' ' + flux ion-resource find --format=jgf "jobid-tag=${jobid1} and agfilter=t" \ + | tail -1 > jgf.jobid.tag.agfilter.raw.json && + normalize_json < jgf.jobid.tag.agfilter.raw.json > jgf.jobid.tag.agfilter.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.tag.agfilter.json jgf.jobid.tag.agfilter.json +' + +test_expect_success 'find/jobid: find jobid-reserved format=jgf works' ' + flux ion-resource find --format=jgf jobid-reserved=${jobid2} \ + | tail -1 > jgf.jobid.rsv.raw.json && + normalize_json < jgf.jobid.rsv.raw.json > jgf.jobid.rsv.json && + test_cmp ${expected_basepath}/jgf.expected.jobid.rsv.json jgf.jobid.rsv.json +' + +test_expect_success 'find/status: cancel jobs' ' + flux cancel ${jobid1} && + flux cancel ${jobid2} && + flux job wait-event -t 10 ${jobid2} clean +' + test_expect_success 'find/status: removing fluxion modules' ' remove_qmanager && remove_resource