Skip to content

Commit e4f265d

Browse files
committed
tests: update golang tests and output
Problem: a recent fix to reapi changed the output of the golang bindings tests. This changed a value that was once static to a value that changes with every run. Use a sed command to remove this value from the output of the test. Edited tests to use orelse_reserve flag.
1 parent 922b6dc commit e4f265d

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

resource/reapi/bindings/go/src/test/main.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
func main() {
2222
jgfPtr := flag.String("jgf", "", "path to jgf")
2323
jobspecPtr := flag.String("jobspec", "", "path to jobspec")
24-
reserve := flag.Bool("reserve", false, "or else reserve?")
24+
reserve := false
2525
flag.Parse()
2626

2727
jgf, err := os.ReadFile(*jgfPtr)
@@ -44,20 +44,32 @@ func main() {
4444
}
4545
fmt.Printf("Jobspec:\n %s\n", jobspec)
4646

47-
reserved, allocated, at, overhead, jobid, err := cli.MatchAllocate(*reserve, string(jobspec))
47+
reserved, allocated, at, overhead, jobid, err := cli.MatchAllocate(reserve, string(jobspec))
4848
if err != nil {
4949
fmt.Printf("Error in ReapiClient MatchAllocate: %v\n", err)
5050
return
5151
}
5252
printOutput(reserved, allocated, at, jobid, err)
53-
reserved, allocated, at, overhead, jobid, err = cli.MatchAllocate(*reserve, string(jobspec))
53+
54+
reserve = true
55+
reserved, allocated, at, overhead, jobid, err = cli.MatchAllocate(reserve, string(jobspec))
56+
fmt.Println("Errors so far: \n", cli.GetErrMsg())
57+
58+
if err != nil {
59+
fmt.Printf("Error in ReapiClient MatchAllocate: %v\n", err)
60+
return
61+
}
62+
printOutput(reserved, allocated, at, jobid, err)
63+
64+
reserved, allocated, at, overhead, jobid, err = cli.MatchAllocate(reserve, string(jobspec))
5465
fmt.Println("Errors so far: \n", cli.GetErrMsg())
5566

5667
if err != nil {
5768
fmt.Printf("Error in ReapiClient MatchAllocate: %v\n", err)
5869
return
5970
}
6071
printOutput(reserved, allocated, at, jobid, err)
72+
6173
err = cli.Cancel(1, false)
6274
if err != nil {
6375
fmt.Printf("Error in ReapiClient Cancel: %v\n", err)

t/data/resource/expected/golang/001.R.out

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ jobid: 2
4747
reserved: false
4848
allocated: {"graph": {"nodes": [{"id": "43", "metadata": {"type": "core", "basename": "core", "name": "core35", "id": 35, "uniq_id": 43, "rank": -1, "exclusive": true, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0/node0/socket1/core35"}}}, {"id": "5", "metadata": {"type": "socket", "basename": "socket", "name": "socket1", "id": 1, "uniq_id": 5, "rank": -1, "exclusive": true, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0/node0/socket1"}}}, {"id": "2", "metadata": {"type": "node", "basename": "node", "name": "node0", "id": 0, "uniq_id": 2, "rank": -1, "exclusive": false, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0/node0"}}}, {"id": "1", "metadata": {"type": "rack", "basename": "rack", "name": "rack0", "id": 0, "uniq_id": 1, "rank": -1, "exclusive": false, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0"}}}, {"id": "0", "metadata": {"type": "cluster", "basename": "tiny", "name": "tiny0", "id": 0, "uniq_id": 0, "rank": -1, "exclusive": false, "unit": "", "size": 1, "paths": {"containment": "/tiny0"}}}], "edges": [{"source": "5", "target": "43", "metadata": {"name": {"containment": "contains"}}}, {"source": "2", "target": "5", "metadata": {"name": {"containment": "contains"}}}, {"source": "1", "target": "2", "metadata": {"name": {"containment": "contains"}}}, {"source": "0", "target": "1", "metadata": {"name": {"containment": "contains"}}}]}}
4949

50+
at: 0
51+
error: <nil>
52+
Errors so far:
53+
54+
55+
----Match Allocate output---
56+
jobid: 3
57+
reserved: false
58+
allocated: {"graph": {"nodes": [{"id": "61", "metadata": {"type": "core", "basename": "core", "name": "core17", "id": 17, "uniq_id": 61, "rank": -1, "exclusive": true, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0/node1/socket0/core17"}}}, {"id": "6", "metadata": {"type": "socket", "basename": "socket", "name": "socket0", "id": 0, "uniq_id": 6, "rank": -1, "exclusive": true, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0/node1/socket0"}}}, {"id": "3", "metadata": {"type": "node", "basename": "node", "name": "node1", "id": 1, "uniq_id": 3, "rank": -1, "exclusive": false, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0/node1"}}}, {"id": "1", "metadata": {"type": "rack", "basename": "rack", "name": "rack0", "id": 0, "uniq_id": 1, "rank": -1, "exclusive": false, "unit": "", "size": 1, "paths": {"containment": "/tiny0/rack0"}}}, {"id": "0", "metadata": {"type": "cluster", "basename": "tiny", "name": "tiny0", "id": 0, "uniq_id": 0, "rank": -1, "exclusive": false, "unit": "", "size": 1, "paths": {"containment": "/tiny0"}}}], "edges": [{"source": "6", "target": "61", "metadata": {"name": {"containment": "contains"}}}, {"source": "3", "target": "6", "metadata": {"name": {"containment": "contains"}}}, {"source": "1", "target": "3", "metadata": {"name": {"containment": "contains"}}}, {"source": "0", "target": "1", "metadata": {"name": {"containment": "contains"}}}]}}
59+
5060
at: 0
5161
error: <nil>
5262
Cancel output: <nil>
53-
Info output jobid 1: false, 0, 0.000000, CANCELED, <nil>
54-
Info output jobid 2: false, 0, 0.000000, <nil>
63+
Info output jobid 1: false, 0, CANCELED, <nil>
64+
Info output jobid 2: false, 0, <nil>

0 commit comments

Comments
 (0)