Skip to content

Commit

Permalink
tests: update golang tests and output
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zekemorton committed Dec 6, 2023
1 parent 22ad075 commit 2a6a3ca
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
18 changes: 15 additions & 3 deletions resource/reapi/bindings/go/src/test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
func main() {
jgfPtr := flag.String("jgf", "", "path to jgf")
jobspecPtr := flag.String("jobspec", "", "path to jobspec")
reserve := flag.Bool("reserve", false, "or else reserve?")
reserve := false
flag.Parse()

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

reserved, allocated, at, overhead, jobid, err := cli.MatchAllocate(*reserve, string(jobspec))
reserved, allocated, at, overhead, jobid, err := cli.MatchAllocate(reserve, string(jobspec))
if err != nil {
fmt.Printf("Error in ReapiClient MatchAllocate: %v\n", err)
return
}
printOutput(reserved, allocated, at, jobid, err)
reserved, allocated, at, overhead, jobid, err = cli.MatchAllocate(*reserve, string(jobspec))

reserve = true
reserved, allocated, at, overhead, jobid, err = cli.MatchAllocate(reserve, string(jobspec))
fmt.Println("Errors so far: \n", cli.GetErrMsg())

if err != nil {
fmt.Printf("Error in ReapiClient MatchAllocate: %v\n", err)
return
}
printOutput(reserved, allocated, at, jobid, err)

reserved, allocated, at, overhead, jobid, err = cli.MatchAllocate(reserve, string(jobspec))
fmt.Println("Errors so far: \n", cli.GetErrMsg())

if err != nil {
fmt.Printf("Error in ReapiClient MatchAllocate: %v\n", err)
return
}
printOutput(reserved, allocated, at, jobid, err)

err = cli.Cancel(1, false)
if err != nil {
fmt.Printf("Error in ReapiClient Cancel: %v\n", err)
Expand Down
14 changes: 12 additions & 2 deletions t/data/resource/expected/golang/001.R.out
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,18 @@ jobid: 2
reserved: false
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"}}}]}}

at: 0
error: <nil>
Errors so far:


----Match Allocate output---
jobid: 3
reserved: false
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"}}}]}}

at: 0
error: <nil>
Cancel output: <nil>
Info output jobid 1: false, 0, 0.000000, CANCELED, <nil>
Info output jobid 2: false, 0, 0.000000, <nil>
Info output jobid 1: false, 0, CANCELED, <nil>
Info output jobid 2: false, 0, <nil>
Loading

0 comments on commit 2a6a3ca

Please sign in to comment.