use of com.amazonaws.services.kinesis.model.GetShardIteratorResult in project kafka-connect-kinesis by jcustenborder.
the class KinesisSourceTaskTest method noSourceOffsets.
@Test
public void noSourceOffsets() throws InterruptedException {
when(this.kinesisClient.getShardIterator(any())).thenReturn(new GetShardIteratorResult().withShardIterator("dfasdfsadfasdf"));
this.task.start(settings);
GetRecordsResult recordsResult = new GetRecordsResult().withNextShardIterator("dsfargadsfasdfasda").withRecords(TestData.record()).withMillisBehindLatest(0L);
when(this.kinesisClient.getRecords(any())).thenReturn(recordsResult);
List<SourceRecord> records = this.task.poll();
assertNotNull(records, "records should not be null.");
assertFalse(records.isEmpty(), "records should not be empty.");
verify(this.kinesisClient, atLeastOnce()).getShardIterator(any());
verify(this.kinesisClient, atLeastOnce()).getRecords(any());
}
use of com.amazonaws.services.kinesis.model.GetShardIteratorResult in project kafka-connect-kinesis by jcustenborder.
the class KinesisSourceTaskTest method throughputExceeded.
@Test
public void throughputExceeded() throws InterruptedException {
final String SEQUENCE_NUMBER = "asdfasdfddsa";
Map<String, Object> sourceOffset = ImmutableMap.of(RecordConverter.FIELD_SEQUENCE_NUMBER, SEQUENCE_NUMBER);
when(this.offsetStorageReader.offset(anyMap())).thenReturn(sourceOffset);
when(this.kinesisClient.getShardIterator(any())).thenReturn(new GetShardIteratorResult().withShardIterator("dfasdfsadfasdf"));
this.task.start(settings);
when(this.kinesisClient.getRecords(any())).thenThrow(new ProvisionedThroughputExceededException(""));
List<SourceRecord> records = this.task.poll();
assertNotNull(records, "records should not be null");
assertTrue(records.isEmpty(), "records should be empty.");
verify(this.task.time, atLeastOnce()).sleep(this.config.kinesisThroughputExceededBackoffMs);
}
use of com.amazonaws.services.kinesis.model.GetShardIteratorResult in project kafka-connect-kinesis by jcustenborder.
the class KinesisSourceTaskTest method noRecords.
@Test
public void noRecords() throws InterruptedException {
final String SEQUENCE_NUMBER = "asdfasdfddsa";
Map<String, Object> sourceOffset = ImmutableMap.of(RecordConverter.FIELD_SEQUENCE_NUMBER, SEQUENCE_NUMBER);
when(this.offsetStorageReader.offset(anyMap())).thenReturn(sourceOffset);
when(this.kinesisClient.getShardIterator(any())).thenReturn(new GetShardIteratorResult().withShardIterator("dfasdfsadfasdf"));
this.task.start(settings);
GetRecordsResult recordsResult = new GetRecordsResult().withNextShardIterator("dsfargadsfasdfasda").withRecords(Arrays.asList()).withMillisBehindLatest(0L);
when(this.kinesisClient.getRecords(any())).thenReturn(recordsResult);
List<SourceRecord> records = this.task.poll();
assertNotNull(records, "records should not be null");
assertTrue(records.isEmpty(), "records should be empty.");
verify(this.task.time, atLeastOnce()).sleep(this.config.kinesisEmptyRecordsBackoffMs);
}
use of com.amazonaws.services.kinesis.model.GetShardIteratorResult in project beam by apache.
the class SimplifiedKinesisClientTest method shouldReturnIteratorStartingWithSequenceNumber.
@Test
public void shouldReturnIteratorStartingWithSequenceNumber() throws Exception {
when(kinesis.getShardIterator(new GetShardIteratorRequest().withStreamName(STREAM).withShardId(SHARD_1).withShardIteratorType(ShardIteratorType.AT_SEQUENCE_NUMBER).withStartingSequenceNumber(SEQUENCE_NUMBER))).thenReturn(new GetShardIteratorResult().withShardIterator(SHARD_ITERATOR));
String stream = underTest.getShardIterator(STREAM, SHARD_1, ShardIteratorType.AT_SEQUENCE_NUMBER, SEQUENCE_NUMBER, null);
assertThat(stream).isEqualTo(SHARD_ITERATOR);
}
use of com.amazonaws.services.kinesis.model.GetShardIteratorResult in project druid by druid-io.
the class KinesisRecordSupplierTest method setupMockKinesisForShardId.
private void setupMockKinesisForShardId(AmazonKinesis kinesis, String shardId, List<Record> expectedRecords, String expectedNextIterator) {
String shardIteratorType = ShardIteratorType.TRIM_HORIZON.toString();
String shardIterator = "shardIterator" + shardId;
GetShardIteratorResult shardIteratorResult = new GetShardIteratorResult().withShardIterator(shardIterator);
EasyMock.expect(kinesis.getShardIterator(STREAM, shardId, shardIteratorType)).andReturn(shardIteratorResult).once();
GetRecordsRequest request = new GetRecordsRequest().withShardIterator(shardIterator).withLimit(1);
GetRecordsResult result = new GetRecordsResult().withRecords(expectedRecords).withNextShardIterator(expectedNextIterator);
EasyMock.expect(kinesis.getRecords(request)).andReturn(result);
}
Aggregations