Search in sources :

Example 41 with Configuration

use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.

the class ClientPartialWriteIT method shouldWriteWhenMoreDataArrivesWhileAwaitingSocketWritable.

@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.sent.data.multiple.frames/client", "${server}/client.sent.data.multiple.frames/server" })
public void shouldWriteWhenMoreDataArrivesWhileAwaitingSocketWritable() throws Exception {
    // processData will be called for each of the two data frames. Make the first
    // do a partial write, then write nothing until handleWrite is called after the
    // second processData call, when we write everything.
    AtomicBoolean finishWrite = new AtomicBoolean(false);
    OnDataHelper.fragmentWrites(concat(of(5), generate(() -> finishWrite.getAndSet(true) ? 0 : 0)));
    HandleWriteHelper.fragmentWrites(generate(() -> finishWrite.get() ? ALL : 0));
    k3po.finish();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Configuration(io.aklivity.zilla.runtime.engine.test.annotation.Configuration) Test(org.junit.Test) Specification(org.kaazing.k3po.junit.annotation.Specification)

Example 42 with Configuration

use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.

the class ClientPartialWriteLimitsIT method shouldWriteWhenMoreDataArrivesWhileAwaitingSocketWritableWithoutOverflowingSlot.

@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.sent.data.multiple.frames/client", "${server}/client.sent.data.multiple.frames/server" })
public void shouldWriteWhenMoreDataArrivesWhileAwaitingSocketWritableWithoutOverflowingSlot() throws Exception {
    AtomicInteger dataFramesReceived = new AtomicInteger();
    OnDataHelper.fragmentWrites(generate(() -> dataFramesReceived.incrementAndGet() == 1 ? 5 : dataFramesReceived.get() == 2 ? 6 : ALL));
    HandleWriteHelper.fragmentWrites(generate(() -> dataFramesReceived.get() >= 2 ? ALL : 0));
    k3po.finish();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Configuration(io.aklivity.zilla.runtime.engine.test.annotation.Configuration) Test(org.junit.Test) Specification(org.kaazing.k3po.junit.annotation.Specification)

Example 43 with Configuration

use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.

the class ClientResetAndAbortIT method shouldShutdownOutputWhenClientSendsAbort.

@Test
@Configuration("client.host.json")
@Specification({ "${client}/client.sent.abort/client" })
public void shouldShutdownOutputWhenClientSendsAbort() 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(20);
            int len = channel.read(buf);
            assertEquals(-1, len);
        } finally {
            k3po.finish();
        }
    }
}
Also used : ServerSocketChannel(java.nio.channels.ServerSocketChannel) SocketChannel(java.nio.channels.SocketChannel) InetSocketAddress(java.net.InetSocketAddress) ByteBuffer(java.nio.ByteBuffer) ServerSocketChannel(java.nio.channels.ServerSocketChannel) Configuration(io.aklivity.zilla.runtime.engine.test.annotation.Configuration) Test(org.junit.Test) Specification(org.kaazing.k3po.junit.annotation.Specification)

Example 44 with Configuration

use of io.aklivity.zilla.runtime.engine.test.annotation.Configuration in project zilla by aklivity.

the class ServerStatsIT method shouldReceiveNonEmptyMessage.

@Test
@Configuration("server.when.json")
@Specification({ "${net}/non.empty/request", "${app}/non.empty/server" })
public void shouldReceiveNonEmptyMessage() throws Exception {
    k3po.finish();
    EngineStats stats = engine.stats("test", "net0");
    assertEquals(0, stats.initialBytes());
    assertEquals(19, stats.replyBytes());
// assertEquals(0, stats.initialMessages());
// assertEquals(1, stats.replyMessages());
}
Also used : EngineStats(io.aklivity.zilla.runtime.engine.EngineStats) Configuration(io.aklivity.zilla.runtime.engine.test.annotation.Configuration) Test(org.junit.Test) Specification(org.kaazing.k3po.junit.annotation.Specification)

Aggregations

Configuration (io.aklivity.zilla.runtime.engine.test.annotation.Configuration)44 Test (org.junit.Test)43 Specification (org.kaazing.k3po.junit.annotation.Specification)43 InetSocketAddress (java.net.InetSocketAddress)32 SocketChannel (java.nio.channels.SocketChannel)32 ByteBuffer (java.nio.ByteBuffer)19 ServerSocketChannel (java.nio.channels.ServerSocketChannel)15 BMRule (org.jboss.byteman.contrib.bmunit.BMRule)8 EngineStats (io.aklivity.zilla.runtime.engine.EngineStats)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 IOException (java.io.IOException)4 BMRules (org.jboss.byteman.contrib.bmunit.BMRules)2 PropertyDef (io.aklivity.zilla.runtime.engine.Configuration.PropertyDef)1 Engine (io.aklivity.zilla.runtime.engine.Engine)1 EngineBuilder (io.aklivity.zilla.runtime.engine.EngineBuilder)1 EngineConfiguration (io.aklivity.zilla.runtime.engine.EngineConfiguration)1 ENGINE_COMMAND_BUFFER_CAPACITY (io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_COMMAND_BUFFER_CAPACITY)1 ENGINE_COUNTERS_BUFFER_CAPACITY (io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_COUNTERS_BUFFER_CAPACITY)1 ENGINE_DIRECTORY (io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_DIRECTORY)1