Search in sources :

Example 6 with TestConsumer

use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.

the class FanOutRecordPublisherTest method testShardConsumerCompletesIfResourceNotFoundExceptionThrownFromSubscription.

@Test
public void testShardConsumerCompletesIfResourceNotFoundExceptionThrownFromSubscription() throws Exception {
    ResourceNotFoundException exception = ResourceNotFoundException.builder().build();
    SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(exception);
    RecordPublisher recordPublisher = createRecordPublisher(kinesis);
    TestConsumer consumer = new TestConsumer();
    assertEquals(COMPLETE, recordPublisher.run(consumer));
    // Will exit on the first subscription
    assertEquals(1, kinesis.getNumberOfSubscribeToShardInvocations());
}
Also used : RecordPublisher(org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher) ResourceNotFoundException(software.amazon.awssdk.services.kinesis.model.ResourceNotFoundException) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 7 with TestConsumer

use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.

the class FanOutRecordPublisherTest method testResourceNotFoundWhenObtainingSubscriptionTerminatesApplication.

@Test
public void testResourceNotFoundWhenObtainingSubscriptionTerminatesApplication() throws Exception {
    thrown.expect(ResourceNotFoundException.class);
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.resourceNotFoundWhenObtainingSubscription();
    RecordPublisher recordPublisher = createRecordPublisher(kinesis);
    recordPublisher.run(new TestConsumer());
}
Also used : RecordPublisher(org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 8 with TestConsumer

use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.

the class PollingRecordPublisherTest method testRunGetShardIteratorReturnsNullIsComplete.

@Test
public void testRunGetShardIteratorReturnsNullIsComplete() throws Exception {
    KinesisProxyInterface fakeKinesis = FakeKinesisBehavioursFactory.noShardsFoundForRequestedStreamsBehaviour();
    PollingRecordPublisher recordPublisher = createPollingRecordPublisher(fakeKinesis);
    assertEquals(COMPLETE, recordPublisher.run(new TestConsumer()));
}
Also used : KinesisProxyInterface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyInterface) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 9 with TestConsumer

use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.

the class PollingRecordPublisherTest method testRunPublishesRecordsToConsumer.

@Test
public void testRunPublishesRecordsToConsumer() throws Exception {
    KinesisProxyInterface fakeKinesis = totalNumOfRecordsAfterNumOfGetRecordsCalls(5, 1, 100);
    PollingRecordPublisher recordPublisher = createPollingRecordPublisher(fakeKinesis);
    TestConsumer consumer = new TestConsumer();
    recordPublisher.run(consumer);
    assertEquals(1, consumer.getRecordBatches().size());
    assertEquals(5, consumer.getRecordBatches().get(0).getDeaggregatedRecordSize());
    assertEquals(100L, consumer.getRecordBatches().get(0).getMillisBehindLatest(), 0);
}
Also used : KinesisProxyInterface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyInterface) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 10 with TestConsumer

use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.

the class PollingRecordPublisherTest method testRunGetRecordsRecoversFromExpiredIteratorException.

@Test
public void testRunGetRecordsRecoversFromExpiredIteratorException() throws Exception {
    KinesisProxyInterface fakeKinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCallsWithUnexpectedExpiredIterator(2, 2, 1, 500));
    PollingRecordPublisher recordPublisher = createPollingRecordPublisher(fakeKinesis);
    recordPublisher.run(new TestConsumer());
    // Get shard iterator is called twice, once during first run, secondly to refresh expired
    // iterator
    verify(fakeKinesis, times(2)).getShardIterator(any(), any(), any());
}
Also used : KinesisProxyInterface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyInterface) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Aggregations

TestConsumer (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer)23 Test (org.junit.Test)23 RecordPublisher (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher)12 SingleShardFanOutKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SingleShardFanOutKinesisV2)7 SubscriptionErrorKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2)7 KinesisProxyInterface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyInterface)6 FullJitterBackoff (org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)5 LimitExceededException (software.amazon.awssdk.services.kinesis.model.LimitExceededException)4 UserRecord (com.amazonaws.services.kinesis.clientlibrary.types.UserRecord)3 KinesisProxyV2Interface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface)3 Date (java.util.Date)2 Properties (java.util.Properties)2 RecordPublisherRunResult (org.apache.flink.streaming.connectors.kinesis.internals.publisher.RecordPublisher.RecordPublisherRunResult)2 SdkInterruptedException (com.amazonaws.http.timers.client.SdkInterruptedException)1 ReadTimeoutException (io.netty.handler.timeout.ReadTimeoutException)1 PollingRecordPublisherMetricsReporter (org.apache.flink.streaming.connectors.kinesis.metrics.PollingRecordPublisherMetricsReporter)1 FakeKinesisFanOutBehavioursFactory (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory)1 Record (software.amazon.awssdk.services.kinesis.model.Record)1 ResourceNotFoundException (software.amazon.awssdk.services.kinesis.model.ResourceNotFoundException)1