use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testSubscribeToShard.
@Test
public void testSubscribeToShard() {
KinesisAsyncClient kinesis = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(kinesis, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
SubscribeToShardRequest request = SubscribeToShardRequest.builder().build();
SubscribeToShardResponseHandler responseHandler = SubscribeToShardResponseHandler.builder().subscriber(event -> {
}).build();
proxy.subscribeToShard(request, responseHandler);
verify(kinesis).subscribeToShard(eq(request), eq(responseHandler));
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testDescribeStreamConsumerWithStreamConsumerArn.
@Test
public void testDescribeStreamConsumerWithStreamConsumerArn() throws Exception {
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
DescribeStreamConsumerResponse expected = DescribeStreamConsumerResponse.builder().build();
ArgumentCaptor<DescribeStreamConsumerRequest> requestCaptor = ArgumentCaptor.forClass(DescribeStreamConsumerRequest.class);
when(client.describeStreamConsumer(requestCaptor.capture())).thenReturn(CompletableFuture.completedFuture(expected));
DescribeStreamConsumerResponse actual = proxy.describeStreamConsumer("arn");
assertEquals(expected, actual);
DescribeStreamConsumerRequest request = requestCaptor.getValue();
assertEquals("arn", request.consumerARN());
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testDescribeStreamSummaryFailsAfterMaxRetries.
@Test
public void testDescribeStreamSummaryFailsAfterMaxRetries() throws Exception {
exception.expect(RuntimeException.class);
exception.expectMessage("Retries exceeded - all 10 retry attempts failed.");
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), backoff);
when(client.describeStreamSummary(any(DescribeStreamSummaryRequest.class))).thenThrow(new RuntimeException(LimitExceededException.builder().build()));
proxy.describeStreamSummary("arn");
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testDescribeStreamSummary.
@Test
public void testDescribeStreamSummary() throws Exception {
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
DescribeStreamSummaryResponse expected = DescribeStreamSummaryResponse.builder().build();
ArgumentCaptor<DescribeStreamSummaryRequest> requestCaptor = ArgumentCaptor.forClass(DescribeStreamSummaryRequest.class);
when(client.describeStreamSummary(requestCaptor.capture())).thenReturn(CompletableFuture.completedFuture(expected));
DescribeStreamSummaryResponse actual = proxy.describeStreamSummary("stream");
assertEquals(expected, actual);
DescribeStreamSummaryRequest request = requestCaptor.getValue();
assertEquals("stream", request.streamName());
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testDescribeStreamSummaryBackoffJitter.
@Test
public void testDescribeStreamSummaryBackoffJitter() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), backoff);
when(client.describeStreamSummary(any(DescribeStreamSummaryRequest.class))).thenThrow(new RuntimeException(LimitExceededException.builder().build())).thenReturn(CompletableFuture.completedFuture(DescribeStreamSummaryResponse.builder().build()));
proxy.describeStreamSummary("arn");
verify(backoff).sleep(anyLong());
verify(backoff).calculateFullJitterBackoff(EXPECTED_DESCRIBE_STREAM_BASE, EXPECTED_DESCRIBE_STREAM_MAX, EXPECTED_DESCRIBE_STREAM_POW, 1);
}
Aggregations