mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
test for known pprof endpoints
This commit is contained in:
@@ -415,13 +415,11 @@ func (s *HTTPServer) agentPprofReq(reqType profile.ReqType, profile string, resp
|
||||
}
|
||||
|
||||
if rpcErr != nil {
|
||||
// TODO: rpcErr should return codedErr
|
||||
return nil, rpcErr
|
||||
}
|
||||
|
||||
// resp.Write(reply.Payload)
|
||||
|
||||
return reply.Payload, nil
|
||||
// return string(reply.Payload), rpcErr
|
||||
}
|
||||
|
||||
// AgentServersRequest is used to query the list of servers used by the Nomad
|
||||
|
||||
@@ -394,7 +394,7 @@ func TestAgent_PprofRequest(t *testing.T) {
|
||||
url string
|
||||
addNodeID bool
|
||||
addServerID bool
|
||||
expectedErr error
|
||||
expectedErr string
|
||||
expectedStatus int
|
||||
}{
|
||||
{
|
||||
@@ -403,6 +403,31 @@ func TestAgent_PprofRequest(t *testing.T) {
|
||||
addNodeID: true,
|
||||
expectedStatus: 200,
|
||||
},
|
||||
{
|
||||
desc: "cpu profile request",
|
||||
url: "/v1/agent/pprof/profile",
|
||||
addNodeID: true,
|
||||
expectedStatus: 200,
|
||||
},
|
||||
{
|
||||
desc: "trace request",
|
||||
url: "/v1/agent/pprof/trace",
|
||||
addNodeID: true,
|
||||
expectedStatus: 200,
|
||||
},
|
||||
{
|
||||
desc: "pprof lookup request",
|
||||
url: "/v1/agent/pprof/goroutine",
|
||||
addNodeID: true,
|
||||
expectedStatus: 200,
|
||||
},
|
||||
{
|
||||
desc: "unknown pprof lookup request",
|
||||
url: "/v1/agent/pprof/latency",
|
||||
addNodeID: true,
|
||||
expectedStatus: 404,
|
||||
expectedErr: "Unknown profile: latency",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
@@ -423,7 +448,7 @@ func TestAgent_PprofRequest(t *testing.T) {
|
||||
|
||||
resp, err := s.Server.AgentPprofRequest(respW, req)
|
||||
|
||||
if tc.expectedErr != nil {
|
||||
if tc.expectedErr != "" {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user