Search in sources :

Example 1 with StreamConsumerFakeKinesis

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis in project flink by apache.

the class StreamConsumerRegistrarTest method testRegisterStreamConsumerWaitsForConsumerToBecomeActive.

@Test
public void testRegisterStreamConsumerWaitsForConsumerToBecomeActive() throws Exception {
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.registerExistingConsumerAndWaitToBecomeActive();
    StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
    String result = registrar.registerStreamConsumer(STREAM, "name");
    // we backoff on each retry
    verify(backoff, times(NUMBER_OF_DESCRIBE_REQUESTS_TO_ACTIVATE - 1)).sleep(anyLong());
    assertEquals(STREAM_CONSUMER_ARN_EXISTING, result);
    // We will invoke describe stream until the stream consumer is activated
    assertEquals(NUMBER_OF_DESCRIBE_REQUESTS_TO_ACTIVATE, kinesis.getNumberOfDescribeStreamConsumerInvocations());
    for (int i = 1; i < NUMBER_OF_DESCRIBE_REQUESTS_TO_ACTIVATE; i++) {
        verify(backoff).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(i));
    }
}
Also used : StreamConsumerFakeKinesis(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Example 2 with StreamConsumerFakeKinesis

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis in project flink by apache.

the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerTimeoutWaitingForConsumerToDeregister.

@Test
public void testDeregisterStreamConsumerTimeoutWaitingForConsumerToDeregister() throws Exception {
    thrown.expect(FlinkKinesisTimeoutException.class);
    thrown.expectMessage("Timeout waiting for stream consumer to deregister: stream-consumer-arn");
    StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.existingActiveConsumer();
    Properties configProps = createEfoProperties();
    configProps.setProperty(DEREGISTER_STREAM_TIMEOUT_SECONDS, "1");
    FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(configProps, singletonList(STREAM));
    StreamConsumerRegistrar registrar = new StreamConsumerRegistrar(kinesis, configuration, backoffFor(1001));
    registrar.deregisterStreamConsumer(STREAM);
}
Also used : StreamConsumerFakeKinesis(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with StreamConsumerFakeKinesis

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis in project flink by apache.

the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerArnNotFound.

@Test
public void testDeregisterStreamConsumerArnNotFound() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Stream consumer ARN not found for stream: not-found");
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.streamConsumerNotFound();
    StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
    registrar.deregisterStreamConsumer("not-found");
}
Also used : StreamConsumerFakeKinesis(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Example 4 with StreamConsumerFakeKinesis

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis in project flink by apache.

the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerNotFound.

@Test
public void testDeregisterStreamConsumerNotFound() throws Exception {
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.streamConsumerNotFound();
    StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
    registrar.deregisterStreamConsumer(STREAM);
    assertEquals(1, kinesis.getNumberOfDescribeStreamConsumerInvocations());
}
Also used : StreamConsumerFakeKinesis(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Example 5 with StreamConsumerFakeKinesis

use of org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis in project flink by apache.

the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerAndWaitForDeletingStatus.

@Test
public void testDeregisterStreamConsumerAndWaitForDeletingStatus() throws Exception {
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.existingActiveConsumer();
    StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
    registrar.deregisterStreamConsumer(STREAM);
    // We will invoke describe stream until the stream consumer is in the DELETING state
    assertEquals(2, kinesis.getNumberOfDescribeStreamConsumerInvocations());
    for (int i = 1; i < 2; i++) {
        verify(backoff).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), eq(i));
    }
}
Also used : StreamConsumerFakeKinesis(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) Test(org.junit.Test)

Aggregations

StreamConsumerFakeKinesis (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.StreamConsumerFakeKinesis)6 Test (org.junit.Test)6 FullJitterBackoff (org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)4 Properties (java.util.Properties)2