Search in sources :

Example 1 with LocalStackContainer

use of org.testcontainers.containers.localstack.LocalStackContainer in project hazelcast by hazelcast.

the class KinesisFailureTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    assumeTrue(DockerClientFactory.instance().isDockerAvailable());
    localStack = new LocalStackContainer(parse("localstack/localstack").withTag("0.12.3")).withNetwork(NETWORK).withServices(Service.KINESIS);
    localStack.start();
    toxiProxy = new ToxiproxyContainer(parse("shopify/toxiproxy").withTag("2.1.0")).withNetwork(NETWORK).withNetworkAliases("toxiproxy");
    toxiProxy.start();
    System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
    // with the jackson versions we use (2.11.x) Localstack doesn't without disabling CBOR
    // https://github.com/localstack/localstack/issues/3208
    PROXY = toxiProxy.getProxy(localStack, 4566);
    AWS_CONFIG = new AwsConfig().withEndpoint("http://" + PROXY.getContainerIpAddress() + ":" + PROXY.getProxyPort()).withRegion(localStack.getRegion()).withCredentials(localStack.getAccessKey(), localStack.getSecretKey());
    KINESIS = AWS_CONFIG.buildClient();
    HELPER = new KinesisTestHelper(KINESIS, STREAM, Logger.getLogger(KinesisIntegrationTest.class));
}
Also used : AwsConfig(com.hazelcast.jet.kinesis.impl.AwsConfig) ToxiproxyContainer(org.testcontainers.containers.ToxiproxyContainer) LocalStackContainer(org.testcontainers.containers.localstack.LocalStackContainer) BeforeClass(org.junit.BeforeClass)

Example 2 with LocalStackContainer

use of org.testcontainers.containers.localstack.LocalStackContainer in project hazelcast by hazelcast.

the class KinesisIntegrationTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    assumeTrue(DockerClientFactory.instance().isDockerAvailable());
    localStack = new LocalStackContainer(parse("localstack/localstack").withTag("0.12.3")).withServices(Service.KINESIS);
    localStack.start();
    // To run with real kinesis AWS credentials need be available
    // to be loaded by DefaultAWSCredentialsProviderChain.
    // Keep in mind the real Kinesis is paid service and once you
    // run it you should ensure that cleanup happened correctly.
    useRealKinesis = Boolean.parseBoolean(System.getProperty("run.with.real.kinesis", "false"));
    System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
    if (useRealKinesis) {
        AWS_CONFIG = new AwsConfig().withEndpoint("https://kinesis.us-east-1.amazonaws.com").withRegion("us-east-1");
    } else {
        AWS_CONFIG = new AwsConfig().withEndpoint("http://" + localStack.getHost() + ":" + localStack.getMappedPort(4566)).withRegion(localStack.getRegion()).withCredentials(localStack.getAccessKey(), localStack.getSecretKey());
    }
    KINESIS = AWS_CONFIG.buildClient();
    HELPER = new KinesisTestHelper(KINESIS, STREAM, Logger.getLogger(KinesisIntegrationTest.class));
}
Also used : AwsConfig(com.hazelcast.jet.kinesis.impl.AwsConfig) LocalStackContainer(org.testcontainers.containers.localstack.LocalStackContainer) BeforeClass(org.junit.BeforeClass)

Example 3 with LocalStackContainer

use of org.testcontainers.containers.localstack.LocalStackContainer in project beam by apache.

the class KinesisIOIT method setupLocalstack.

/**
 * Necessary setup for localstack environment.
 */
private static void setupLocalstack() {
    // For some unclear reason localstack requires a timestamp in seconds
    now = Instant.ofEpochMilli(Long.divideUnsigned(now.getMillis(), 1000L));
    LocalStackContainer kinesisContainer = new LocalStackContainer(DockerImageName.parse("localstack/localstack").withTag(LOCALSTACK_VERSION)).withServices(Service.KINESIS).withEnv("USE_SSL", "true").withStartupAttempts(3);
    kinesisContainer.start();
    teardownTasks.add(() -> kinesisContainer.stop());
    options.setAwsServiceEndpoint(kinesisContainer.getEndpointOverride(Service.KINESIS).toString());
    options.setAwsKinesisRegion(kinesisContainer.getRegion());
    options.setAwsAccessKey(kinesisContainer.getAccessKey());
    options.setAwsSecretKey(kinesisContainer.getSecretKey());
    options.setAwsVerifyCertificate(false);
    options.setCreateStream(true);
}
Also used : LocalStackContainer(org.testcontainers.containers.localstack.LocalStackContainer)

Aggregations

LocalStackContainer (org.testcontainers.containers.localstack.LocalStackContainer)3 AwsConfig (com.hazelcast.jet.kinesis.impl.AwsConfig)2 BeforeClass (org.junit.BeforeClass)2 ToxiproxyContainer (org.testcontainers.containers.ToxiproxyContainer)1