Class IntegrationTestBase
- java.lang.Object
-
- com.amazonaws.athena.connector.integ.IntegrationTestBase
-
public abstract class IntegrationTestBase extends Object
The Integration-Tests base class from which all connector-specific integration test modules should subclass.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
INTEG_TEST_DATABASE_NAME
protected static boolean
TEST_DATATYPES_BOOLEAN_VALUE
protected static byte[]
TEST_DATATYPES_BYTE_ARRAY_VALUE
protected static String
TEST_DATATYPES_DATE_VALUE
protected static double
TEST_DATATYPES_DOUBLE_PRECISION_VALUE
protected static int
TEST_DATATYPES_INT_VALUE
protected static long
TEST_DATATYPES_LONG_VALUE
protected static short
TEST_DATATYPES_SHORT_VALUE
protected static float
TEST_DATATYPES_SINGLE_PRECISION_VALUE
protected static String
TEST_DATATYPES_TABLE_NAME
protected static String
TEST_DATATYPES_TIMESTAMP_VALUE
protected static String
TEST_DATATYPES_VARCHAR_ARRAY_VALUE
protected static String
TEST_DATATYPES_VARCHAR_VALUE
protected static String
TEST_EMPTY_TABLE_NAME
protected static String
TEST_NULL_TABLE_NAME
-
Constructor Summary
Constructors Constructor Description IntegrationTestBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description float
calculateThroughput(String lambdaFnName, String schemaName, String tableName)
protected void
cleanUp()
Deletes a CloudFormation stack, and the lambda function registered with Athena.Map<String,String>
describeTable(String databaseName, String tableName)
Uses the startQueryExecution Athena API to process a "describe table" query utilizing the lambda function.List<String>
fetchDataDistinct(String lambdaFnName, String schemaName, String tablename, String distinctColumn, String whereClauseColumn, String whereClauseValue)
List<String>
fetchDataGroupBy(String schemaName, String tablename, String lambdaFnName, String groupByColumn)
List<String>
fetchDataGroupByHavingClause(String schemaName, String tablename, String lambdaFnName, String groupByColumn, String groupByColumnValue)
List<String>
fetchDataJoin(String lambdaFnName1, String schemaName1, String tablename1, String lambdaFnName2, String schemaName2, String tablename2, String whereClauseColumn1, String whereClauseColumn2)
List<String>
fetchDataSelect(String schemaName, String tablename, String lambdaFnName)
List<String>
fetchDataSelectCountAll(String schemaName, String tablename, String lambdaFnName)
List<String>
fetchDataUnion(String schemaName, String tablename1, String tablename2, String lambdaFnName1, String lambdaFnName2, String whereClauseColumn, String whereClauseValue)
List<String>
fetchDataWhereClause(String schemaName, String tablename, String lambdaFnName, String whereClauseColumn, String whereClauseValue)
List<String>
fetchDataWhereClauseLIKE(String schemaName, String tablename, String lambdaFnName, String whereClauseColumn, String whereClauseValue)
protected abstract Optional<software.amazon.awscdk.services.iam.PolicyDocument>
getConnectorAccessPolicy()
Must be overridden in the extending class to get the lambda function's IAM access policy.String
getLambdaFunctionName()
Public accessor for the framework generate lambda function name used in generating the lambda function.Optional<SecretsManagerCredentials>
getSecretCredentials()
Public accessor for the SecretsManager credentials obtained using the secrets_manager_secret attribute entered in the config file.Optional<Map<String,Object>>
getUserSettings()
Public accessor for the user_settings attribute (stored in the test-config.json file) that are customizable to any user-specific purpose.Optional<ConnectorVpcAttributes>
getVpcAttributes()
Public accessor for the VPC attributes used in generating the lambda function.List<String>
listDatabases()
Uses the listDatabases Athena API to list databases for the data source utilizing the lambda function.List<String>
listTables(String databaseName)
Uses the startQueryExecution Athena API to process a "show tables" query utilizing the lambda function.List<String>
processQuery(String query)
void
selectBigintTypeTest()
void
selectBooleanTypeTest()
void
selectByteArrayTypeTest()
void
selectDateTypeTest()
void
selectEmptyTableTest()
void
selectFloat4TypeTest()
void
selectFloat8TypeTest()
void
selectIntegerTypeTest()
void
selectNullValueTest()
void
selectSmallintTypeTest()
void
selectTimestampTypeTest()
void
selectVarcharListTypeTest()
void
selectVarcharTypeTest()
protected abstract void
setConnectorEnvironmentVars(Map<String,String> environmentVars)
Must be overridden in the extending class (can be a no-op) to set the lambda function's environment variables key-value pairs (e.g.protected void
setUp()
Creates a CloudFormation stack to build the infrastructure needed to run the integration tests (e.g., Database instance, Lambda function, etc...).protected abstract void
setUpStackData(software.amazon.awscdk.core.Stack stack)
Must be overridden in the extending class (can be a no-op) to create a connector-specific CloudFormation stack resource (e.g.protected abstract void
setUpTableData()
Must be overridden in the extending class to setup the DB table (i.e. insert rows into table, etc...)List<software.amazon.awssdk.services.athena.model.Row>
skipColumnHeaderRow(List<software.amazon.awssdk.services.athena.model.Row> rows)
software.amazon.awssdk.services.athena.model.GetQueryResultsResponse
startQueryExecution(String query)
Sends a DB query via Athena and returns the query results.
-
-
-
Field Detail
-
INTEG_TEST_DATABASE_NAME
protected static final String INTEG_TEST_DATABASE_NAME
- See Also:
- Constant Field Values
-
TEST_NULL_TABLE_NAME
protected static final String TEST_NULL_TABLE_NAME
- See Also:
- Constant Field Values
-
TEST_EMPTY_TABLE_NAME
protected static final String TEST_EMPTY_TABLE_NAME
- See Also:
- Constant Field Values
-
TEST_DATATYPES_TABLE_NAME
protected static final String TEST_DATATYPES_TABLE_NAME
- See Also:
- Constant Field Values
-
TEST_DATATYPES_INT_VALUE
protected static final int TEST_DATATYPES_INT_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_SHORT_VALUE
protected static final short TEST_DATATYPES_SHORT_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_LONG_VALUE
protected static final long TEST_DATATYPES_LONG_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_VARCHAR_VALUE
protected static final String TEST_DATATYPES_VARCHAR_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_BOOLEAN_VALUE
protected static final boolean TEST_DATATYPES_BOOLEAN_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_SINGLE_PRECISION_VALUE
protected static final float TEST_DATATYPES_SINGLE_PRECISION_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_DOUBLE_PRECISION_VALUE
protected static final double TEST_DATATYPES_DOUBLE_PRECISION_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_DATE_VALUE
protected static final String TEST_DATATYPES_DATE_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_TIMESTAMP_VALUE
protected static final String TEST_DATATYPES_TIMESTAMP_VALUE
- See Also:
- Constant Field Values
-
TEST_DATATYPES_BYTE_ARRAY_VALUE
protected static final byte[] TEST_DATATYPES_BYTE_ARRAY_VALUE
-
TEST_DATATYPES_VARCHAR_ARRAY_VALUE
protected static final String TEST_DATATYPES_VARCHAR_ARRAY_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLambdaFunctionName
public String getLambdaFunctionName()
Public accessor for the framework generate lambda function name used in generating the lambda function.- Returns:
- The name of the lambda function.
-
getVpcAttributes
public Optional<ConnectorVpcAttributes> getVpcAttributes()
Public accessor for the VPC attributes used in generating the lambda function.- Returns:
- Optional VPC attributes object.
-
getUserSettings
public Optional<Map<String,Object>> getUserSettings()
Public accessor for the user_settings attribute (stored in the test-config.json file) that are customizable to any user-specific purpose.- Returns:
- Optional Map(String, Object) containing all the user attributes as defined in the test configuration file, or an empty Optional if the user_settings attribute does not exist in the file.
-
getSecretCredentials
public Optional<SecretsManagerCredentials> getSecretCredentials()
Public accessor for the SecretsManager credentials obtained using the secrets_manager_secret attribute entered in the config file.- Returns:
- Optional SecretsManager credentials object.
-
setUpTableData
protected abstract void setUpTableData() throws Exception
Must be overridden in the extending class to setup the DB table (i.e. insert rows into table, etc...)- Throws:
Exception
-
setUpStackData
protected abstract void setUpStackData(software.amazon.awscdk.core.Stack stack)
Must be overridden in the extending class (can be a no-op) to create a connector-specific CloudFormation stack resource (e.g. DB table) using AWS CDK.- Parameters:
stack
- The current CloudFormation stack.
-
setConnectorEnvironmentVars
protected abstract void setConnectorEnvironmentVars(Map<String,String> environmentVars)
Must be overridden in the extending class (can be a no-op) to set the lambda function's environment variables key-value pairs (e.g. "connection_string":"redshift://jdbc:redshift://..."). See individual connector for the expected environment variables. This method is intended to supplement the test-config.json file environment_vars attribute (see below) for cases where the environment variable cannot be hardcoded.
-
getConnectorAccessPolicy
protected abstract Optional<software.amazon.awscdk.services.iam.PolicyDocument> getConnectorAccessPolicy()
Must be overridden in the extending class to get the lambda function's IAM access policy. The latter sets up access to multiple connector-specific AWS services (e.g. DynamoDB, Elasticsearch etc...)- Returns:
- A policy document object.
-
setUp
@BeforeClass protected void setUp() throws Exception
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.- Throws:
Exception
-
cleanUp
@AfterClass protected void cleanUp()
Deletes a CloudFormation stack, and the lambda function registered with Athena.
-
listDatabases
public List<String> listDatabases()
Uses the listDatabases Athena API to list databases for the data source utilizing the lambda function.- Returns:
- a list of database names.
-
listTables
public List<String> listTables(String databaseName) throws RuntimeException
Uses the startQueryExecution Athena API to process a "show tables" query utilizing the lambda function.- Parameters:
databaseName
- The name of the database.- Returns:
- A list of database table names.
- Throws:
RuntimeException
- The Query is cancelled or has failed.
-
describeTable
public Map<String,String> describeTable(String databaseName, String tableName) throws RuntimeException
Uses the startQueryExecution Athena API to process a "describe table" query utilizing the lambda function.- Parameters:
databaseName
- The name of the database.tableName
- The name of the database table.- Returns:
- A Map of the table column names and their associated types.
- Throws:
RuntimeException
- The Query is cancelled or has failed.
-
startQueryExecution
public software.amazon.awssdk.services.athena.model.GetQueryResultsResponse startQueryExecution(String query) throws RuntimeException
Sends a DB query via Athena and returns the query results.- Parameters:
query
- - The query string to be processed by Athena.- Returns:
- The query results object containing the metadata and row information.
- Throws:
RuntimeException
- The Query is cancelled or has failed.
-
fetchDataSelect
public List<String> fetchDataSelect(String schemaName, String tablename, String lambdaFnName) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataSelectCountAll
public List<String> fetchDataSelectCountAll(String schemaName, String tablename, String lambdaFnName) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataWhereClause
public List<String> fetchDataWhereClause(String schemaName, String tablename, String lambdaFnName, String whereClauseColumn, String whereClauseValue) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataWhereClauseLIKE
public List<String> fetchDataWhereClauseLIKE(String schemaName, String tablename, String lambdaFnName, String whereClauseColumn, String whereClauseValue) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataGroupBy
public List<String> fetchDataGroupBy(String schemaName, String tablename, String lambdaFnName, String groupByColumn) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataGroupByHavingClause
public List<String> fetchDataGroupByHavingClause(String schemaName, String tablename, String lambdaFnName, String groupByColumn, String groupByColumnValue) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataUnion
public List<String> fetchDataUnion(String schemaName, String tablename1, String tablename2, String lambdaFnName1, String lambdaFnName2, String whereClauseColumn, String whereClauseValue) throws RuntimeException
- Throws:
RuntimeException
-
fetchDataDistinct
public List<String> fetchDataDistinct(String lambdaFnName, String schemaName, String tablename, String distinctColumn, String whereClauseColumn, String whereClauseValue)
-
fetchDataJoin
public List<String> fetchDataJoin(String lambdaFnName1, String schemaName1, String tablename1, String lambdaFnName2, String schemaName2, String tablename2, String whereClauseColumn1, String whereClauseColumn2) throws RuntimeException
- Throws:
RuntimeException
-
calculateThroughput
public float calculateThroughput(String lambdaFnName, String schemaName, String tableName)
-
skipColumnHeaderRow
public List<software.amazon.awssdk.services.athena.model.Row> skipColumnHeaderRow(List<software.amazon.awssdk.services.athena.model.Row> rows)
-
selectIntegerTypeTest
public void selectIntegerTypeTest()
-
selectVarcharTypeTest
public void selectVarcharTypeTest()
-
selectBooleanTypeTest
public void selectBooleanTypeTest()
-
selectSmallintTypeTest
public void selectSmallintTypeTest()
-
selectBigintTypeTest
public void selectBigintTypeTest()
-
selectFloat4TypeTest
public void selectFloat4TypeTest()
-
selectFloat8TypeTest
public void selectFloat8TypeTest()
-
selectDateTypeTest
public void selectDateTypeTest()
-
selectTimestampTypeTest
public void selectTimestampTypeTest()
-
selectByteArrayTypeTest
public void selectByteArrayTypeTest()
-
selectVarcharListTypeTest
public void selectVarcharListTypeTest()
-
selectNullValueTest
public void selectNullValueTest()
-
selectEmptyTableTest
public void selectEmptyTableTest()
-
-