Search in sources :

Example 1 with AwsConfig

use of com.hazelcast.jet.kinesis.impl.AwsConfig 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 2 with AwsConfig

use of com.hazelcast.jet.kinesis.impl.AwsConfig 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 3 with AwsConfig

use of com.hazelcast.jet.kinesis.impl.AwsConfig in project hazelcast by hazelcast.

the class KinesisFailureTest method sourceWithIncorrectCredentials.

@Test
@Category(SerialTest.class)
// AWS mock completely ignores the credentials passed to it, accepts anything (test passes on real backend)
@Ignore
public void sourceWithIncorrectCredentials() {
    HELPER.createStream(1);
    AwsConfig awsConfig = new AwsConfig().withCredentials("wrong_key", "wrong_key");
    Pipeline p = Pipeline.create();
    p.readFrom(KinesisSources.kinesis(STREAM).withEndpoint(awsConfig.getEndpoint()).withRegion(awsConfig.getRegion()).withCredentials(awsConfig.getAccessKey(), awsConfig.getSecretKey()).withRetryStrategy(KinesisTestHelper.RETRY_STRATEGY).build()).withoutTimestamps().writeTo(Sinks.noop());
    Job job = hz().getJet().newJob(p);
    assertThrowsJetException(job, "The security token included in the request is invalid");
}
Also used : AwsConfig(com.hazelcast.jet.kinesis.impl.AwsConfig) Job(com.hazelcast.jet.Job) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Ignore(org.junit.Ignore) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) SerialTest(com.hazelcast.jet.test.SerialTest)

Example 4 with AwsConfig

use of com.hazelcast.jet.kinesis.impl.AwsConfig in project hazelcast by hazelcast.

the class KinesisFailureTest method sinkWithIncorrectCredentials.

@Test
@Category(SerialTest.class)
// AWS mock completely ignores the credentials passed to it, accepts anything (test passes on real backend)
@Ignore
public void sinkWithIncorrectCredentials() {
    HELPER.createStream(1);
    AwsConfig awsConfig = new AwsConfig().withCredentials("wrong_key", "wrong_key");
    Pipeline p = Pipeline.create();
    p.readFrom(TestSources.items(entry("k", new byte[0]))).writeTo(KinesisSinks.kinesis(STREAM).withEndpoint(awsConfig.getEndpoint()).withRegion(awsConfig.getRegion()).withCredentials(awsConfig.getAccessKey(), awsConfig.getSecretKey()).withRetryStrategy(KinesisTestHelper.RETRY_STRATEGY).build());
    Job job = hz().getJet().newJob(p);
    assertThrowsJetException(job, "The security token included in the request is invalid");
}
Also used : AwsConfig(com.hazelcast.jet.kinesis.impl.AwsConfig) Job(com.hazelcast.jet.Job) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Ignore(org.junit.Ignore) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) SerialTest(com.hazelcast.jet.test.SerialTest)

Aggregations

AwsConfig (com.hazelcast.jet.kinesis.impl.AwsConfig)4 Job (com.hazelcast.jet.Job)2 Pipeline (com.hazelcast.jet.pipeline.Pipeline)2 SerialTest (com.hazelcast.jet.test.SerialTest)2 BeforeClass (org.junit.BeforeClass)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Category (org.junit.experimental.categories.Category)2 LocalStackContainer (org.testcontainers.containers.localstack.LocalStackContainer)2 ToxiproxyContainer (org.testcontainers.containers.ToxiproxyContainer)1