Skip to content

Commit

Permalink
Made test more robust on slower machines.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbordet committed Jul 14, 2016
1 parent f6071ca commit 2387d97
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -528,14 +528,15 @@ public void succeeded(Stream stream)
@Test
public void testBufferedReadsResetStreamIdleTimeout() throws Exception
{
int bufferSize = 8192;
long delay = 1000;
start(new HttpServlet()
{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
ServletInputStream input = request.getInputStream();
byte[] buffer = new byte[8192];
byte[] buffer = new byte[bufferSize];
while (true)
{
int read = input.read(buffer);
Expand Down Expand Up @@ -566,12 +567,13 @@ public void onHeaders(Stream stream, HeadersFrame frame)

// Send data larger than the flow control window.
// The client will send bytes up to the flow control window immediately
// and they will be buffered by the server, which will read them slowly.
// Server reads should reset the idle timeout.
ByteBuffer data = ByteBuffer.allocate(FlowControlStrategy.DEFAULT_WINDOW_SIZE + 1);
// and they will be buffered by the server; the Servlet will consume them slowly.
// Servlet reads should reset the idle timeout.
int contentLength = FlowControlStrategy.DEFAULT_WINDOW_SIZE + 1;
ByteBuffer data = ByteBuffer.allocate(contentLength);
stream.data(new DataFrame(stream.getId(), data, true), Callback.NOOP);

Assert.assertTrue(latch.await(555, TimeUnit.SECONDS));
Assert.assertTrue(latch.await(2 * (contentLength / bufferSize + 1) * delay, TimeUnit.MILLISECONDS));
}

private void sleep(long value)
Expand Down

0 comments on commit 2387d97

Please sign in to comment.