manirajv06 commented on code in PR #970:
URL: https://github.com/apache/yunikorn-core/pull/970#discussion_r1761385458


##########
pkg/webservice/handlers_test.go:
##########
@@ -318,6 +318,18 @@ func newApplication(appID, partitionName, queueName, rmID 
string, ugi security.U
        return objects.NewApplication(siApp, userGroup, nil, rmID)
 }
 
+func TestGetStackInfo(t *testing.T) {
+       req, err := http.NewRequest("GET", "", strings.NewReader(baseConf))
+       assert.NilError(t, err, "Error creating request")
+       resp := &MockResponseWriter{}
+       getStackInfo(resp, req)
+
+       // assert stack trace
+       assert.Assert(t, strings.Contains(string(resp.outputBytes), 
"goroutine"), "Stack trace should be present in the response")
+       assert.Assert(t, strings.Contains(string(resp.outputBytes), "test"), 
"Stack trace should be present in the response")
+       assert.Assert(t, strings.Contains(string(resp.outputBytes), 
"github.com/apache/yunikorn-core/pkg/webservice.getStackInfo"), "Stack trace 
should be present in the response")
+}

Review Comment:
   Can you cover -ve cases?



##########
pkg/webservice/handlers_test.go:
##########
@@ -1358,17 +1364,42 @@ func TestGetPartitionNodes(t *testing.T) {
        assertParamsMissing(t, resp)
 
        // Test specific node
-       req, err = createRequest(t, "/ws/v1/partition/default/node/node-1", 
map[string]string{"node": "node-1"})
+       req, err = createRequest(t, "/ws/v1/partition/default/node/node-1", 
map[string]string{"partition": "default", "node": "node-1"})
        assert.NilError(t, err, "Get Node for PartitionNode Handler request 
failed")
        resp = &MockResponseWriter{}
        getPartitionNode(resp, req)
+       var nodeInfo dao.NodeDAOInfo
+       err = json.Unmarshal(resp.outputBytes, &nodeInfo)
+       assert.NilError(t, err, unmarshalError)
+       assertNodeInfo(t, &nodeInfo, node1ID, "alloc-1", attributesOfnode1, 
map[string]int64{"memory": 50, "vcore": 30})
 
        // Test node id is missing
        req, err = createRequest(t, "/ws/v1/partition/default/node/node-1", 
map[string]string{"partition": "default", "node": ""})
        assert.NilError(t, err, "Get Node for PartitionNode Handler request 
failed")
        resp = &MockResponseWriter{}
        getPartitionNode(resp, req)
        assertNodeIDNotExists(t, resp)
+
+       // Test param missing
+       req, err = http.NewRequest("GET", "/ws/v1/partition/default/node", 
strings.NewReader(""))
+       assert.NilError(t, err, "Get Node for PartitionNode Handler request 
failed")
+       resp = &MockResponseWriter{}
+       getPartitionNode(resp, req)
+       assertParamsMissing(t, resp)
+
+       // Test partition not exist
+       req, err = createRequest(t, "/ws/v1/partition/notexists/node/node-1", 
map[string]string{"partition": "notexists"})
+       assert.NilError(t, err, "Get Nodes for PartitionNode Handler request 
failed")
+       resp = &MockResponseWriter{}
+       getPartitionNodes(resp, req)
+       assertPartitionNotExists(t, resp)
+}

Review Comment:
   It is growing big. Probably, time to split into two separate methods, one 
for Nodes and another one for specific node.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to