def testInitLocation(self):
    FLAGS.zone = ['us-east-1a']

    test_instance = aws_dynamodb.AwsDynamoDBInstance('test_table')

    self.assertEqual(test_instance.zone, 'us-east-1a')
    self.assertEqual(test_instance.region, 'us-east-1')
  def testGetResourceMetadata(self):
    FLAGS.zone = ['us-east-1a']
    FLAGS.aws_dynamodb_primarykey = 'test_primary_key'
    FLAGS.aws_dynamodb_use_sort = 'test_use_sort'
    FLAGS.aws_dynamodb_sortkey = 'test_sortkey'
    FLAGS.aws_dynamodb_attributetype = 'test_attribute_type'
    FLAGS.aws_dynamodb_read_capacity = 1
    FLAGS.aws_dynamodb_write_capacity = 2
    FLAGS.aws_dynamodb_lsi_count = 3
    FLAGS.aws_dynamodb_gsi_count = 4
    FLAGS.aws_dynamodb_ycsb_consistentReads = 5
    FLAGS.aws_dynamodb_connectMax = 6
    test_instance = aws_dynamodb.AwsDynamoDBInstance('test_table')

    actual_metadata = test_instance.GetResourceMetadata()

    expected_metadata = {
        'aws_dynamodb_primarykey': 'test_primary_key',
        'aws_dynamodb_use_sort': 'test_use_sort',
        'aws_dynamodb_sortkey': 'test_sortkey',
        'aws_dynamodb_attributetype': 'test_attribute_type',
        'aws_dynamodb_read_capacity': 1,
        'aws_dynamodb_write_capacity': 2,
        'aws_dynamodb_lsi_count': 3,
        'aws_dynamodb_gsi_count': 4,
        'aws_dynamodb_consistentReads': 5,
        'aws_dynamodb_connectMax': 6,
    }
    self.assertEqual(actual_metadata, expected_metadata)
Exemple #3
0
    def testRunThroughputStaysSame(self):
        # WCU stays the same during loading if > 10k.
        # Arrange
        instance = aws_dynamodb.AwsDynamoDBInstance(rcu=1000, wcu=30000)
        mock_set_throughput = self.enter_context(
            mock.patch.object(instance, 'SetThroughput'))
        self.mock_spec.non_relational_db = instance

        # Act
        aws_dynamodb_ycsb_benchmark.Run(self.mock_spec)

        # Assert
        mock_set_throughput.assert_called_once_with()
Exemple #4
0
    def testRunThroughputIncreases(self):
        # Benchmark raises WCU to 10k during loading if WCU < 10k.
        # Arrange
        instance = aws_dynamodb.AwsDynamoDBInstance(rcu=1000, wcu=1000)
        mock_set_throughput = self.enter_context(
            mock.patch.object(instance, 'SetThroughput'))
        self.mock_spec.non_relational_db = instance

        # Act
        aws_dynamodb_ycsb_benchmark.Run(self.mock_spec)

        # Assert
        mock_set_throughput.assert_has_calls(
            [mock.call(wcu=10000), mock.call()])
Exemple #5
0
def Prepare(benchmark_spec):
    """Install YCSB on the target vm.
    Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.
    """
    benchmark_spec.always_call_cleanup = True

    benchmark_spec.dynamodb_instance = aws_dynamodb.AwsDynamoDBInstance(
        table_name='pkb-{0}'.format(FLAGS.run_uri))
    benchmark_spec.dynamodb_instance._Create()

    vms = benchmark_spec.vms
    # Install required packages.
    vm_util.RunThreaded(_Install, vms)
    benchmark_spec.executor = ycsb.YCSBExecutor('dynamodb')
def GetTestDynamoDBInstance(table_name='test_table'):
  FLAGS.zone = ['us-east-1a']
  return aws_dynamodb.AwsDynamoDBInstance(table_name)