Disable CBOR for AWS; enable Kinesis tests

* Since Local Stack Kinesis support is based on Kinesalite, it turns out
that `System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");`
does the trick to make Kinesis integration tests to pass with Local Stack
in Docker
* Suppress `serial` warning in the `AwsIntegrationEvent` classes
* Make `junit-jupiter-api` as `testCompile` dependency
* Fix README in regards Local Stack support for testing
This commit is contained in:
Artem Bilan
2019-10-22 15:04:19 -04:00
parent ab70876923
commit 507f652122
8 changed files with 18 additions and 12 deletions

View File

@@ -522,8 +522,7 @@ this.amazonDynamoDB = AmazonDynamoDBAsyncClientBuilder.standard()
````
Where you should specify the port on which you have ran the Dynalite service.
Also you can use for your testing purpose a copy of `org.springframework.integration.aws.DynamoDbLocalRunning` in the `/test` directory of this project.
The default port is expected as `4568`, because the `4567` is reserved for the `KinesisLocalRunning` against local Kinesalite npm service.
Also you can use for you testing purpose a [Local Stack][] library.
Starting with _version 2.0_, the `DynamoDbMetadataStore` can be configured with the `timeToLive` option to enable the [DynamoDB TTL][] feature.
The `TTL` attribute is added to each item with the value based on the sum of current time and provided `timeToLive` in seconds.
@@ -647,7 +646,7 @@ this.amazonKinesis = AmazonKinesisAsyncClientBuilder.standard()
````
Where you should specify the port on which you have ran the Kinesalite service.
Also you can use for you testing purpose a copy of `org.springframework.integration.aws.KinesisLocalRunning` in the `/test` directory of this project.
Also you can use for you testing purpose a [Local Stack][] library.
Also the `KplMessageHandler` is provided for performing streams consumption by [Kinesis Producer Library][].
@@ -679,3 +678,4 @@ The `com.amazonaws:dynamodb-lock-client` dependency must be present to make a `D
[Leader Election]: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints-chapter.html#leadership-event-handling
[Kinesis Producer Library]: https://docs.aws.amazon.com/streams/latest/dev/developing-producers-with-kpl.html
[LockRegistryLeaderInitiator]: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints-chapter.html#leadership-event-handling
[Local Stack]: https://localstack.cloud

View File

@@ -119,7 +119,7 @@ dependencies {
testCompile ("org.awaitility:awaitility:$awaitilityVersion") {
exclude group: 'org.hamcrest'
}
compile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
testRuntime "org.apache.logging.log4j:log4j-jcl:$log4jVersion"

View File

@@ -25,6 +25,7 @@ import org.springframework.integration.events.IntegrationEvent;
*
* @since 2.3
*/
@SuppressWarnings("serial")
public abstract class AwsIntegrationEvent extends IntegrationEvent {
public AwsIntegrationEvent(Object source) {

View File

@@ -23,6 +23,7 @@ package org.springframework.integration.aws.event;
*
* @since 2.3
*/
@SuppressWarnings("serial")
public abstract class KinesisIntegrationEvent extends AwsIntegrationEvent {
public KinesisIntegrationEvent(Object source) {

View File

@@ -23,6 +23,7 @@ package org.springframework.integration.aws.event;
*
* @since 2.3
*/
@SuppressWarnings("serial")
public class KinesisShardEndedEvent extends KinesisIntegrationEvent {
private final String shardKey;

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.aws;
import cloud.localstack.docker.annotation.IHostNameResolver;
import com.amazonaws.SDKGlobalConfiguration;
/**
* @author Artem Bilan
@@ -27,6 +28,10 @@ public class EnvironmentHostNameResolver implements IHostNameResolver {
public static final String DOCKER_HOST_NAME = "DOCKER_HOST_NAME";
static {
System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
}
@Override
public String getHostName() {
return System.getenv(DOCKER_HOST_NAME);

View File

@@ -25,7 +25,6 @@ import java.util.Set;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -68,7 +67,7 @@ import com.amazonaws.services.kinesis.AmazonKinesisAsync;
*
* @since 1.1
*/
@Disabled("Looks like Kinesis is not supported well in Local Stack")
//@Disabled("Looks like Kinesis is not supported well in Local Stack")
@SpringJUnitConfig
@EnabledIfEnvironmentVariable(named = EnvironmentHostNameResolver.DOCKER_HOST_NAME, matches = ".+")
@ExtendWith(LocalstackDockerExtension.class)
@@ -124,21 +123,21 @@ public class KinesisIntegrationTests {
.contains("Channel 'kinesisReceiveChannel' expected one of the following data types "
+ "[class java.util.Date], but received [class java.lang.String]");
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < 10; i++) {
this.kinesisSendChannel
.send(MessageBuilder.withPayload(new Date()).setHeader(AwsHeaders.STREAM, TEST_STREAM).build());
}
Set<String> receivedSequences = new HashSet<>();
for (int i = 0; i < 1000; i++) {
receive = this.kinesisReceiveChannel.receive(10_000);
for (int i = 0; i < 10; i++) {
receive = this.kinesisReceiveChannel.receive(20_000);
assertThat(receive).isNotNull();
String sequenceNumber = receive.getHeaders().get(AwsHeaders.RECEIVED_SEQUENCE_NUMBER, String.class);
assertThat(receivedSequences.add(sequenceNumber)).isTrue();
}
assertThat(receivedSequences.size()).isEqualTo(1000);
assertThat(receivedSequences.size()).isEqualTo(10);
receive = this.kinesisReceiveChannel.receive(10);
assertThat(receive).isNull();

View File

@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -87,7 +86,7 @@ class DynamoDbLockRegistryLeaderInitiatorTests {
DYNAMO_DB.deleteTable(DynamoDbLockRegistry.DEFAULT_TABLE_NAME);
}
@Disabled("Doesn't work properly against Local Stack when two instances try to lock in table")
// @Disabled("Doesn't work properly against Local Stack when two instances try to lock in table")
@Test
void testDistributedLeaderElection() throws Exception {
CountDownLatch granted = new CountDownLatch(1);