cdap icon indicating copy to clipboard operation
cdap copied to clipboard

Make sure that response is processed completely before stopping service in the AppWithCustomTx test case.

Open sagarkapare opened this issue 3 years ago • 3 comments

If service is stopped before the current inflight requests are processed completely, we see failure in the expected value in the test case. Added synchronization mechanism between service and test case to make sure we wait for the current inflight response to be completely processed before stopping the service program.

This failure becomes more pronounced after this change - https://github.com/cdapio/cdap/pull/13096/files#diff-07c7839ccb633f3535e6e5fcb30afaca412536ed747d21e30c60ffb447ce5c08R2118

sagarkapare avatar Mar 01 '21 18:03 sagarkapare

gitpod-io[bot] avatar Mar 01 '21 18:03 gitpod-io[bot]

PUT call here returns the 200 and HttpContentProducer - https://github.com/cdapio/cdap/blob/develop/cdap-unit-test/src/test/java/io/cdap/cdap/test/app/AppWithCustomTx.java#L408.

Test case checks for 200 return code and return from here - https://github.com/cdapio/cdap/blob/develop/cdap-unit-test/src/test/java/io/cdap/cdap/test/app/TestFrameworkTestRun.java#L2113 at which point connection is closed.

It looks like the onFinish and onError callback methods of the HttpBodyProducer are called asynchronously when the response content is streamed and marked as done from the listener attached here - https://github.com/cdapio/netty-http/blob/develop/src/main/java/io/cdap/http/internal/BasicHttpResponder.java#L191.

Since these listeners are invoked after the content is sent, it is possible that the thread executing test case finish first causing these methods to not to complete.

sagarkapare avatar Mar 01 '21 22:03 sagarkapare

ah I see, thanks for explanation.

albertshau avatar Mar 02 '21 17:03 albertshau