Repository navigation
test: migrate webapp ITs from TestRestTemplate to RestTestClient - #2404
Ashish-CodeJourney wants to merge 8 commits into
Conversation
Signed-off-by: Ashish Vaghela <[email protected]>
Signed-off-by: Ashish Vaghela <[email protected]>
Signed-off-by: Ashish Vaghela <[email protected]>
Signed-off-by: Ashish Vaghela <[email protected]>
Signed-off-by: Ashish Vaghela <[email protected]>
Signed-off-by: Ashish Vaghela <[email protected]>
…m base Signed-off-by: Ashish Vaghela <[email protected]>
|
Welcome to the Microcks community! 💖 Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly. Hope you have a great time there! |
| try { | ||
| restTemplate.execute("/mcp/Petstore+API/1.0.0/sse", HttpMethod.GET, request -> {}, response -> { | ||
| streamingRestClient.get().uri("/mcp/Petstore+API/1.0.0/sse").exchange((request, response) -> { | ||
| String line; |
There was a problem hiding this comment.
The SSE client thread reads the response body until EOF, but shutdown() on the executor does not close an active response. The server-side emitter has a 600-second timeout (new SseEmitter(Duration.ofSeconds(600).toMillis()) in McpController). Could we retain the active response/stream and explicitly close it during teardown so the read loop can terminate promptly rather than relying on the server timeout?
| HttpMethod.GET, request -> {}, response -> { | ||
| streamingRestClient.get().uri( | ||
| "/api/traces/operations/stream?serviceName=pastry-details&operationName=GET /pastry&clientAddress=.*") | ||
| .exchange((request, response) -> { |
There was a problem hiding this comment.
shutdownNow() interrupts the executor, but it does not explicitly close the active HTTP response. This test opens a long-lived SSE stream and blocks on bufferedReader.readLine(), while the server-side emitter is created with new SseEmitter(0L) in TraceSubscriptionManager.subscribe(), meaning there is no timeout. Could we retain the active response/stream and close it during teardown so the read loop terminates cleanly?
dipak0000812
left a comment
There was a problem hiding this comment.
Reviewed the SSE integration test changes and left two non-blocking comments regarding explicit cleanup of active SSE response streams during test teardown.
I am looking into that, Thanks. |
The streaming RestClient used by the SSE integration tests had no read timeout, so reader threads could block until the server closed the stream. Give it a 5 second read timeout so the reader exits on its own. Signed-off-by: Ashish Vaghela <[email protected]>
Thanks for the review, both points are valid. Teardown only shut down the executor, so the SSE reader thread stayed blocked on |
@dipak0000812 The streaming client now has a 5 second read timeout, so each reader exits on its own. The four SSE call sites are unchanged they all use this client. |
TestRestTemplateto Spring'sRestTestClient.restClientandnoRedirectRestClienttoAbstractBaseIT. Remove@AutoConfigureTestRestTemplateand theTestRestTemplatefield from the base class.RestClientfor the SSE tests inMcpControllerITandTracingControllerIT, sinceRestTestClientbuffers the full response body and would block on the infinite stream.RestControllerITto check the headers-only 302 response.Test results
mvn -pl webapp -am -Pit test): 69 tests, 0 failures, 0 errors. Same count asmaster.mvn spotless:applyrun before each commit.Related issue(s)
Fixes #2116