Skip to content

Commit

Permalink
add check for unsupported HTTP endpoint (#57)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Shmulevich <[email protected]>
  • Loading branch information
dmitsh authored Jan 17, 2025
1 parent 91b6dc7 commit 63519a8
Showing 1 changed file with 39 additions and 31 deletions.
70 changes: 39 additions & 31 deletions pkg/server/http_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,17 @@ func TestServer(t *testing.T) {
expected string
}{
{
name: "Case 1: test healthz endpoint",
name: "Case 1: test invalid endpoint",
endpoint: "invalid",
expected: "404 page not found\n",
},
{
name: "Case 2: test healthz endpoint",
endpoint: "healthz",
expected: "OK\n",
},
{
name: "Case 2: send test request for tree topology",
name: "Case 3: send test request for tree topology",
endpoint: "generate",
payload: `
{
Expand All @@ -90,7 +95,7 @@ SwitchName=S3 Nodes=Node[304-306]
`,
},
{
name: "Case 3: mock AWS request for tree topology",
name: "Case 4: mock AWS request for tree topology",
endpoint: "generate",
payload: `
{
Expand Down Expand Up @@ -130,49 +135,50 @@ SwitchName=sw14 Nodes=n14-[1-2]
`,
},
{
name: "Case 4: mock AWS request for block topology",
name: "Case 5: mock AWS request for block topology",
endpoint: "generate",
payload: `
{
"provider": {
"name": "aws-sim",
"params": {
"model_path": "../../tests/models/medium.yaml"
"model_path": "../../tests/models/large.yaml"
}
},
"engine": {
"name": "slurm",
"params": {
"plugin": "topology/block",
"block_sizes": "2,4"
}
},
"nodes": [
{
"region": "R1",
"instances": {
"n11-1": "n11-1",
"n11-2": "n11-2",
"n12-1": "n12-1",
"n12-2": "n12-2",
"n13-1": "n13-1",
"n13-2": "n13-2",
"n14-1": "n14-1",
"n14-2": "n14-2"
}
"block_sizes": "8,16,32"
}
]
}
}
`,
expected: `# block001=nvl1
BlockName=block001 Nodes=n11-[1-2]
# block002=nvl2
BlockName=block002 Nodes=n12-[1-2]
# block003=nvl3
BlockName=block003 Nodes=n13-[1-2]
# block004=nvl4
BlockName=block004 Nodes=n14-[1-2]
BlockSizes=2,4
expected: `# block001=nvl-1-1
BlockName=block001 Nodes=n1-1-0[1-8]
# block002=nvl-1-2
BlockName=block002 Nodes=n1-2-0[1-8]
# block003=nvl-2-1
BlockName=block003 Nodes=n2-1-0[1-8]
# block004=nvl-2-2
BlockName=block004 Nodes=n2-2-0[1-8]
# block005=nvl-3-1
BlockName=block005 Nodes=n3-1-0[1-8]
# block006=nvl-3-2
BlockName=block006 Nodes=n3-2-0[1-8]
# block007=nvl-4-1
BlockName=block007 Nodes=n4-1-0[1-8]
# block008=nvl-4-2
BlockName=block008 Nodes=n4-2-0[1-8]
# block009=nvl-5-1
BlockName=block009 Nodes=n5-1-0[1-8]
# block010=nvl-5-2
BlockName=block010 Nodes=n5-2-0[1-8]
# block011=nvl-6-1
BlockName=block011 Nodes=n6-1-0[1-8]
# block012=nvl-6-2
BlockName=block012 Nodes=n6-2-0[1-8]
BlockSizes=8,16,32
`,
},
}
Expand All @@ -181,6 +187,8 @@ BlockSizes=2,4
var resp *http.Response
var body []byte
switch tc.endpoint {
case "invalid":
resp, err = http.Get(baseURL + "/invalid")
case "healthz":
resp, err = http.Get(baseURL + "/healthz")
case "generate":
Expand Down

0 comments on commit 63519a8

Please sign in to comment.