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));
}
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());
}
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());
}
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());
}
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);
}
}
Aggregations