manirajv06 commented on a change in pull request #216:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/216#discussion_r566828399



##########
File path: pkg/webservice/handlers_test.go
##########
@@ -607,3 +627,46 @@ func TestGetNodesUtilJSON(t *testing.T) {
        assert.Equal(t, subresNon[0].NumOfNodes, int64(-1))
        assert.Equal(t, subresNon[0].NodeNames[0], "N/A")
 }
+
+func TestPartitions(t *testing.T) {
+       configs.MockSchedulerConfigByData([]byte(configMultiPartitions))
+       var err error
+       schedulerContext, err = scheduler.NewClusterContext(rmID, policyGroup)
+       assert.NilError(t, err, "Error when load clusterInfo from config")
+       assert.Equal(t, 2, len(schedulerContext.GetPartitionMapClone()))
+
+       // Check default partition
+       partitionName := "[" + rmID + "]default"
+       defaultPartition := schedulerContext.GetPartition(partitionName)
+       assert.Equal(t, 0, len(defaultPartition.GetApplications()))
+
+       // add a new app
+       app := newApplication("app-1", partitionName, "root.default", rmID)
+       err = defaultPartition.AddApplication(app)
+       assert.NilError(t, err, "Failed to add Application to Partition.")
+       assert.Equal(t, app.CurrentState(), objects.New.String())
+       assert.Equal(t, 1, len(defaultPartition.GetApplications()))
+
+       NewWebApp(schedulerContext, nil)
+
+       var req *http.Request
+       req, err = http.NewRequest("GET", "/ws/v1/partitions", 
strings.NewReader(""))
+       assert.NilError(t, err, "App Handler request failed")
+       resp := &MockResponseWriter{}
+       var partitionInfo []dao.PartitionInfo
+       getPartitions(resp, req)
+       err = json.Unmarshal(resp.outputBytes, &partitionInfo)
+       assert.NilError(t, err, "failed to unmarshal applications dao response 
from response body: %s", string(resp.outputBytes))
+       for _, part := range partitionInfo {
+               if part.Name == partitionName {
+                       assert.Equal(t, part.Name, "[rm-123]default")
+                       assert.Equal(t, part.NodeSortingPolicy, "fair")
+                       assert.Equal(t, part.Applications["total"], 1)

Review comment:
       Improved UT coverage.




----------------------------------------------------------------
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.

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


Reply via email to