Mock AWS Kinesis maven plugin

Mock kinesis is a library intended to run with the maven-failsafe-plugin to act as a fake aws kinesis endpoint for your integration tests.

Лицензия

Лицензия

Категории

Категории

Maven Компиляция и сборка
Группа

Группа

com.mypurecloud
Идентификатор

Идентификатор

mock-kinesis-maven-plugin
Последняя версия

Последняя версия

1.2.0
Дата

Дата

Тип

Тип

maven-plugin
Описание

Описание

Mock AWS Kinesis maven plugin
Mock kinesis is a library intended to run with the maven-failsafe-plugin to act as a fake aws kinesis endpoint for your integration tests.
Ссылка на сайт

Ссылка на сайт

https://github.com/MyPureCloud/mock-kinesis-maven-plugin
Система контроля версий

Система контроля версий

http://github.com/MyPureCloud/mock-kinesis-maven-plugin/

Скачать mock-kinesis-maven-plugin

Как подключить последнюю версию

<plugin>
    <groupId>com.mypurecloud</groupId>
    <artifactId>mock-kinesis-maven-plugin</artifactId>
    <version>1.2.0</version>
</plugin>

Зависимости

compile (7)

Идентификатор библиотеки Тип Версия
org.eclipse.jetty : jetty-server jar 9.4.0.v20161208
org.eclipse.jetty : jetty-servlet jar 9.4.0.v20161208
com.fasterxml.jackson.core : jackson-databind jar 2.7.4
commons-io : commons-io jar 2.4
com.squareup.okhttp3 : okhttp jar 3.9.0
com.fasterxml.jackson.dataformat : jackson-dataformat-cbor jar 2.7.4
org.apache.maven : maven-plugin-api jar 3.3.3

provided (1)

Идентификатор библиотеки Тип Версия
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.8.2
org.mockito : mockito-core jar 2.8.47

Модули Проекта

Данный проект не имеет модулей.

Mock-kinesis

Mock kinesis is a library intended to run with the maven-failsafe-plugin to act as a fake kinesis endpoint for your integration tests.

Installation

Maven:

<dependency>
    <groupId>com.mypurecloud</groupId>
    <artifactId>mock-kinesis-maven-plugin</artifactId>
    <version>${mock.kinesis.version}</version>
</dependency>
 

and then under

<plugin>
    <groupId>com.genesys.purecloud</groupId>
    <artifactId>mock-kinesis-maven-plugin</artifactId>
    <version>${mock.kinesis.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>start</goal>
            </goals>
            <configuration>
                <port>${it.kinesis.port}</port>
                <streamname>kinesis-mock</streamname>
            </configuration>
        </execution>
    </executions>
</plugin>

This starts mock kinesis listening on port 8899 and then adds a new stream called 'kinesis-mock'.

Usage

In your application's code

System.setProperty("com.amazonaws.sdk.disableCbor", "true");
clientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:8899", "us-east-1"));

The MockKinesisClient class will wrap http calls to the server that you can use to change error rates, clear streams or get messages that were sent to the stream. An example test case would look like this:

@Test
public void testSmallBatchOfRequests() throws JSONException, IOException, ExecutionException, InterruptedException {
    MockKinesisClient client = new MockKinesisClient(8899);
    client.clearStreams();  //clear all records
    client.setRateLimitErrorRate(streamName, 0); //set error rate to 0

    functionThatTriggersMessagesSentToKinesis();

    Thread.sleep(waitForEventsToFlushInMs);// wait for all records to be sent
    List<PutRecordRequest> records = client.getRecordsForStream(streamName); // get records from stream

    assertEquals(1, records.size());

}

Error Responses

There are two configuration options for mock kinesis to return error codes: MockKinesisClient.setRateLimitErrorRate and MockKinesisClient.setErrorRate

setRateLimitErrorRate will return rate limiting error codes "KMSThrottlingException", "ProvisionedThroughputExceededException" where setErrorRate will return a random error code from "InvalidArgumentException","KMSAccessDeniedException","KMSDisabledException","KMSInvalidStateException","KMSNotFoundException","KMSOptInRequired"

A Note on CBOR Content Type

Kinesis uses the (CBOR)[http://cbor.io/] content type by default. Mock kinesis doesn't yet support decoding that content type so when setting up your client, you first have to set the system property to turn it off.

System.setProperty("com.amazonaws.sdk.disableCbor", "true");

Messages with CBOR enter the server with Content-type set to application/x-amz-cbor-1.1 normal json messages will have the content type application/x-amz-json-1.1

Kinesis Producer Library

If using this with KPL, you will need to set the following properties

kplConfig.setKinesisEndpoint("localhost");
kplConfig.setKinesisPort(8899);
kplConfig.setVerifyCertificate(false);

System.setProperty("com.amazonaws.sdk.disableCbor", "true");
System.setProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "");

kplConfig.setVerifyCertificate(false);
com.mypurecloud

Genesys Cloud

Версии библиотеки

Версия
1.2.0
1.1.1
1.1.0
1.0.2
1.0.1