Closed rudranil-das closed 2 years ago
We will return HTTP code specify within model. At the same time call 200-OK as default.
result := ctrl.handler.GetCapture(item, r)
if result.HasStatusCode400() {
httpapi.WriteJSONResponse(w, 400, result.StatusCode400())
return
}
if result.HasStatusCode500() {
httpapi.WriteJSONResponse(w, 500, result.StatusCode500())
return
}
httpapi.WriteByteResponse(w, 200, result.StatusCode200())
@alakendu I disagree with this. its is not OK to return OK as default. If nothing is set, then that is an error. If one particular return model does not work properly, then modify the model. Do not change the controller code for this
@rudranil-das in this particular case, do not set nil, but empty array. Empty array indicates success, but nothing was captured
According to the suggestion of @jkristia we are passing empty array from Athena controller. So no change in our servergen logic.
This should address in https://github.com/open-traffic-generator/snappi/releases/tag/v0.7.1
A response to GetCapture API call with StatusCode200 but no packets is a valid use-case (e.g. due to a capture-filter which does not result in any packet to be captured). In this case GetCaptureResponse from concrete implementation would return with
But with above, captureController GetCapture sends out a 500 response through
That is because the HasStatusCode200 of returned result (GetCaptureResponse) results false due to nil-check
[snippet from func (ctrl *captureController) GetCapture...]
This impacts a couple of TCs in ixia-c sanity e.g. http://gitlab.it.keysight.com/athena/tests/blob/main/py/validation/test_api_payload.py (TC: test_get_capture_for_port_not_in_flow)