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.
  • Loading branch information
ywangd authored Oct 21, 2024
1 parent b4a5817 commit 22b4d81
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,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 22b4d81

Please sign in to comment.