pbacsko commented on code in PR #743:
URL: https://github.com/apache/yunikorn-core/pull/743#discussion_r1410515846


##########
pkg/webservice/handlers_test.go:
##########
@@ -1720,3 +1720,83 @@ func verifyStateDumpJSON(t *testing.T, aggregated 
*AggregatedStateInfo) {
        assert.Check(t, len(aggregated.Config.SchedulerConfig.Partitions) > 0)
        assert.Check(t, len(aggregated.Config.Extra) > 0)
 }
+
+func TestCheckHealthStatusNotFound(t *testing.T) {
+       NewWebApp(&scheduler.ClusterContext{}, nil)
+       req, err := http.NewRequest("GET", "/ws/v1/scheduler/healthcheck", 
strings.NewReader(""))
+       assert.NilError(t, err, "Error while creating the healthcheck request")
+       resp := &MockResponseWriter{}
+       checkHealthStatus(resp, req)
+
+       var errInfo dao.YAPIError
+       err = json.Unmarshal(resp.outputBytes, &errInfo)
+       assert.NilError(t, err, unmarshalError)
+       assert.Equal(t, http.StatusNotFound, errInfo.StatusCode, 
statusCodeError)
+       assert.Equal(t, "The healthy status of scheduler is not found", 
errInfo.Message, jsonMessageError)

Review Comment:
   Could you change this text to sth else? It sounds funny.
   I propose "Health check is not available".



##########
pkg/webservice/handlers_test.go:
##########
@@ -1720,3 +1720,83 @@ func verifyStateDumpJSON(t *testing.T, aggregated 
*AggregatedStateInfo) {
        assert.Check(t, len(aggregated.Config.SchedulerConfig.Partitions) > 0)
        assert.Check(t, len(aggregated.Config.Extra) > 0)
 }
+
+func TestCheckHealthStatusNotFound(t *testing.T) {
+       NewWebApp(&scheduler.ClusterContext{}, nil)
+       req, err := http.NewRequest("GET", "/ws/v1/scheduler/healthcheck", 
strings.NewReader(""))
+       assert.NilError(t, err, "Error while creating the healthcheck request")
+       resp := &MockResponseWriter{}
+       checkHealthStatus(resp, req)
+
+       var errInfo dao.YAPIError
+       err = json.Unmarshal(resp.outputBytes, &errInfo)
+       assert.NilError(t, err, unmarshalError)
+       assert.Equal(t, http.StatusNotFound, errInfo.StatusCode, 
statusCodeError)
+       assert.Equal(t, "The healthy status of scheduler is not found", 
errInfo.Message, jsonMessageError)
+}
+
+func TestCheckHealthStatus(t *testing.T) {
+       testCases := []struct {
+               name     string
+               expected *dao.SchedulerHealthDAOInfo
+       }{

Review Comment:
   Don't think we need this overhead for only two test cases. Just call 
`runHealthChecks()` directly twice.



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