Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switches the AWS v2 test infra-structure #635

Merged
merged 1 commit into from Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions tests/itests-aws-v2/pom.xml
Expand Up @@ -38,9 +38,17 @@
</dependency>

<dependency>
<groupId>org.apache.camel.kafkaconnector</groupId>
<artifactId>itests-aws-common</artifactId>
<version>${project.version}</version>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-infra-aws-common</artifactId>
<version>${camel.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-infra-aws-v2</artifactId>
<version>${camel.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
Expand Up @@ -17,126 +17,18 @@

package org.apache.camel.kafkaconnector.aws.v2.clients;

import java.net.URI;
import java.net.URISyntaxException;

import org.apache.camel.kafkaconnector.aws.common.AWSConfigs;
import org.apache.camel.kafkaconnector.aws.v2.common.TestAWSCredentialsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.kinesis.KinesisClient;
import software.amazon.awssdk.services.kinesis.KinesisClientBuilder;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;
import software.amazon.awssdk.services.s3.model.DeleteBucketRequest;
import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
import software.amazon.awssdk.services.s3.model.S3Object;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.SqsClientBuilder;

public final class AWSSDKClientUtils {
private static final Logger LOG = LoggerFactory.getLogger(AWSSDKClientUtils.class);

private AWSSDKClientUtils() {

}

private static URI getEndpoint() {
String amazonHost = System.getProperty(AWSConfigs.AMAZON_AWS_HOST);

if (amazonHost == null || amazonHost.isEmpty()) {
return null;
}

try {
return new URI(String.format("http://%s", amazonHost));
} catch (URISyntaxException e) {
throw new RuntimeException("Invalid endpoint");
}
}

private static boolean isLocalContainer(String awsInstanceType) {
return awsInstanceType == null || awsInstanceType.equals("local-aws-container");
}

public static KinesisClient newKinesisClient() {
LOG.debug("Creating a new AWS v2 Kinesis client");

String awsInstanceType = System.getProperty("aws-service.kinesis.instance.type");

KinesisClientBuilder clientBuilder = KinesisClient.builder();

clientBuilder.region(Region.US_EAST_1);

URI endpoint = getEndpoint();

if (isLocalContainer(awsInstanceType) || endpoint != null) {
clientBuilder.endpointOverride(endpoint);
}

if (isLocalContainer(awsInstanceType)) {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.CONTAINER_LOCAL_DEFAULT_PROVIDER);

} else {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.SYSTEM_PROPERTY_PROVIDER);
}

return clientBuilder.build();
}

public static SqsClient newSQSClient() {
LOG.debug("Creating a new AWS v2 SQS client");

String awsInstanceType = System.getProperty("aws-service.instance.type");

SqsClientBuilder clientBuilder = SqsClient.builder();

clientBuilder.region(Region.US_EAST_1);

URI endpoint = getEndpoint();

if (isLocalContainer(awsInstanceType) || endpoint != null) {
clientBuilder.endpointOverride(endpoint);
}

if (isLocalContainer(awsInstanceType)) {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.CONTAINER_LOCAL_DEFAULT_PROVIDER);

} else {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.SYSTEM_PROPERTY_PROVIDER);
}

return clientBuilder.build();
}

public static S3Client newS3Client() {
LOG.debug("Creating a new S3 client");
S3ClientBuilder clientBuilder = S3Client.builder();

String awsInstanceType = System.getProperty("aws-service.instance.type");

clientBuilder.region(Region.US_EAST_1);

URI endpoint = getEndpoint();

if (isLocalContainer(awsInstanceType) || endpoint != null) {
clientBuilder.endpointOverride(endpoint);
}

if (isLocalContainer(awsInstanceType)) {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.CONTAINER_LOCAL_DEFAULT_PROVIDER);

} else {
clientBuilder.credentialsProvider(TestAWSCredentialsProvider.SYSTEM_PROPERTY_PROVIDER);
}

return clientBuilder.build();
}


/**
* Delete an S3 bucket using the provided client. Coming from AWS documentation:
* https://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html
Expand Down

This file was deleted.

Expand Up @@ -21,9 +21,9 @@
import java.util.Map;
import java.util.Properties;

import org.apache.camel.kafkaconnector.aws.common.AWSConfigs;
import org.apache.camel.kafkaconnector.common.EndpointUrlBuilder;
import org.apache.camel.kafkaconnector.common.SourceConnectorPropertyFactory;
import org.apache.camel.test.infra.aws.common.AWSConfigs;
import software.amazon.awssdk.regions.Region;


Expand Down
Expand Up @@ -22,13 +22,13 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import org.apache.camel.kafkaconnector.aws.common.AWSCommon;
import org.apache.camel.kafkaconnector.aws.common.services.AWSService;
import org.apache.camel.kafkaconnector.aws.v2.services.AWSServiceFactory;
import org.apache.camel.kafkaconnector.common.AbstractKafkaTest;
import org.apache.camel.kafkaconnector.common.ConnectorPropertyFactory;
import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
import org.apache.camel.kafkaconnector.common.utils.TestUtils;
import org.apache.camel.test.infra.aws.common.AWSCommon;
import org.apache.camel.test.infra.aws.common.services.AWSService;
import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Expand Up @@ -18,7 +18,7 @@
package org.apache.camel.kafkaconnector.aws.v2.kinesis.source;

import org.apache.camel.component.aws2.kinesis.Kinesis2Configuration;
import org.apache.camel.kafkaconnector.aws.v2.clients.AWSSDKClientUtils;
import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
import software.amazon.awssdk.services.kinesis.KinesisClient;

public class TestKinesisConfiguration extends Kinesis2Configuration {
Expand Down
Expand Up @@ -21,9 +21,9 @@
import java.util.Map;
import java.util.Properties;

import org.apache.camel.kafkaconnector.aws.common.AWSConfigs;
import org.apache.camel.kafkaconnector.common.EndpointUrlBuilder;
import org.apache.camel.kafkaconnector.common.SourceConnectorPropertyFactory;
import org.apache.camel.test.infra.aws.common.AWSConfigs;
import software.amazon.awssdk.regions.Region;


Expand Down
Expand Up @@ -21,15 +21,15 @@
import java.util.Properties;
import java.util.concurrent.ExecutionException;

import org.apache.camel.kafkaconnector.aws.common.AWSCommon;
import org.apache.camel.kafkaconnector.aws.common.AWSConfigs;
import org.apache.camel.kafkaconnector.aws.common.services.AWSService;
import org.apache.camel.kafkaconnector.aws.v2.clients.AWSSDKClientUtils;
import org.apache.camel.kafkaconnector.aws.v2.services.AWSServiceFactory;
import org.apache.camel.kafkaconnector.common.AbstractKafkaTest;
import org.apache.camel.kafkaconnector.common.ConnectorPropertyFactory;
import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
import org.apache.camel.kafkaconnector.common.utils.TestUtils;
import org.apache.camel.test.infra.aws.common.AWSCommon;
import org.apache.camel.test.infra.aws.common.AWSConfigs;
import org.apache.camel.test.infra.aws.common.services.AWSService;
import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Expand Up @@ -18,7 +18,7 @@
package org.apache.camel.kafkaconnector.aws.v2.s3.source;

import org.apache.camel.component.aws2.s3.AWS2S3Configuration;
import org.apache.camel.kafkaconnector.aws.v2.clients.AWSSDKClientUtils;
import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
import software.amazon.awssdk.services.s3.S3Client;

public class TestS3Configuration extends AWS2S3Configuration {
Expand Down

This file was deleted.