Updating Fuzzer for ignoring broken pipe issues when appropriate

This commit is contained in:
Joakim Erdfelt 2012-09-17 14:04:33 -07:00
parent ce4ffa7ad3
commit e0e8708932
2 changed files with 31 additions and 41 deletions

View File

@ -18,7 +18,10 @@
package org.eclipse.jetty.websocket.server.ab;
import static org.hamcrest.Matchers.*;
import java.io.IOException;
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
@ -38,8 +41,6 @@ import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.junit.Assert;
import static org.hamcrest.Matchers.is;
/**
* Fuzzing utility for the AB tests.
*/
@ -254,6 +255,28 @@ public class Fuzzer
send(Collections.singletonList(send));
}
public void sendAndIgnoreBrokenPipe(List<WebSocketFrame> send) throws IOException
{
try
{
send(send);
}
catch (SocketException ignore)
{
// Potential for SocketException (Broken Pipe) here.
// But not in 100% of testing scenarios. It is a safe
// exception to ignore in this testing scenario, as the
// slow writing of the frames can result in the server
// throwing a PROTOCOL ERROR termination/close when it
// encounters the bad continuation frame above (this
// termination is the expected behavior), and this
// early socket close can propagate back to the client
// before it has a chance to finish writing out the
// remaining frame octets
Assert.assertThat("Allowed to be a broken pipe",ignore.getMessage().toLowerCase(),containsString("broken pipe"));
}
}
public void setSendMode(SendMode sendMode)
{
this.sendMode = sendMode;

View File

@ -18,7 +18,6 @@
package org.eclipse.jetty.websocket.server.ab;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -85,7 +84,7 @@ public class TestABCase5 extends AbstractABCase
{
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.send(send);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
finally
@ -114,23 +113,7 @@ public class TestABCase5 extends AbstractABCase
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.SLOW);
fuzzer.setSlowSendSegmentSize(1);
try
{
fuzzer.send(send);
}
catch (SocketException ignore)
{
// Potential for SocketException (Broken Pipe) here.
// But not in 100% of testing scenarios. It is a safe
// exception to ignore in this testing scenario, as the
// slow writing of the frames can result in the server
// throwing a PROTOCOL ERROR termination/close when it
// encounters the bad continuation frame above (this
// termination is the expected behavior), and this
// early socket close can propagate back to the client
// before it has a chance to finish writing out the
// remaining frame octets
}
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
finally
@ -158,7 +141,7 @@ public class TestABCase5 extends AbstractABCase
{
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
finally
@ -186,7 +169,7 @@ public class TestABCase5 extends AbstractABCase
{
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.send(send);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
finally
@ -215,23 +198,7 @@ public class TestABCase5 extends AbstractABCase
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.SLOW);
fuzzer.setSlowSendSegmentSize(1);
try
{
fuzzer.send(send);
}
catch (SocketException ignore)
{
// Potential for SocketException (Broken Pipe) here.
// But not in 100% of testing scenarios. It is a safe
// exception to ignore in this testing scenario, as the
// slow writing of the frames can result in the server
// throwing a PROTOCOL ERROR termination/close when it
// encounters the bad continuation frame above (this
// termination is the expected behavior), and this
// early socket close can propagate back to the client
// before it has a chance to finish writing out the
// remaining frame octets
}
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
finally
@ -294,7 +261,7 @@ public class TestABCase5 extends AbstractABCase
{
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
finally