use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class PollingRecordPublisherTest method testRunOnCompletelyConsumedShardReturnsComplete.
@Test
public void testRunOnCompletelyConsumedShardReturnsComplete() throws Exception {
KinesisProxyInterface fakeKinesis = totalNumOfRecordsAfterNumOfGetRecordsCalls(5, 1, 100);
PollingRecordPublisher recordPublisher = createPollingRecordPublisher(fakeKinesis);
assertEquals(COMPLETE, recordPublisher.run(new TestConsumer()));
assertEquals(COMPLETE, recordPublisher.run(new TestConsumer()));
}
use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class PollingRecordPublisherTest method testRunReturnsCompleteWhenShardExpires.
@Test
public void testRunReturnsCompleteWhenShardExpires() throws Exception {
// There are 2 batches available in the stream
KinesisProxyInterface fakeKinesis = totalNumOfRecordsAfterNumOfGetRecordsCalls(5, 2, 100);
PollingRecordPublisher recordPublisher = createPollingRecordPublisher(fakeKinesis);
// First call results in INCOMPLETE, there is one batch left
assertEquals(INCOMPLETE, recordPublisher.run(new TestConsumer()));
// After second call the shard is complete
assertEquals(COMPLETE, recordPublisher.run(new TestConsumer()));
}
use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class FanOutRecordPublisherTest method testSubscribeToShardIgnoresReadTimeoutInRetryPolicy.
@Test
public void testSubscribeToShardIgnoresReadTimeoutInRetryPolicy() throws Exception {
Properties efoProperties = createEfoProperties();
efoProperties.setProperty(SUBSCRIBE_TO_SHARD_RETRIES, String.valueOf(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES));
FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
ReadTimeoutException retryableError = ReadTimeoutException.INSTANCE;
FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(retryableError);
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
int count = 0;
while (recordPublisher.run(new TestConsumer()) == RecordPublisherRunResult.INCOMPLETE) {
if (++count > EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES) {
break;
}
}
// No exception is thrown, but we still backoff.
verify(backoff, times(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES + 1)).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt());
}
use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class FanOutRecordPublisherTest method testToSdkV2StartingPositionTrimHorizon.
@Test
public void testToSdkV2StartingPositionTrimHorizon() throws Exception {
SingleShardFanOutKinesisV2 kinesis = emptyShard();
RecordPublisher publisher = createRecordPublisher(kinesis, StartingPosition.continueFromSequenceNumber(SENTINEL_EARLIEST_SEQUENCE_NUM.get()));
publisher.run(new TestConsumer());
assertNull(kinesis.getStartingPositionForSubscription(0).sequenceNumber());
assertEquals(TRIM_HORIZON, kinesis.getStartingPositionForSubscription(0).type());
}
use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class FanOutRecordPublisherTest method testInterruptedPublisherReturnsCancelled.
@Test
public void testInterruptedPublisherReturnsCancelled() throws Exception {
KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(new SdkInterruptedException(null));
RecordPublisher publisher = createRecordPublisher(kinesis, StartingPosition.continueFromSequenceNumber(SEQUENCE_NUMBER));
RecordPublisherRunResult actual = publisher.run(new TestConsumer());
assertEquals(CANCELLED, actual);
}
Aggregations