Search in sources :

Example 6 with StartingPosition

use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.

the class FanOutShardSubscriberTest method testMultipleErrorsThrownPassesFirstErrorToConsumer.

@Test
public void testMultipleErrorsThrownPassesFirstErrorToConsumer() throws Exception {
    thrown.expect(FanOutShardSubscriber.FanOutSubscriberException.class);
    thrown.expectMessage("Error 1!");
    RuntimeException error1 = new RuntimeException("Error 1!");
    RuntimeException error2 = new RuntimeException("Error 2!");
    SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(error1, error2);
    FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", errorKinesisV2, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT);
    StartingPosition startingPosition = StartingPosition.builder().build();
    subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
    });
}
Also used : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) Test(org.junit.Test)

Example 7 with StartingPosition

use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.

the class FanOutShardSubscriberTest method testTimeoutSubscribingToShard.

@Test
public void testTimeoutSubscribingToShard() throws Exception {
    thrown.expect(FanOutShardSubscriber.RecoverableFanOutSubscriberException.class);
    thrown.expectMessage("Timed out acquiring subscription");
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.failsToAcquireSubscription();
    FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", kinesis, Duration.ofMillis(1));
    StartingPosition startingPosition = StartingPosition.builder().build();
    subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
    });
}
Also used : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) Test(org.junit.Test)

Example 8 with StartingPosition

use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.

the class FanOutShardSubscriberTest method testTimeoutEnqueuingEvent.

@Test
public void testTimeoutEnqueuingEvent() throws Exception {
    thrown.expect(FanOutShardSubscriber.RecoverableFanOutSubscriberException.class);
    thrown.expectMessage("Timed out enqueuing event SubscriptionNextEvent");
    KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.shardThatCreatesBackpressureOnQueue();
    FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", kinesis, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT, Duration.ofMillis(100));
    StartingPosition startingPosition = StartingPosition.builder().build();
    subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
        try {
            Thread.sleep(120);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });
}
Also used : StartingPosition(software.amazon.awssdk.services.kinesis.model.StartingPosition) KinesisProxyV2Interface(org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface) SdkInterruptedException(com.amazonaws.http.timers.client.SdkInterruptedException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 StartingPosition (software.amazon.awssdk.services.kinesis.model.StartingPosition)8 SubscriptionErrorKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2)4 SdkInterruptedException (com.amazonaws.http.timers.client.SdkInterruptedException)2 Instant (java.time.Instant)2 ShardConsumerTestUtils.fakeSequenceNumber (org.apache.flink.streaming.connectors.kinesis.internals.ShardConsumerTestUtils.fakeSequenceNumber)2 SequenceNumber (org.apache.flink.streaming.connectors.kinesis.model.SequenceNumber)2 KinesisProxyV2Interface (org.apache.flink.streaming.connectors.kinesis.proxy.KinesisProxyV2Interface)2 AbstractSingleShardFanOutKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.AbstractSingleShardFanOutKinesisV2)2 SingleShardFanOutKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SingleShardFanOutKinesisV2)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Properties (java.util.Properties)1 TestUtils.efoProperties (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.efoProperties)1