From ee15bf4702231475ffbd9bf30ea845bf9b46d1b6 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 28 May 2009 04:00:36 +0000 Subject: [PATCH] improved stress test git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@311 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../org/eclipse/jetty/server/StressTest.java | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java index 6464133e371..f8b6ad564df 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java @@ -18,6 +18,7 @@ import java.net.Inet4Address; import java.net.InetAddress; import java.net.Socket; import java.util.Queue; +import java.util.Random; import java.util.Timer; import java.util.concurrent.ConcurrentLinkedQueue; @@ -52,6 +53,7 @@ public class StressTest extends TestCase new ConcurrentLinkedQueue(), new ConcurrentLinkedQueue() }; + private Random _random=new Random(); protected void setUp() throws Exception { @@ -59,9 +61,10 @@ public class StressTest extends TestCase _threads.setMaxThreads(500); _server.setThreadPool(_threads); SelectChannelConnector c_connector=new SelectChannelConnector(); - SocketConnector s_connector=new SocketConnector(); + c_connector.setAcceptors(4); + c_connector.setAcceptQueueSize(1000); - _connector=s_connector; + _connector=c_connector; _connector.setMaxIdleTime(30000); _server.setConnectors(new Connector[]{ _connector }); @@ -89,6 +92,14 @@ public class StressTest extends TestCase {"/path/5","NORMAL"}, {"/path/6","NORMAL"}, {"/path/7","NORMAL"}, + {"/path/8","NORMAL"}, + {"/path/9","NORMAL"}, + {"/path/a","NORMAL"}, + {"/path/b","NORMAL"}, + {"/path/c","NORMAL"}, + {"/path/d","NORMAL"}, + {"/path/e","NORMAL"}, + {"/path/f","NORMAL"}, }; @@ -144,14 +155,12 @@ public class StressTest extends TestCase _latencies[1].add((i==0)?new Long(bind+flush):flush); _latencies[5].add((i==0)?new Long(bind+flush+read):(flush+read)); } - } else { for (int i=0;i<__tests.length;i++) { - //int timeout = __tests[i][1].equals("NORMAL")?0:(_random.nextInt(200)+1); - int timeout = __tests[i][1].equals("NORMAL")?0:20; + int timeout = __tests[i][1].equals("NORMAL")?0:(_random.nextInt(20)*_random.nextInt(20)+1); String uri=__tests[i][0]; long start=System.currentTimeMillis(); @@ -196,7 +205,7 @@ public class StressTest extends TestCase { _loops[thread]=i; doPaths(thread,name+"-"+i,persistent); - // Thread.sleep(1+_random.nextInt(10)*_random.nextInt(10)); + Thread.sleep(1+_random.nextInt(10)*_random.nextInt(10)); Thread.sleep(10); } _loops[thread]=loops; @@ -204,7 +213,6 @@ public class StressTest extends TestCase catch(Exception e) { System.err.println(e); - //_connector.dump(); _loops[thread]=-_loops[thread]; throw e; } @@ -242,6 +250,9 @@ public class StressTest extends TestCase for (int i=0;i10) + throw new IllegalStateException("Stalled"); + } + else + same=0; + last=status; + Log.info(status); if ((finished+errors)==threads) break; } @@ -282,9 +301,7 @@ public class StressTest extends TestCase if (throwable[i]!=null) throw throwable[i]; - - - int quantums=16; + int quantums=48; int[][] count = new int[_latencies.length][quantums]; int length[] = new int[_latencies.length]; int other[] = new int[_latencies.length]; @@ -299,7 +316,7 @@ public class StressTest extends TestCase { for (int q=0;q=(q*1000) && latency<((q+1)*1000)) + if (latency>=(q*100) && latency<((q+1)*100)) { count[i][q]++; continue loop; @@ -312,7 +329,7 @@ public class StressTest extends TestCase System.out.println(" stage:\tbind\twrite\trecv\tdispatch\twrote\ttotal"); for (int q=0;q