Search in sources :

Example 6 with CloudFormationClient

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

the class HbaseIntegTest method setUpTableData.

/**
 * Create and invoke a special Lambda function that sets up the HBase table used by the integration tests.
 */
@Override
protected void setUpTableData() {
    logger.info("----------------------------------------------------");
    logger.info("Setting up table for DB ({}): {}", hbaseDbName, hbaseTableName);
    logger.info("----------------------------------------------------");
    String hbaseLambdaName = "integ-hbase-" + UUID.randomUUID();
    AWSLambda lambdaClient = AWSLambdaClientBuilder.defaultClient();
    CloudFormationClient cloudFormationHbaseClient = new CloudFormationClient(getHbaseLambdaStack(hbaseLambdaName));
    try {
        // Create the Lambda function.
        cloudFormationHbaseClient.createStack();
        // Invoke the Lambda function.
        lambdaClient.invoke(new InvokeRequest().withFunctionName(hbaseLambdaName).withInvocationType(InvocationType.RequestResponse));
    } finally {
        // Delete the Lambda function.
        cloudFormationHbaseClient.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 7 with CloudFormationClient

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

the class HbaseIntegTest method setUp.

/**
 * Creates a HBase EMR Cluster used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(getHbaseStack());
    try {
        // Create the CloudFormation stack for the HBase DB cluster.
        cloudFormationClient.createStack();
        // Get the hostname of the EMR cluster hosting the HBase database, and set the environment variables
        // needed by the Lambda.
        setEnvironmentVars(getClusterData());
        // 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 8 with CloudFormationClient

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

the class PostGreSqlIntegTest method setUp.

/**
 * Creates a PostGreSql RDS Instance used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(theApp, getPostGreSqlStack());
    try {
        // Create the CloudFormation stack for the PostGreSql 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 9 with CloudFormationClient

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

the class RedshiftIntegTest method setUp.

/**
 * Creates a Redshift cluster used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(theApp, getRedshiftStack());
    try {
        // Create the CloudFormation stack for the Redshift cluster.
        cloudFormationClient.createStack();
        // Get DB cluster's host and port information and set the environment variables needed for the Lambda.
        setEnvironmentVars(getClusterData());
        // Create the DB schema in the newly created DB cluster 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 10 with CloudFormationClient

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

the class DocDbIntegTest method setUp.

/**
 * Creates a DocumentDB Cluster used for the integration tests.
 */
@BeforeClass
@Override
protected void setUp() {
    cloudFormationClient = new CloudFormationClient(theApp, getDocDbStack());
    try {
        // Create the CloudFormation stack for the DocumentDb cluster.
        cloudFormationClient.createStack();
        // Get DB cluster's endpoint information and set the connection string environment var for Lambda.
        setEnvironmentVars(getClusterData());
        // 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)

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