Search in sources :

Example 1 with CloudFormationClient

use of com.amazonaws.athena.connector.integ.clients.CloudFormationClient in project aws-athena-query-federation by awslabs.

the class MySqlIntegTest method setUp.

/**
 * Creates a MySql RDS Instance used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(theApp, getMySqlStack());
    try {
        // Create the CloudFormation stack for the MySql DB instance.
        cloudFormationClient.createStack();
        // Get DB instance's host and port information and set the environment variables needed for the Lambda.
        setEnvironmentVars(getInstanceData());
        // Create the DB schema in the newly created DB instance used for the integration tests.
        createDbSchema();
        // Invoke the framework's setUp().
        super.setUp();
    } catch (Exception e) {
        // Delete the partially formed CloudFormation stack.
        cloudFormationClient.deleteStack();
        throw e;
    }
}
Also used : CloudFormationClient(com.amazonaws.athena.connector.integ.clients.CloudFormationClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with CloudFormationClient

use of com.amazonaws.athena.connector.integ.clients.CloudFormationClient in project aws-athena-query-federation by awslabs.

the class RedisIntegTest method setUp.

/**
 * Creates a Redis cluster used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(theApp, getRedisStack());
    try {
        // Create the CloudFormation stack for the Redis instances.
        cloudFormationClient.createStack();
        // Get host and port information
        Endpoint standaloneEndpoint = getRedisInstanceData(redisStandaloneName, false);
        logger.info("Got Endpoint: " + standaloneEndpoint.toString());
        redisEndpoints.put(STANDALONE_KEY, String.format("%s:%s", standaloneEndpoint.getAddress(), standaloneEndpoint.getPort()));
        Endpoint clusterEndpoint = getRedisInstanceData(redisClusterName, true);
        logger.info("Got Endpoint: " + clusterEndpoint.toString());
        redisEndpoints.put(CLUSTER_KEY, String.format("%s:%s:%s", clusterEndpoint.getAddress(), clusterEndpoint.getPort(), redisPassword));
        // Get endpoint information and set the connection string environment var for Lambda.
        environmentVars.put("standalone_connection", redisEndpoints.get(STANDALONE_KEY));
        environmentVars.put("cluster_connection", redisEndpoints.get(CLUSTER_KEY));
        // Invoke the framework's setUp().
        super.setUp();
    } catch (Exception e) {
        // Delete the partially formed CloudFormation stack.
        cloudFormationClient.deleteStack();
        throw e;
    }
}
Also used : Endpoint(com.amazonaws.services.elasticache.model.Endpoint) EntityNotFoundException(com.amazonaws.services.glue.model.EntityNotFoundException) CloudFormationClient(com.amazonaws.athena.connector.integ.clients.CloudFormationClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with CloudFormationClient

use of com.amazonaws.athena.connector.integ.clients.CloudFormationClient in project aws-athena-query-federation by awslabs.

the class RedisIntegTest method setUpTableData.

/**
 * Create and invoke a special Lambda function that sets up the Redis instances used by the integration tests.
 */
@Override
protected void setUpTableData() {
    logger.info("----------------------------------------------------");
    logger.info("Setting up data for Redis Instances");
    logger.info("----------------------------------------------------");
    String redisLambdaName = "integ-redis-helper-" + UUID.randomUUID();
    AWSLambda lambdaClient = AWSLambdaClientBuilder.defaultClient();
    CloudFormationClient cloudFormationRedisClient = new CloudFormationClient(getRedisLambdaStack(redisLambdaName));
    try {
        // Create the Lambda function.
        cloudFormationRedisClient.createStack();
        // Invoke the Lambda function.
        lambdaClient.invoke(new InvokeRequest().withFunctionName(redisLambdaName).withInvocationType(InvocationType.RequestResponse));
    } finally {
        // Delete the Lambda function.
        cloudFormationRedisClient.deleteStack();
        lambdaClient.shutdown();
    }
}
Also used : AWSLambda(com.amazonaws.services.lambda.AWSLambda) InvokeRequest(com.amazonaws.services.lambda.model.InvokeRequest) CloudFormationClient(com.amazonaws.athena.connector.integ.clients.CloudFormationClient)

Example 4 with CloudFormationClient

use of com.amazonaws.athena.connector.integ.clients.CloudFormationClient in project aws-athena-query-federation by awslabs.

the class ElasticsearchIntegTest method setUp.

/**
 * Creates an Elasticsearch Cluster used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(theApp, getElasticsearchStack());
    try {
        // Create the CloudFormation stack for the Elasticsearch Cluster.
        cloudFormationClient.createStack();
        // Invoke the framework's setUp().
        super.setUp();
    } catch (Exception e) {
        // Delete the partially formed CloudFormation stack.
        cloudFormationClient.deleteStack();
        throw e;
    }
}
Also used : CloudFormationClient(com.amazonaws.athena.connector.integ.clients.CloudFormationClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with CloudFormationClient

use of com.amazonaws.athena.connector.integ.clients.CloudFormationClient in project aws-athena-query-federation by awslabs.

the class IntegrationTestBase method setUp.

/**
 * Creates a CloudFormation stack to build the infrastructure needed to run the integration tests (e.g., Database
 * instance, Lambda function, etc...). Once the stack is created successfully, the lambda function is registered
 * with Athena.
 */
@BeforeClass
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(connectorStackProvider.getStack());
    try {
        cloudFormationClient.createStack();
        setUpTableData();
    } catch (Exception e) {
        // Delete the partially formed CloudFormation stack.
        cloudFormationClient.deleteStack();
        throw e;
    }
}
Also used : CloudFormationClient(com.amazonaws.athena.connector.integ.clients.CloudFormationClient) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

CloudFormationClient (com.amazonaws.athena.connector.integ.clients.CloudFormationClient)11 BeforeClass (org.testng.annotations.BeforeClass)8 AWSLambda (com.amazonaws.services.lambda.AWSLambda)3 InvokeRequest (com.amazonaws.services.lambda.model.InvokeRequest)3 Endpoint (com.amazonaws.services.elasticache.model.Endpoint)1 EntityNotFoundException (com.amazonaws.services.glue.model.EntityNotFoundException)1