use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.
the class ClientIOExceptionFromReadIT method shouldNotResetWhenProcessingEndAfterIOExceptionFromRead.
@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.received.abort.sent.end/client" })
public void shouldNotResetWhenProcessingEndAfterIOExceptionFromRead() throws Exception {
try (ServerSocketChannel server = ServerSocketChannel.open()) {
server.setOption(SO_REUSEADDR, true);
server.bind(new InetSocketAddress("127.0.0.1", 8080));
k3po.start();
try (SocketChannel channel = server.accept()) {
k3po.awaitBarrier("CONNECTED");
channel.setOption(StandardSocketOptions.SO_LINGER, 0);
channel.close();
k3po.finish();
}
}
}
use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.
the class ClientIOExceptionFromReadIT method shouldReportIOExceptionFromReadAsAbortAndReset.
@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.received.reset.and.abort/client" })
public void shouldReportIOExceptionFromReadAsAbortAndReset() throws Exception {
try (ServerSocketChannel server = ServerSocketChannel.open()) {
server.setOption(SO_REUSEADDR, true);
server.bind(new InetSocketAddress("127.0.0.1", 8080));
k3po.start();
try (SocketChannel channel = server.accept()) {
k3po.awaitBarrier("CONNECTED");
channel.setOption(StandardSocketOptions.SO_LINGER, 0);
channel.close();
k3po.finish();
}
}
}
use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.
the class ClientIOExceptionFromWriteIT method shouldAbortAndResetWhenDeferredWriteThrowsIOException.
@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.sent.data.received.abort.and.reset/client" })
@BMRules(rules = { @BMRule(name = "onData", helper = "io.aklivity.zilla.runtime.binding.tcp.internal.SocketChannelHelper$OnDataHelper", targetClass = "^java.nio.channels.SocketChannel", targetMethod = "write(java.nio.ByteBuffer)", condition = "callerEquals(\"TcpClientFactory$TcpClient.onAppData\", true, 2)", action = "return doWrite($0, $1);"), @BMRule(name = "handleWrite", targetClass = "^java.nio.channels.SocketChannel", targetMethod = "write(java.nio.ByteBuffer)", condition = "callerEquals(\"TcpClientFactory$TcpClient.onNetWritable\", true, 2)", action = "throw new IOException(\"Simulating an IOException from write\")") })
public void shouldAbortAndResetWhenDeferredWriteThrowsIOException() throws Exception {
OnDataHelper.fragmentWrites(generate(() -> 0));
try (ServerSocketChannel server = ServerSocketChannel.open()) {
server.setOption(SO_REUSEADDR, true);
server.bind(new InetSocketAddress("127.0.0.1", 8080));
k3po.start();
try (SocketChannel channel = server.accept()) {
k3po.finish();
}
}
}
use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.
the class ClientIT method shouldWriteDataAfterReceivingEndOfRead.
@Test
@Configuration("client.host.json")
@Specification({ "${app}/client.sent.end.then.received.data/client" // No support for "read closed" in k3po tcp
})
public void shouldWriteDataAfterReceivingEndOfRead() throws Exception {
try (ServerSocketChannel server = ServerSocketChannel.open()) {
server.setOption(SO_REUSEADDR, true);
server.bind(new InetSocketAddress("127.0.0.1", 8080));
k3po.start();
try (SocketChannel channel = server.accept()) {
ByteBuffer buf = ByteBuffer.allocate(256);
int len = channel.read(buf);
assertEquals(-1, len);
channel.write(UTF_8.encode("server data"));
k3po.finish();
}
}
}
use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.
the class ClientPartialWriteLimitsIT method shouldResetStreamsExceedingPartialWriteStreamsLimit.
@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.sent.data.multiple.streams.second.was.reset/client" })
public void shouldResetStreamsExceedingPartialWriteStreamsLimit() throws Exception {
// avoid spin write for first stream write
OnDataHelper.fragmentWrites(concat(of(1), generate(() -> 0)));
AtomicBoolean resetReceived = new AtomicBoolean(false);
HandleWriteHelper.fragmentWrites(generate(() -> resetReceived.get() ? ALL : 0));
try (ServerSocketChannel server = ServerSocketChannel.open()) {
server.setOption(SO_REUSEADDR, true);
server.bind(new InetSocketAddress("127.0.0.1", 8080));
k3po.start();
try (SocketChannel channel1 = server.accept();
SocketChannel channel2 = server.accept()) {
k3po.awaitBarrier("CLIENT_TWO_RESET_RECEIVED");
resetReceived.set(true);
ByteBuffer buf = ByteBuffer.allocate(256);
while (buf.position() < 13) {
int len = channel1.read(buf);
assert len != -1;
}
buf.flip();
assertEquals("client data 1", UTF_8.decode(buf).toString());
buf.rewind();
int len = 0;
while (buf.position() < 13) {
len = channel2.read(buf);
if (len == -1) {
break;
}
}
buf.flip();
assertEquals(0, buf.remaining());
assertEquals(-1, len);
k3po.finish();
}
}
}
Aggregations