added SCEP stress test
This commit is contained in:
parent
71734400e9
commit
470e63b77b
|
@ -55,7 +55,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio");
|
||||
|
||||
private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue();
|
||||
private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",25000).intValue();
|
||||
private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",100000).intValue();
|
||||
private static final int __BUSY_PAUSE=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_PAUSE",50).intValue();
|
||||
private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue();
|
||||
|
||||
|
|
|
@ -179,4 +179,9 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
|||
Assert.assertEquals(-1,filled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStress() throws Exception
|
||||
{
|
||||
super.testStress();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,16 @@ package org.eclipse.jetty.io.nio;
|
|||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
|
@ -111,7 +115,10 @@ public class SelectChannelEndPointTest
|
|||
progress=false;
|
||||
_in.compact();
|
||||
if (_in.space()>0 && _endp.fill(_in)>0)
|
||||
{
|
||||
progress=true;
|
||||
((AsyncEndPoint)_endp).cancelIdle();
|
||||
}
|
||||
|
||||
if (_blockAt>0 && _in.length()>0 && _in.length()<_blockAt)
|
||||
{
|
||||
|
@ -146,10 +153,12 @@ public class SelectChannelEndPointTest
|
|||
|
||||
public void onClose()
|
||||
{
|
||||
System.err.println("onClose");
|
||||
}
|
||||
|
||||
public void onInputShutdown() throws IOException
|
||||
{
|
||||
System.err.println("onInputShutdown");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -305,4 +314,53 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStress() throws Exception
|
||||
{
|
||||
Socket client = newClient();
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
SocketChannel server = _connector.accept();
|
||||
server.configureBlocking(false);
|
||||
|
||||
_manager.register(server);
|
||||
int writes = 1000000;
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(writes);
|
||||
final InputStream in = new BufferedInputStream(client.getInputStream());
|
||||
|
||||
new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (latch.getCount()>0)
|
||||
{
|
||||
// Verify echo server to client
|
||||
for (char c : "HelloWorld".toCharArray())
|
||||
{
|
||||
int b = in.read();
|
||||
assertTrue(b>0);
|
||||
assertEquals(c,(char)b);
|
||||
}
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
||||
byte[] bytes="HelloWorld".getBytes("UTF-8");
|
||||
|
||||
// Write client to server
|
||||
for (int i=0;i<writes;i++)
|
||||
client.getOutputStream().write(bytes);
|
||||
|
||||
assertTrue(latch.await(100,TimeUnit.SECONDS));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue