Search in sources :

Example 91 with InterruptAfter

use of io.aeron.test.InterruptAfter in project aeron by real-logic.

the class ReceiverTest method shouldCreateRcvTermAndSendSmOnSetup.

@Test
@InterruptAfter(10)
public void shouldCreateRcvTermAndSendSmOnSetup() throws IOException {
    receiverProxy.registerReceiveChannelEndpoint(receiveChannelEndpoint);
    receiverProxy.addSubscription(receiveChannelEndpoint, STREAM_ID);
    receiver.doWork();
    fillSetupFrame(setupHeader);
    receiveChannelEndpoint.onSetupMessage(setupHeader, setupBuffer, SetupFlyweight.HEADER_LENGTH, senderAddress, 0);
    final PublicationImage image = new PublicationImage(CORRELATION_ID, ctx, receiveChannelEndpoint, 0, senderAddress, SESSION_ID, STREAM_ID, INITIAL_TERM_ID, ACTIVE_TERM_ID, INITIAL_TERM_OFFSET, rawLog, mockFeedbackDelayGenerator, POSITIONS, mockHighestReceivedPosition, mockRebuildPosition, SOURCE_ADDRESS, congestionControl);
    final int messagesRead = toConductorQueue.drain((e) -> {
        // pass in new term buffer from conductor, which should trigger SM
        receiverProxy.newPublicationImage(receiveChannelEndpoint, image);
    });
    assertThat(messagesRead, is(1));
    nanoClock.advance(STATUS_MESSAGE_TIMEOUT * 2);
    receiver.doWork();
    final ByteBuffer rcvBuffer = ByteBuffer.allocateDirect(256);
    InetSocketAddress rcvAddress;
    do {
        rcvAddress = (InetSocketAddress) senderChannel.receive(rcvBuffer);
    } while (null == rcvAddress);
    statusHeader.wrap(new UnsafeBuffer(rcvBuffer));
    assertNotNull(rcvAddress);
    assertThat(rcvAddress.getPort(), is(UDP_CHANNEL.remoteData().getPort()));
    assertThat(statusHeader.headerType(), is(HeaderFlyweight.HDR_TYPE_SM));
    assertThat(statusHeader.streamId(), is(STREAM_ID));
    assertThat(statusHeader.sessionId(), is(SESSION_ID));
    assertThat(statusHeader.consumptionTermId(), is(ACTIVE_TERM_ID));
    assertThat(statusHeader.frameLength(), is(StatusMessageFlyweight.HEADER_LENGTH));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 92 with InterruptAfter

use of io.aeron.test.InterruptAfter in project aeron by real-logic.

the class ArchiveTest method recordAndReplayConcurrentPublication.

@ParameterizedTest
@MethodSource("threadingModes")
@InterruptAfter(10)
public void recordAndReplayConcurrentPublication(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
    before(threadingMode, archiveThreadingMode);
    final Publication controlPublication = client.addPublication(archive.context().localControlChannel(), archive.context().localControlStreamId());
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    final Subscription recordingEvents = client.addSubscription(archive.context().recordingEventsChannel(), archive.context().recordingEventsStreamId());
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final Publication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int termBufferLength = recordedPublication.termBufferLength();
    final long startPosition = recordedPublication.position();
    preSendChecks(archiveProxy, recordingEvents, recordedPublication.sessionId(), termBufferLength, startPosition);
    prepAndSendMessages(recordingEvents, recordedPublication);
    postPublicationValidations(archiveProxy, recordingEvents, termBufferLength, recordedPublication.initialTermId(), recordedPublication.maxPayloadLength());
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) InterruptAfter(io.aeron.test.InterruptAfter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 93 with InterruptAfter

use of io.aeron.test.InterruptAfter in project aeron by real-logic.

the class CatalogWithJumboRecordingsAndGapsTest method listRecordingsForUri.

@ParameterizedTest
@InterruptAfter(10)
@MethodSource("listRecordingsForUriArguments")
void listRecordingsForUri(final long fromRecordingId, final int recordCount, final String channelFragment, final int streamId, final int expectedRecordCount) {
    final MutableInteger callCount = new MutableInteger();
    final int count = aeronArchive.listRecordingsForUri(fromRecordingId, recordCount, channelFragment, streamId, (controlSessionId, correlationId, recordingId, startTimestamp, stopTimestamp, startPosition, stopPosition, initialTermId, segmentFileLength, termBufferLength, mtuLength, sessionId, streamId1, strippedChannel, originalChannel, sourceIdentity) -> callCount.increment());
    assertEquals(expectedRecordCount, count);
    assertEquals(expectedRecordCount, callCount.get());
}
Also used : MutableInteger(org.agrona.collections.MutableInteger) InterruptAfter(io.aeron.test.InterruptAfter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 94 with InterruptAfter

use of io.aeron.test.InterruptAfter in project aeron by real-logic.

the class CatalogWithJumboRecordingsAndGapsTest method listRecordings.

@ParameterizedTest
@InterruptAfter(10)
@MethodSource("listRecordingsArguments")
void listRecordings(final long fromRecordingId, final int recordCount, final int expectedRecordCount) {
    final MutableInteger callCount = new MutableInteger();
    final int count = aeronArchive.listRecordings(fromRecordingId, recordCount, (controlSessionId, correlationId, recordingId, startTimestamp, stopTimestamp, startPosition, stopPosition, initialTermId, segmentFileLength, termBufferLength, mtuLength, sessionId, streamId, strippedChannel, originalChannel, sourceIdentity) -> callCount.increment());
    assertEquals(expectedRecordCount, count);
    assertEquals(expectedRecordCount, callCount.get());
}
Also used : MutableInteger(org.agrona.collections.MutableInteger) InterruptAfter(io.aeron.test.InterruptAfter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 95 with InterruptAfter

use of io.aeron.test.InterruptAfter in project aeron by real-logic.

the class ManageRecordingHistoryTest method shouldPurgeForStreamJoinedAtTheBeginning.

@Test
@InterruptAfter(10)
void shouldPurgeForStreamJoinedAtTheBeginning() {
    final String messagePrefix = "Message-Prefix-";
    final long targetPosition = (SEGMENT_LENGTH * 3L) + 1;
    try (Publication publication = aeronArchive.addRecordedPublication(uriBuilder.build(), STREAM_ID)) {
        final CountersReader counters = aeron.countersReader();
        final int counterId = awaitRecordingCounterId(counters, publication.sessionId());
        final long recordingId = RecordingPos.getRecordingId(counters, counterId);
        offerToPosition(publication, messagePrefix, targetPosition);
        awaitPosition(counters, counterId, publication.position());
        final long startPosition = 0L;
        final long segmentFileBasePosition = AeronArchive.segmentFileBasePosition(startPosition, SEGMENT_LENGTH * 2L, TERM_LENGTH, SEGMENT_LENGTH);
        final long count = aeronArchive.purgeSegments(recordingId, segmentFileBasePosition);
        assertEquals(2L, count);
        assertEquals(segmentFileBasePosition, aeronArchive.getStartPosition(recordingId));
        aeronArchive.stopRecording(publication);
    }
}
Also used : Publication(io.aeron.Publication) CountersReader(org.agrona.concurrent.status.CountersReader) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Aggregations

InterruptAfter (io.aeron.test.InterruptAfter)304 Test (org.junit.jupiter.api.Test)240 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)90 MediaDriver (io.aeron.driver.MediaDriver)74 TestNode (io.aeron.test.cluster.TestNode)72 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)68 Tests (io.aeron.test.Tests)66 CountersReader (org.agrona.concurrent.status.CountersReader)64 MethodSource (org.junit.jupiter.params.provider.MethodSource)62 SlowTest (io.aeron.test.SlowTest)60 InterruptingTestCallback (io.aeron.test.InterruptingTestCallback)58 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)58 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)54 TestCluster (io.aeron.test.cluster.TestCluster)52 ThreadingMode (io.aeron.driver.ThreadingMode)50 MutableInteger (org.agrona.collections.MutableInteger)50 DirectBuffer (org.agrona.DirectBuffer)48 SystemTestWatcher (io.aeron.test.SystemTestWatcher)46 MutableLong (org.agrona.collections.MutableLong)46 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)46