use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class FanOutRecordPublisherTest method testToSdkV2StartingPositionAtTimeStamp.
@Test
public void testToSdkV2StartingPositionAtTimeStamp() throws Exception {
SingleShardFanOutKinesisV2 kinesis = emptyShard();
Date now = new Date();
RecordPublisher publisher = createRecordPublisher(kinesis, StartingPosition.fromTimestamp(now));
publisher.run(new TestConsumer());
assertEquals(now.toInstant(), kinesis.getStartingPositionForSubscription(0).timestamp());
assertEquals(AT_TIMESTAMP, kinesis.getStartingPositionForSubscription(0).type());
}
use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class FanOutRecordPublisherTest method testToSdkV2StartingPositionLatest.
@Test
public void testToSdkV2StartingPositionLatest() throws Exception {
SingleShardFanOutKinesisV2 kinesis = emptyShard();
RecordPublisher publisher = createRecordPublisher(kinesis, latest());
publisher.run(new TestConsumer());
assertNull(kinesis.getStartingPositionForSubscription(0).sequenceNumber());
assertEquals(LATEST, kinesis.getStartingPositionForSubscription(0).type());
}
use of org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer in project flink by apache.
the class FanOutRecordPublisherTest method testBackOffAttemptResetsWithSuccessfulSubscription.
@Test
public void testBackOffAttemptResetsWithSuccessfulSubscription() throws Exception {
SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.alternatingSuccessErrorDuringSubscription();
FanOutRecordPublisherConfiguration configuration = createConfiguration();
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
recordPublisher.run(new TestConsumer());
recordPublisher.run(new TestConsumer());
recordPublisher.run(new TestConsumer());
// Expecting:
// - first attempt to fail, and backoff attempt #1
// - second attempt to succeed, and reset attempt index
// - third attempt to fail, and backoff attempt #1
verify(backoff, times(2)).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(1));
verify(backoff, never()).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(0));
verify(backoff, never()).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(2));
}
Aggregations