Search in sources :

Example 6 with Theory

use of org.junit.experimental.theories.Theory in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleImpliedLocalPortFormatWithAeronUri.

@Theory
public void shouldHandleImpliedLocalPortFormatWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124", interfaceKey, "localhost"));
    assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 7 with Theory

use of org.junit.experimental.theories.Theory in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast.

@Theory
public void shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "[::1]:40124", interfaceKey, "[::]"));
    assertThat(udpChannel.localData(), is(new InetSocketAddress("::", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("::", 0)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("::1", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("::1", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 8 with Theory

use of org.junit.experimental.theories.Theory in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleCanonicalFormForUnicastCorrectlyWithAeronUri.

@Theory
public void shouldHandleCanonicalFormForUnicastCorrectlyWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "192.168.0.1:40456"));
    final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "192.168.0.1:40456", interfaceKey, "127.0.0.1"));
    final UdpChannel udpChannelLocalPort = UdpChannel.parse(uri(endpointKey, "192.168.0.1:40456", interfaceKey, "127.0.0.1:40455"));
    final UdpChannel udpChannelLocalhost = UdpChannel.parse(uri(endpointKey, "localhost:40456", interfaceKey, "localhost"));
    assertThat(udpChannel.canonicalForm(), is("UDP-00000000-0-c0a80001-40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-7f000001-0-c0a80001-40456"));
    assertThat(udpChannelLocalPort.canonicalForm(), is("UDP-7f000001-40455-c0a80001-40456"));
    assertThat(udpChannelLocalhost.canonicalForm(), is("UDP-7f000001-0-7f000001-40456"));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 9 with Theory

use of org.junit.experimental.theories.Theory in project Aeron by real-logic.

the class PubAndSubTest method shouldReceivePublishedMessageBatchedWithDataLoss.

@Theory
@Test(timeout = 10000)
public void shouldReceivePublishedMessageBatchedWithDataLoss(final String channel) throws Exception {
    final int termBufferLength = 64 * 1024;
    final int numMessagesInTermBuffer = 64;
    final int messageLength = (termBufferLength / numMessagesInTermBuffer) - HEADER_LENGTH;
    final int numMessagesToSend = 2 * numMessagesInTermBuffer;
    final int numBatches = 4;
    final int numMessagesPerBatch = numMessagesToSend / numBatches;
    final LossReport lossReport = mock(LossReport.class);
    context.lossReport(lossReport);
    final LossGenerator dataLossGenerator = DebugChannelEndpointConfiguration.lossGeneratorSupplier(0.10, 0xcafebabeL);
    final LossGenerator noLossGenerator = DebugChannelEndpointConfiguration.lossGeneratorSupplier(0, 0);
    context.publicationTermBufferLength(termBufferLength);
    context.sendChannelEndpointSupplier((udpChannel, statusIndicator, context) -> new DebugSendChannelEndpoint(udpChannel, statusIndicator, context, noLossGenerator, noLossGenerator));
    context.receiveChannelEndpointSupplier((udpChannel, dispatcher, statusIndicator, context) -> new DebugReceiveChannelEndpoint(udpChannel, dispatcher, statusIndicator, context, dataLossGenerator, noLossGenerator));
    launch(channel);
    Assume.assumeThat(channel, not(IPC_URI));
    for (int i = 0; i < numBatches; i++) {
        for (int j = 0; j < numMessagesPerBatch; j++) {
            while (publication.offer(buffer, 0, messageLength) < 0L) {
                Thread.yield();
            }
        }
        final AtomicInteger fragmentsRead = new AtomicInteger();
        SystemTestHelper.executeUntil(() -> fragmentsRead.get() >= numMessagesPerBatch, (j) -> {
            fragmentsRead.addAndGet(subscription.poll(fragmentHandler, 10));
            Thread.yield();
        }, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(900));
    }
    verify(fragmentHandler, times(numMessagesToSend)).onFragment(any(DirectBuffer.class), anyInt(), eq(messageLength), any(Header.class));
    verify(lossReport).createEntry(anyLong(), anyLong(), anyInt(), eq(STREAM_ID), anyString(), anyString());
}
Also used : DirectBuffer(org.agrona.DirectBuffer) DebugReceiveChannelEndpoint(io.aeron.driver.ext.DebugReceiveChannelEndpoint) LossGenerator(io.aeron.driver.ext.LossGenerator) Header(io.aeron.logbuffer.Header) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LossReport(io.aeron.driver.reports.LossReport) DebugSendChannelEndpoint(io.aeron.driver.ext.DebugSendChannelEndpoint) DataPoint(org.junit.experimental.theories.DataPoint) DebugSendChannelEndpoint(io.aeron.driver.ext.DebugSendChannelEndpoint) DebugReceiveChannelEndpoint(io.aeron.driver.ext.DebugReceiveChannelEndpoint) Theory(org.junit.experimental.theories.Theory) Test(org.junit.Test)

Example 10 with Theory

use of org.junit.experimental.theories.Theory in project Aeron by real-logic.

the class PubAndSubTest method shouldContinueAfterBufferRolloverWithPaddingBatched.

@Theory
@Test(timeout = 10000)
public void shouldContinueAfterBufferRolloverWithPaddingBatched(final String channel) throws Exception {
    /*
         * 65536 bytes in the buffer
         * 63 * 1032 = 65016
         * 65536 - 65016 = 520 bytes padding at the end
         * so, sending 64 messages causes last to overflow
         */
    final int termBufferLength = 64 * 1024;
    final int messageLength = 1032 - HEADER_LENGTH;
    final int numMessagesToSend = 64;
    final int numBatchesPerTerm = 4;
    final int numMessagesPerBatch = numMessagesToSend / numBatchesPerTerm;
    context.publicationTermBufferLength(termBufferLength);
    launch(channel);
    for (int i = 0; i < numBatchesPerTerm; i++) {
        for (int j = 0; j < numMessagesPerBatch; j++) {
            while (publication.offer(buffer, 0, messageLength) < 0L) {
                Thread.yield();
            }
        }
        final AtomicInteger fragmentsRead = new AtomicInteger();
        SystemTestHelper.executeUntil(() -> fragmentsRead.get() >= numMessagesPerBatch, (j) -> {
            fragmentsRead.addAndGet(subscription.poll(fragmentHandler, 10));
            Thread.yield();
        }, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(900));
    }
    verify(fragmentHandler, times(numMessagesToSend)).onFragment(any(DirectBuffer.class), anyInt(), eq(messageLength), any(Header.class));
}
Also used : DirectBuffer(org.agrona.DirectBuffer) Header(io.aeron.logbuffer.Header) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataPoint(org.junit.experimental.theories.DataPoint) DebugSendChannelEndpoint(io.aeron.driver.ext.DebugSendChannelEndpoint) DebugReceiveChannelEndpoint(io.aeron.driver.ext.DebugReceiveChannelEndpoint) Theory(org.junit.experimental.theories.Theory) Test(org.junit.Test)

Aggregations

Theory (org.junit.experimental.theories.Theory)107 DataPoint (org.junit.experimental.theories.DataPoint)23 Test (org.junit.Test)22 Header (io.aeron.logbuffer.Header)15 DirectBuffer (org.agrona.DirectBuffer)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 DebugReceiveChannelEndpoint (io.aeron.driver.ext.DebugReceiveChannelEndpoint)11 DebugSendChannelEndpoint (io.aeron.driver.ext.DebugSendChannelEndpoint)11 UdpChannel (io.aeron.driver.media.UdpChannel)11 MediaDriver (io.aeron.driver.MediaDriver)8 Lock (java.util.concurrent.locks.Lock)7 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 LongAdder (java.util.concurrent.atomic.LongAdder)6 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)6 PrimitiveCollection (org.neo4j.collection.primitive.PrimitiveCollection)6 InOrder (org.mockito.InOrder)5 InputStream (java.io.InputStream)4 BaseStream (java.util.stream.BaseStream)4 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)4 Metric (org.springframework.boot.actuate.metrics.Metric)4