Skip to content

Commit

Permalink
[Test] Use stream.next instead of setAutoRead in test (elastic#115063)
Browse files Browse the repository at this point in the history
For a more realistic simulation.

(cherry picked from commit 22b4d81)
  • Loading branch information
ywangd committed Oct 30, 2024
1 parent 4152080 commit ea7d4de
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,16 @@ public void testClientConnectionCloseMidStream() throws Exception {
var handler = ctx.awaitRestChannelAccepted(opaqueId);
assertBusy(() -> assertNotNull(handler.stream.buf()));

// enable auto-read to receive channel close event
handler.stream.channel().config().setAutoRead(true);
assertFalse(handler.streamClosed);

// terminate connection and wait resources are released
// terminate client connection
ctx.clientChannel.close();
// read the first half of the request
handler.stream.next();
// attempt to read more data and it should notice channel being closed eventually
handler.stream.next();

// wait for resources to be released
assertBusy(() -> {
assertNull(handler.stream.buf());
assertTrue(handler.streamClosed);
Expand Down

0 comments on commit ea7d4de

Please sign in to comment.