jetty-9 wider test margin for DoSfilterTest

This commit is contained in:
Greg Wilkins 2012-08-27 14:01:26 +10:00
parent 6e9bea1938
commit 838ddcd444
1 changed files with 12 additions and 10 deletions

View File

@ -104,26 +104,26 @@ public abstract class AbstractDoSFilterTest
_dosFilter.stop();
}
private String doRequests(String requests, int loops, long pause0, long pause1, String request) throws Exception
private String doRequests(String loopRequests, int loops, long pauseBetweenLoops, long pauseBeforeLast, String lastRequest) throws Exception
{
Socket socket = new Socket(_host, _port);
socket.setSoTimeout(30000);
for (int i=loops;i-->0;)
{
socket.getOutputStream().write(requests.getBytes("UTF-8"));
socket.getOutputStream().write(loopRequests.getBytes("UTF-8"));
socket.getOutputStream().flush();
if (i>0 && pause0>0)
Thread.sleep(pause0);
if (i>0 && pauseBetweenLoops>0)
Thread.sleep(pauseBetweenLoops);
}
if (pause1>0)
Thread.sleep(pause1);
socket.getOutputStream().write(request.getBytes("UTF-8"));
if (pauseBeforeLast>0)
Thread.sleep(pauseBeforeLast);
socket.getOutputStream().write(lastRequest.getBytes("UTF-8"));
socket.getOutputStream().flush();
String response;
if (requests.contains("/unresponsive"))
if (loopRequests.contains("/unresponsive"))
{
// don't read in anything, forcing the request to time out
Thread.sleep(_requestMaxTime * 2);
@ -302,11 +302,13 @@ public abstract class AbstractDoSFilterTest
assertEquals(0,count(responses,"DoSFilter: delayed"));
// alternate between sessions
responses = doRequests(request1+request2+request1+request2+request1,2,350,550,last);
responses = doRequests(request1+request2+request1+request2+request1,2,250,250,last);
System.err.println(responses);
assertEquals(11,count(responses,"HTTP/1.1 200 OK"));
int delayedRequests = count(responses,"DoSFilter: delayed");
assertTrue("delayedRequests: " + delayedRequests + " is not between 2 and 3",delayedRequests >= 2 && delayedRequests <= 3);
assertTrue("delayedRequests: " + delayedRequests + " is not between 2 and 5",delayedRequests >= 2 && delayedRequests <= 5);
}
@Test