Fixed flaky test `StreamResetTest.testResetAfterBlockingWrite()`, that became flaky after #10554.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
d8338124ee
commit
a4b55e6964
|
@ -85,6 +85,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
@ -710,29 +711,20 @@ public class StreamResetTest extends AbstractTest
|
|||
}
|
||||
});
|
||||
|
||||
List<Stream.Data> dataList = new ArrayList<>();
|
||||
AtomicLong received = new AtomicLong();
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
Session client = newClientSession(new Session.Listener() {});
|
||||
MetaData.Request request = newRequest("GET", HttpFields.EMPTY);
|
||||
HeadersFrame frame = new HeadersFrame(request, null, true);
|
||||
FuturePromise<Stream> promise = new FuturePromise<>();
|
||||
client.newStream(frame, promise, new Stream.Listener()
|
||||
Stream stream = client.newStream(frame, new Stream.Listener()
|
||||
{
|
||||
@Override
|
||||
public void onDataAvailable(Stream stream)
|
||||
{
|
||||
Stream.Data data = stream.readData();
|
||||
dataList.add(data);
|
||||
// Do not release to stall the flow control window.
|
||||
if (received.addAndGet(data.frame().getByteBuffer().remaining()) == windowSize)
|
||||
latch.countDown();
|
||||
else
|
||||
stream.demand();
|
||||
// Do not read to stall the flow control window.
|
||||
}
|
||||
});
|
||||
Stream stream = promise.get(5, TimeUnit.SECONDS);
|
||||
assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
|
||||
// Wait until the flow control stalls.
|
||||
await().atMost(5, TimeUnit.SECONDS).until(() -> ((HTTP2Stream)stream).getDataLength(), is((long)windowSize));
|
||||
|
||||
// Reset.
|
||||
stream.reset(new ResetFrame(stream.getId(), ErrorCode.CANCEL_STREAM_ERROR.code), Callback.NOOP);
|
||||
|
@ -747,8 +739,6 @@ public class StreamResetTest extends AbstractTest
|
|||
HTTP2Session session = (HTTP2Session)sessions.iterator().next();
|
||||
HTTP2Flusher flusher = session.getBean(HTTP2Flusher.class);
|
||||
assertEquals(0, flusher.getFrameQueueSize());
|
||||
|
||||
dataList.forEach(Stream.Data::release);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue