Bumping up to jetty-test-helper 2.0 with new @Rule TestTracker & AdvancedRunner status messages.

This commit is contained in:
Joakim Erdfelt 2012-10-10 09:10:51 -07:00
parent 03b27d0c61
commit f2595a7ec3
7 changed files with 52 additions and 117 deletions

View File

@ -25,6 +25,7 @@ import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.After;
@ -44,18 +45,7 @@ public abstract class AbstractHttpClientServerTest
}
@Rule
public final TestWatcher testName = new TestWatcher()
{
@Override
public void starting(Description description)
{
super.starting(description);
System.err.printf("Running %s.%s()%n",
description.getClassName(),
description.getMethodName());
}
};
public final TestTracker tracker = new TestTracker();
protected SslContextFactory sslContextFactory;
protected String scheme;

View File

@ -37,7 +37,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.toolchain.test.Stress;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.annotation.Stress;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -46,7 +47,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AdvancedRunner.class)
public class AsyncStressTest
{
private static final Logger LOG = Log.getLogger(AsyncStressTest.class);
@ -90,17 +93,10 @@ public class AsyncStressTest
}
@Test
@Ignore
@Stress("High connection count")
public void testAsync() throws Throwable
{
if (Stress.isEnabled())
{
doConnections(1600,240);
}
else
{
doConnections(80,80);
}
doConnections(1600,240);
}
private void doConnections(int connections,final int loops) throws Throwable

View File

@ -34,16 +34,14 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.toolchain.test.Stress;
import org.eclipse.jetty.util.IO;
import org.junit.After;
import org.junit.Before;
public class HttpServerTestFixture
{ // Useful constants
protected static final long PAUSE=10L;
protected static final int LOOPS=Stress.isEnabled()?250:50;
protected static final int LOOPS=50;
protected static final String HOST="localhost";
protected Server _server;

View File

@ -34,8 +34,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.toolchain.test.Stress;
import org.eclipse.jetty.toolchain.test.annotation.Stress;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -43,10 +44,10 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@Ignore
@RunWith(AdvancedRunner.class)
public class StressTest
{
private static final Logger LOG = Log.getLogger(StressTest.class);
@ -122,45 +123,42 @@ public class StressTest
@Test
@Stress("Hey, its called StressTest for a reason")
public void testMinNonPersistent() throws Throwable
{
doThreads(2,2,false);
}
@Test
@Stress("Much threading")
public void testNonPersistent() throws Throwable
{
// TODO needs to be further investigated
assumeTrue(!OS.IS_OSX || Stress.isEnabled());
assumeTrue(!OS.IS_OSX);
doThreads(10,10,false);
Thread.sleep(1000);
doThreads(20,20,false);
if (Stress.isEnabled())
{
Thread.sleep(1000);
doThreads(200,10,false);
Thread.sleep(1000);
doThreads(200,200,false);
}
Thread.sleep(1000);
doThreads(200,10,false);
Thread.sleep(1000);
doThreads(200,200,false);
}
@Test
@Stress("Much threading")
public void testPersistent() throws Throwable
{
// TODO needs to be further investigated
assumeTrue(!OS.IS_OSX || Stress.isEnabled());
assumeTrue(!OS.IS_OSX);
doThreads(10,10,true);
Thread.sleep(1000);
doThreads(40,40,true);
if (Stress.isEnabled())
{
Thread.sleep(1000);
doThreads(200,10,true);
Thread.sleep(1000);
doThreads(200,200,true);
}
Thread.sleep(1000);
doThreads(200,10,true);
Thread.sleep(1000);
doThreads(200,200,true);
}
private void doThreads(int threadCount, final int loops, final boolean persistent) throws Throwable
@ -293,33 +291,30 @@ public class StressTest
}
}
if(Stress.isEnabled())
System.out.println(" stage:\tbind\twrite\trecv\tdispatch\twrote\ttotal");
for (int q=0;q<quantums;q++)
{
System.out.println(" stage:\tbind\twrite\trecv\tdispatch\twrote\ttotal");
for (int q=0;q<quantums;q++)
{
System.out.printf("%02d00<=l<%02d00",q,(q+1));
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+count[i][q]);
System.out.println();
}
System.out.print("other ");
System.out.printf("%02d00<=l<%02d00",q,(q+1));
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+other[i]);
System.out.print("\t"+count[i][q]);
System.out.println();
System.out.print("HANDLED ");
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+_handled.get());
System.out.println();
System.out.print("TOTAL ");
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+length[i]);
System.out.println();
long ave=total/_latencies[4].size();
System.out.println("ave="+ave);
}
System.out.print("other ");
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+other[i]);
System.out.println();
System.out.print("HANDLED ");
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+_handled.get());
System.out.println();
System.out.print("TOTAL ");
for (int i=0;i<_latencies.length;i++)
System.out.print("\t"+length[i]);
System.out.println();
long ave=total/_latencies[4].size();
System.out.println("ave="+ave);
}
}

View File

@ -22,11 +22,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.core.api.ProtocolException;
import org.eclipse.jetty.websocket.core.protocol.CloseInfo;
import org.eclipse.jetty.websocket.core.protocol.Generator;
import org.eclipse.jetty.websocket.core.protocol.UnitGenerator;
import org.eclipse.jetty.websocket.core.protocol.WebSocketFrame;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -38,7 +40,6 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(value = Parameterized.class)
public class TestABCase3
{
@Parameters
public static Collection<WebSocketFrame[]> data()
{
@ -72,6 +73,9 @@ public class TestABCase3
return data;
}
@Rule
public TestTracker tt = new TestTracker();
private WebSocketFrame invalidFrame;
public TestABCase3(WebSocketFrame invalidFrame)

View File

@ -112,54 +112,6 @@ public class WebkitDeflateFrameExtensionTest
capture.assertBytes(0,expectedHex);
}
private String deflate(byte data[], int level, boolean nowrap, int strategy, int flush)
{
Deflater compressor = new Deflater(level,nowrap);
compressor.setStrategy(strategy);
// Prime the compressor
compressor.reset();
compressor.setInput(data,0,data.length);
compressor.finish();
byte out[] = new byte[64];
int len = compressor.deflate(out,0,out.length,flush);
compressor.end();
String ret = TypeUtil.toHexString(out,0,len);
System.out.printf("deflate(l=%d,s=%d,f=%d,w=%-5b) => %s%n",level,strategy,flush,nowrap,ret);
return ret;
}
@Test
public void testAllDeflate() throws Exception
{
int strategies[] = new int[] {
Deflater.DEFAULT_STRATEGY,
Deflater.FILTERED,
Deflater.HUFFMAN_ONLY
};
int flushes[] = new int[] {
Deflater.FULL_FLUSH,
Deflater.NO_FLUSH,
Deflater.SYNC_FLUSH
};
byte uncompressed[] = StringUtil.getUtf8Bytes("info:");
for(int level = 0; level <= 9; level++)
{
for (int strategy : strategies)
{
for (int flush : flushes)
{
deflate(uncompressed,level,true,strategy,flush);
deflate(uncompressed,level,false,strategy,flush);
}
}
}
}
@Test
public void testChrome20_Hello()
{

View File

@ -515,7 +515,7 @@
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<version>1.9</version>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>