Class IntegrationTestBase


  • public abstract class IntegrationTestBase
    extends Object
    The Integration-Tests base class from which all connector-specific integration test modules should subclass.
    • Constructor Detail

      • IntegrationTestBase

        public IntegrationTestBase()
    • 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.
      • 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()