Search in sources :

Example 1 with EngineStats

use of io.aklivity.zilla.runtime.engine.EngineStats in project zilla by aklivity.

the class ClientStatsIT method shouldEchoPayloadLength10k.

@Test
@Configuration("client.json")
@Specification({ "${app}/echo.payload.length.10k/client", "${net}/echo.payload.length.10k/server" })
public void shouldEchoPayloadLength10k() throws Exception {
    k3po.finish();
    EngineStats stats = engine.stats("test", "app0");
    assertThat(stats.initialBytes(), equalTo(10240L));
    assertThat(stats.replyBytes(), equalTo(10240L));
}
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)

Example 2 with EngineStats

use of io.aklivity.zilla.runtime.engine.EngineStats in project zilla by aklivity.

the class ServerIT method shouldUnbindRebind.

@Test
@Configuration("server.json")
@Specification({ "${app}/max.connections/server" })
public void shouldUnbindRebind() throws Exception {
    k3po.start();
    SocketChannel channel1 = SocketChannel.open();
    channel1.connect(new InetSocketAddress("127.0.0.1", 8080));
    SocketChannel channel2 = SocketChannel.open();
    channel2.connect(new InetSocketAddress("127.0.0.1", 8080));
    SocketChannel channel3 = SocketChannel.open();
    channel3.connect(new InetSocketAddress("127.0.0.1", 8080));
    k3po.awaitBarrier("CONNECTION_ACCEPTED_1");
    k3po.awaitBarrier("CONNECTION_ACCEPTED_2");
    k3po.awaitBarrier("CONNECTION_ACCEPTED_3");
    EngineStats stats = engine.stats("test", "net0");
    assertEquals(3, stats.initialOpens());
    assertEquals(0, stats.initialCloses());
    assertEquals(3, stats.replyOpens());
    assertEquals(0, stats.replyCloses());
    SocketChannel channel4 = SocketChannel.open();
    try {
        channel4.connect(new InetSocketAddress("127.0.0.1", 8080));
        fail("4th connect shouldn't succeed as max.connections = 3");
    } catch (IOException ioe) {
    // expected
    }
    assertEquals(3, stats.initialOpens());
    assertEquals(0, stats.initialCloses());
    assertEquals(3, stats.replyOpens());
    assertEquals(0, stats.replyCloses());
    channel1.close();
    channel4.close();
    k3po.awaitBarrier("CLOSED");
    // sleep so that rebind happens
    Thread.sleep(200);
    assertEquals(3, stats.initialOpens());
    assertEquals(1, stats.initialCloses());
    assertEquals(3, stats.replyOpens());
    assertEquals(1, stats.replyCloses());
    SocketChannel channel5 = SocketChannel.open();
    channel5.connect(new InetSocketAddress("127.0.0.1", 8080));
    k3po.awaitBarrier("CONNECTION_ACCEPTED_4");
    assertEquals(4, stats.initialOpens());
    assertEquals(1, stats.initialCloses());
    assertEquals(4, stats.replyOpens());
    assertEquals(1, stats.replyCloses());
    channel2.close();
    channel3.close();
    channel5.close();
    Thread.sleep(500);
    assertEquals(4, stats.initialOpens());
    assertEquals(4, stats.initialCloses());
    assertEquals(4, stats.replyOpens());
    assertEquals(4, stats.replyCloses());
    k3po.finish();
}
Also used : SocketChannel(java.nio.channels.SocketChannel) InetSocketAddress(java.net.InetSocketAddress) EngineStats(io.aklivity.zilla.runtime.engine.EngineStats) IOException(java.io.IOException) Configuration(io.aklivity.zilla.runtime.engine.test.annotation.Configuration) Test(org.junit.Test) Specification(org.kaazing.k3po.junit.annotation.Specification)

Example 3 with EngineStats

use of io.aklivity.zilla.runtime.engine.EngineStats in project zilla by aklivity.

the class ServerStatsIT method shouldSendAndReceiveData.

@Test
@Configuration("server.json")
@Specification({ "${server}/client.and.server.sent.data.multiple.frames/server", "${client}/client.and.server.sent.data.multiple.frames/client" })
public void shouldSendAndReceiveData() throws Exception {
    k3po.finish();
    EngineStats stats = engine.stats("test", "net0");
    assertThat(stats.initialOpens(), equalTo(1L));
    assertThat(stats.replyOpens(), equalTo(1L));
    assertThat(stats.initialBytes(), equalTo(26L));
    assertThat(stats.replyBytes(), equalTo(26L));
}
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)

Example 4 with EngineStats

use of io.aklivity.zilla.runtime.engine.EngineStats in project zilla by aklivity.

the class EngineTest method shouldConfigure.

@Test
public void shouldConfigure() throws Exception {
    String resource = String.format("%s-%s.json", getClass().getSimpleName(), "configure");
    URL configURL = getClass().getResource(resource);
    List<Throwable> errors = new LinkedList<>();
    try (Engine engine = Engine.builder().config(config).configURL(configURL).errorHandler(errors::add).build()) {
        engine.start().get();
        EngineStats stats = engine.stats("default", "test0");
        assertEquals(0L, stats.initialOpens());
        assertEquals(0L, stats.initialCloses());
        assertEquals(0L, stats.initialErrors());
        assertEquals(0L, stats.initialBytes());
        assertEquals(0L, stats.replyOpens());
        assertEquals(0L, stats.replyCloses());
        assertEquals(0L, stats.replyErrors());
        assertEquals(0L, stats.replyBytes());
    } catch (Throwable ex) {
        errors.add(ex);
    } finally {
        assertThat(errors, empty());
    }
}
Also used : EngineStats(io.aklivity.zilla.runtime.engine.EngineStats) URL(java.net.URL) LinkedList(java.util.LinkedList) Engine(io.aklivity.zilla.runtime.engine.Engine) Test(org.junit.Test)

Example 5 with EngineStats

use of io.aklivity.zilla.runtime.engine.EngineStats in project zilla by aklivity.

the class ServerStatsIT method shouldEchoPayloadLength10k.

@Test
@Configuration("server.json")
@Specification({ "${net}/echo.payload.length.10k/client", "${app}/echo.payload.length.10k/server" })
public void shouldEchoPayloadLength10k() throws Exception {
    k3po.finish();
    EngineStats stats = engine.stats("test", "net0");
    assertThat(stats.initialBytes(), greaterThan(10240L));
    assertThat(stats.replyBytes(), greaterThan(10240L));
}
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

EngineStats (io.aklivity.zilla.runtime.engine.EngineStats)7 Test (org.junit.Test)7 Configuration (io.aklivity.zilla.runtime.engine.test.annotation.Configuration)6 Specification (org.kaazing.k3po.junit.annotation.Specification)6 Engine (io.aklivity.zilla.runtime.engine.Engine)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 URL (java.net.URL)1 SocketChannel (java.nio.channels.SocketChannel)1 LinkedList (java.util.LinkedList)1