def test_update_table_task(self, mock_config):
        mock_config.get_config.return_value.get.return_value = AWS_ACCESS_KEY
        t = TestUpdateDynamoDBTableTask()

        # mock s3 location for writing output token
        s3_client = S3Client(AWS_ACCESS_KEY, AWS_SECRET_KEY)
        s3_client.s3.create_bucket('mybucket')

        # create table
        table_name = 'dynamo_table1'
        schema = [HashKey('my_hash', data_type=STRING)]
        indexes = [
            AllIndex('IndexName',
                     parts=[
                         HashKey('my_hash', data_type=STRING),
                         RangeKey('range_index', data_type=NUMBER)
                     ])
        ]
        throughput = {'read': 2, 'write': 4}
        client = DynamoDBClient(aws_access_key_id=AWS_ACCESS_KEY,
                                aws_secret_access_key=AWS_SECRET_KEY)
        client.create_table(table_name, schema, throughput, indexes=indexes)

        luigi.build([t], local_scheduler=True)

        table = client.get_table('dynamo_table1')
        self.assertEquals(8, table.throughput['read'])
        self.assertEquals(16, table.throughput['write'])
Esempio n. 2
0
    def test_update_table_task(self, mock_config):
        mock_config.get_config.return_value.get.return_value = AWS_ACCESS_KEY
        t = TestUpdateDynamoDBTableTask()

        # mock s3 location for writing output token
        s3_client = S3Client(AWS_ACCESS_KEY, AWS_SECRET_KEY)
        s3_client.s3.create_bucket("mybucket")

        # create table
        table_name = "dynamo_table1"
        schema = [HashKey("my_hash", data_type=STRING)]
        indexes = [
            AllIndex(
                "IndexName", parts=[HashKey("my_hash", data_type=STRING), RangeKey("range_index", data_type=NUMBER)]
            )
        ]
        throughput = {"read": 2, "write": 4}
        client = DynamoDBClient(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY)
        client.create_table(table_name, schema, throughput, indexes=indexes)

        luigi.build([t], local_scheduler=True)

        table = client.get_table("dynamo_table1")
        self.assertEquals(8, table.throughput["read"])
        self.assertEquals(16, table.throughput["write"])
Esempio n. 3
0
    def test_update_throughput(self):
        table_name = "dynamo_table"
        schema = [HashKey("my_hash", data_type=STRING)]
        indexes = [
            AllIndex(
                "IndexName", parts=[HashKey("my_hash", data_type=STRING), RangeKey("range_index", data_type=NUMBER)]
            )
        ]
        throughput = {"read": 2, "write": 4}
        client = DynamoDBClient(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY)
        client.create_table(table_name, schema, throughput, indexes=indexes)
        table = client.get_table(table_name)
        self.assertEquals(2, table.throughput["read"])
        self.assertEquals(4, table.throughput["write"])

        new_throughput = {"read": 8, "write": 1}
        client.update_throughput(table_name, new_throughput)
        table = client.get_table(table_name)
        # verify new throughput
        self.assertEquals(8, table.throughput["read"])
        self.assertEquals(1, table.throughput["write"])
Esempio n. 4
0
    def test_create_table_task(self, mock_config):
        mock_config.get_config.return_value.get.return_value = AWS_ACCESS_KEY
        t = TestCreateDynamoDBTableTask()
        s3_client = S3Client(AWS_ACCESS_KEY, AWS_SECRET_KEY)
        s3_client.s3.create_bucket("mybucket")
        luigi.build([t], local_scheduler=True)

        client = DynamoDBClient(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY)

        table = client.get_table("dynamo_table1")
        self.assertEquals(2, table.throughput["read"])
        self.assertEquals(3, table.throughput["write"])
        self.assertEquals("key1", table.schema[0].name)
    def test_create_table_task(self, mock_config):
        mock_config.get_config.return_value.get.return_value = AWS_ACCESS_KEY
        t = TestCreateDynamoDBTableTask()
        s3_client = S3Client(AWS_ACCESS_KEY, AWS_SECRET_KEY)
        s3_client.s3.create_bucket('mybucket')
        luigi.build([t], local_scheduler=True)

        client = DynamoDBClient(aws_access_key_id=AWS_ACCESS_KEY,
                                aws_secret_access_key=AWS_SECRET_KEY)

        table = client.get_table('dynamo_table1')
        self.assertEquals(2, table.throughput['read'])
        self.assertEquals(3, table.throughput['write'])
        self.assertEquals('key1', table.schema[0].name)
    def test_update_throughput(self):
        table_name = 'dynamo_table'
        schema = [HashKey('my_hash', data_type=STRING)]
        indexes = [
            AllIndex('IndexName',
                     parts=[
                         HashKey('my_hash', data_type=STRING),
                         RangeKey('range_index', data_type=NUMBER)
                     ])
        ]
        throughput = {'read': 2, 'write': 4}
        client = DynamoDBClient(aws_access_key_id=AWS_ACCESS_KEY,
                                aws_secret_access_key=AWS_SECRET_KEY)
        client.create_table(table_name, schema, throughput, indexes=indexes)
        table = client.get_table(table_name)
        self.assertEquals(2, table.throughput['read'])
        self.assertEquals(4, table.throughput['write'])

        new_throughput = {'read': 8, 'write': 1}
        client.update_throughput(table_name, new_throughput)
        table = client.get_table(table_name)
        # verify new throughput
        self.assertEquals(8, table.throughput['read'])
        self.assertEquals(1, table.throughput['write'])