Search in sources :

Example 26 with Theory

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

the class RetransmitHandlerTest method shouldRetransmitOnMultipleNaks.

@Theory
public void shouldRetransmitOnMultipleNaks(final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    createTermBuffer(creator, 5);
    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH, TERM_BUFFER_LENGTH, retransmitSender);
    handler.onNak(TERM_ID, offsetOfFrame(1), ALIGNED_FRAME_LENGTH, TERM_BUFFER_LENGTH, retransmitSender);
    currentTime = TimeUnit.MILLISECONDS.toNanos(100);
    handler.processTimeouts(currentTime, retransmitSender);
    final InOrder inOrder = inOrder(retransmitSender);
    inOrder.verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
    inOrder.verify(retransmitSender).resend(TERM_ID, offsetOfFrame(1), ALIGNED_FRAME_LENGTH);
}
Also used : InOrder(org.mockito.InOrder) Theory(org.junit.experimental.theories.Theory)

Example 27 with Theory

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

the class RetransmitHandlerTest method shouldRetransmitOnNakOverMtuLength.

@Theory
public void shouldRetransmitOnNakOverMtuLength(final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    final int numFramesPerMtu = MTU_LENGTH / ALIGNED_FRAME_LENGTH;
    createTermBuffer(creator, numFramesPerMtu * 5);
    handler.onNak(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2, TERM_BUFFER_LENGTH, retransmitSender);
    currentTime = TimeUnit.MILLISECONDS.toNanos(100);
    handler.processTimeouts(currentTime, retransmitSender);
    verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2);
}
Also used : DataPoint(org.junit.experimental.theories.DataPoint) Theory(org.junit.experimental.theories.Theory)

Example 28 with Theory

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

the class BufferClaimMessageTest method shouldReceivePublishedMessageWithInterleavedAbort.

@Theory
@Test(timeout = 10000)
public void shouldReceivePublishedMessageWithInterleavedAbort(final String channel) throws Exception {
    final BufferClaim bufferClaim = new BufferClaim();
    final UnsafeBuffer srcBuffer = new UnsafeBuffer(ByteBuffer.allocateDirect(MESSAGE_LENGTH));
    final MediaDriver.Context ctx = new MediaDriver.Context();
    try (MediaDriver ignore = MediaDriver.launch(ctx);
        Aeron aeron = Aeron.connect();
        Publication publication = aeron.addPublication(channel, STREAM_ID);
        Subscription subscription = aeron.addSubscription(channel, STREAM_ID)) {
        publishMessage(srcBuffer, publication);
        while (publication.tryClaim(MESSAGE_LENGTH, bufferClaim) < 0L) {
            Thread.yield();
        }
        publishMessage(srcBuffer, publication);
        bufferClaim.abort();
        final int expectedNumberOfFragments = 2;
        int numFragments = 0;
        do {
            numFragments += subscription.poll(mockFragmentHandler, FRAGMENT_COUNT_LIMIT);
        } while (numFragments < expectedNumberOfFragments);
        verify(mockFragmentHandler, times(expectedNumberOfFragments)).onFragment(any(DirectBuffer.class), anyInt(), eq(MESSAGE_LENGTH), any(Header.class));
    } finally {
        ctx.deleteAeronDirectory();
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer) MediaDriver(io.aeron.driver.MediaDriver) Header(io.aeron.logbuffer.Header) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) DataPoint(org.junit.experimental.theories.DataPoint) BufferClaim(io.aeron.logbuffer.BufferClaim) Theory(org.junit.experimental.theories.Theory) Test(org.junit.Test)

Example 29 with Theory

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

the class UdpChannelTest method shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri.

@Theory
public void shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost"));
    final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.1"));
    final UdpChannel udpChannelAllSystems = UdpChannel.parse(uri(endpointKey, "224.0.0.1:40456", interfaceKey, "127.0.0.1"));
    final UdpChannel udpChannelDefault = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456"));
    final UdpChannel udpChannelSubnet = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost/24"));
    final UdpChannel udpChannelSubnetLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.0/24"));
    assertThat(udpChannel.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
    assertThat(udpChannelAllSystems.canonicalForm(), is("UDP-7f000001-0-e0000001-40456"));
    assertThat(udpChannelSubnet.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
    assertThat(udpChannelSubnetLocal.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
    assertThat(udpChannelDefault.localInterface(), supportsMulticastOrIsLoopback());
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 30 with Theory

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

the class UdpChannelTest method shouldHandleIpV6CanonicalFormForMulticastCorrectly.

@Theory
public void shouldHandleIpV6CanonicalFormForMulticastCorrectly(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    Assume.assumeTrue(System.getProperty("java.net.preferIPv4Stack") == null);
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "[FF01::FD]:40456", interfaceKey, "localhost"));
    final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "[::1]:54321/64"));
    assertThat(udpChannel.canonicalForm(), is("UDP-7f000001-0-ff0100000000000000000000000000fd-40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-00000000000000000000000000000001-54321-e0000101-40456"));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Aggregations

Theory (org.junit.experimental.theories.Theory)97 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 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 BufferClaim (io.aeron.logbuffer.BufferClaim)3