Made test more robust on slower machines.
This commit is contained in:
parent
f6071ca7fc
commit
2387d973ec
|
@ -528,6 +528,7 @@ public class IdleTimeoutTest extends AbstractTest
|
||||||
@Test
|
@Test
|
||||||
public void testBufferedReadsResetStreamIdleTimeout() throws Exception
|
public void testBufferedReadsResetStreamIdleTimeout() throws Exception
|
||||||
{
|
{
|
||||||
|
int bufferSize = 8192;
|
||||||
long delay = 1000;
|
long delay = 1000;
|
||||||
start(new HttpServlet()
|
start(new HttpServlet()
|
||||||
{
|
{
|
||||||
|
@ -535,7 +536,7 @@ public class IdleTimeoutTest extends AbstractTest
|
||||||
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
ServletInputStream input = request.getInputStream();
|
ServletInputStream input = request.getInputStream();
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[bufferSize];
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int read = input.read(buffer);
|
int read = input.read(buffer);
|
||||||
|
@ -566,12 +567,13 @@ public class IdleTimeoutTest extends AbstractTest
|
||||||
|
|
||||||
// Send data larger than the flow control window.
|
// Send data larger than the flow control window.
|
||||||
// The client will send bytes up to the flow control window immediately
|
// 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.
|
// and they will be buffered by the server; the Servlet will consume them slowly.
|
||||||
// Server reads should reset the idle timeout.
|
// Servlet reads should reset the idle timeout.
|
||||||
ByteBuffer data = ByteBuffer.allocate(FlowControlStrategy.DEFAULT_WINDOW_SIZE + 1);
|
int contentLength = FlowControlStrategy.DEFAULT_WINDOW_SIZE + 1;
|
||||||
|
ByteBuffer data = ByteBuffer.allocate(contentLength);
|
||||||
stream.data(new DataFrame(stream.getId(), data, true), Callback.NOOP);
|
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)
|
private void sleep(long value)
|
||||||
|
|
Loading…
Reference in New Issue