public void TestTableCalls() { var tables = GetTableNames(); int tableCount = tables.Count; // Create hash-key table var table1Name = TableNamePrefix + "Table1"; Client.CreateTable( table1Name, new List <KeySchemaElement> { new KeySchemaElement { KeyType = KeyType.HASH, AttributeName = "Id" } }, new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N } }, new ProvisionedThroughput { ReadCapacityUnits = DefaultReadCapacity, WriteCapacityUnits = DefaultWriteCapacity }); CreatedTables.Add(table1Name); // Create hash-and-range-key table var table2Name = TableNamePrefix + "Table2"; Client.CreateTable( table2Name, new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Id", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Name", KeyType = KeyType.RANGE } }, new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Name", AttributeType = ScalarAttributeType.S } }, new ProvisionedThroughput { ReadCapacityUnits = DefaultReadCapacity, WriteCapacityUnits = DefaultWriteCapacity }); CreatedTables.Add(table2Name); // Create hash-key table with global index var table3Name = TableNamePrefix + "Table3"; Client.CreateTable(new CreateTableRequest { TableName = table3Name, AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Company", AttributeType = ScalarAttributeType.S }, new AttributeDefinition { AttributeName = "Price", AttributeType = ScalarAttributeType.N } }, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { KeyType = KeyType.HASH, AttributeName = "Id" } }, GlobalSecondaryIndexes = new List <GlobalSecondaryIndex> { new GlobalSecondaryIndex { IndexName = "GlobalIndex", KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Company", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Price", KeyType = KeyType.RANGE } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 1, WriteCapacityUnits = 1 }, Projection = new Projection { ProjectionType = ProjectionType.ALL } } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = DefaultReadCapacity, WriteCapacityUnits = DefaultWriteCapacity }, }); CreatedTables.Add(table3Name); // Wait for tables to be ready before creating another table with an index WaitForTableStatus(CreatedTables, TableStatus.ACTIVE); // Create hash-and-range-key table with local and global indexes var table4Name = TableNamePrefix + "Table4"; Client.CreateTable(new CreateTableRequest { TableName = table4Name, AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Name", AttributeType = ScalarAttributeType.S }, new AttributeDefinition { AttributeName = "Company", AttributeType = ScalarAttributeType.S }, new AttributeDefinition { AttributeName = "Price", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Manager", AttributeType = ScalarAttributeType.S } }, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Id", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Name", KeyType = KeyType.RANGE } }, GlobalSecondaryIndexes = new List <GlobalSecondaryIndex> { new GlobalSecondaryIndex { IndexName = "GlobalIndex", KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Company", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Price", KeyType = KeyType.RANGE } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 1, WriteCapacityUnits = 1 }, Projection = new Projection { ProjectionType = ProjectionType.ALL } } }, LocalSecondaryIndexes = new List <LocalSecondaryIndex> { new LocalSecondaryIndex { IndexName = "LocalIndex", KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Id", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Manager", KeyType = KeyType.RANGE } }, Projection = new Projection { ProjectionType = ProjectionType.INCLUDE, NonKeyAttributes = new List <string> { "Company", "Price" } } } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = DefaultReadCapacity, WriteCapacityUnits = DefaultWriteCapacity }, }); CreatedTables.Add(table4Name); tables = GetTableNames(); Assert.AreEqual(tableCount + 4, tables.Count); // Wait for tables to be ready WaitForTableStatus(CreatedTables, TableStatus.ACTIVE); // Update throughput for a table Client.UpdateTable( table2Name, new ProvisionedThroughput { ReadCapacityUnits = DefaultReadCapacity * 2, WriteCapacityUnits = DefaultWriteCapacity * 2 }); // Wait for tables to be ready WaitForTableStatus(CreatedTables, TableStatus.ACTIVE); // Delete new tables Client.DeleteTable(table1Name); Client.DeleteTable(table2Name); Client.DeleteTable(table3Name); Client.DeleteTable(table4Name); // Wait for tables to be deleted WaitForTableStatus(new string[] { table1Name, table2Name, table3Name, table4Name }, null); // Count tables again tables = GetTableNames(); Assert.AreEqual(tableCount, tables.Count); CreatedTables.Remove(table1Name); CreatedTables.Remove(table2Name); CreatedTables.Remove(table3Name); CreatedTables.Remove(table4Name); }
public void TestTableCalls() { // Only run these tests if we are not reusing tables if (ReuseTables) { return; } var tables = GetTableNames(); int tableCount = tables.Count; // Create hash-key table var table1Name = TableNamePrefix + "Table1"; Client.CreateTable( new CreateTableRequest { TableName = table1Name, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { KeyType = KeyType.HASH, AttributeName = "Id" } }, AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N } }, BillingMode = BillingMode.PAY_PER_REQUEST }); CreatedTables.Add(table1Name); // Create hash-and-range-key table var table2Name = TableNamePrefix + "Table2"; Client.CreateTable(new CreateTableRequest { TableName = table2Name, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Id", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Name", KeyType = KeyType.RANGE } }, AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Name", AttributeType = ScalarAttributeType.S } }, BillingMode = BillingMode.PAY_PER_REQUEST }); CreatedTables.Add(table2Name); // Create hash-key table with global index var table3Name = TableNamePrefix + "Table3"; Client.CreateTable(new CreateTableRequest { TableName = table3Name, AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Company", AttributeType = ScalarAttributeType.S }, new AttributeDefinition { AttributeName = "Price", AttributeType = ScalarAttributeType.N } }, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { KeyType = KeyType.HASH, AttributeName = "Id" } }, GlobalSecondaryIndexes = new List <GlobalSecondaryIndex> { new GlobalSecondaryIndex { IndexName = "GlobalIndex", KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Company", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Price", KeyType = KeyType.RANGE } }, Projection = new Projection { ProjectionType = ProjectionType.ALL } } }, BillingMode = BillingMode.PAY_PER_REQUEST }); CreatedTables.Add(table3Name); // Wait for tables to be ready before creating another table with an index WaitForTableStatus(CreatedTables, TableStatus.ACTIVE); // Create hash-and-range-key table with local and global indexes var table4Name = TableNamePrefix + "Table4"; Client.CreateTable(new CreateTableRequest { TableName = table4Name, AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "Id", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Name", AttributeType = ScalarAttributeType.S }, new AttributeDefinition { AttributeName = "Company", AttributeType = ScalarAttributeType.S }, new AttributeDefinition { AttributeName = "Price", AttributeType = ScalarAttributeType.N }, new AttributeDefinition { AttributeName = "Manager", AttributeType = ScalarAttributeType.S } }, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Id", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Name", KeyType = KeyType.RANGE } }, GlobalSecondaryIndexes = new List <GlobalSecondaryIndex> { new GlobalSecondaryIndex { IndexName = "GlobalIndex", KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Company", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Price", KeyType = KeyType.RANGE } }, Projection = new Projection { ProjectionType = ProjectionType.ALL } } }, LocalSecondaryIndexes = new List <LocalSecondaryIndex> { new LocalSecondaryIndex { IndexName = "LocalIndex", KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "Id", KeyType = KeyType.HASH }, new KeySchemaElement { AttributeName = "Manager", KeyType = KeyType.RANGE } }, Projection = new Projection { ProjectionType = ProjectionType.INCLUDE, NonKeyAttributes = new List <string> { "Company", "Price" } } } }, BillingMode = BillingMode.PAY_PER_REQUEST }); CreatedTables.Add(table4Name); tables = GetTableNames(); Assert.AreEqual(tableCount + 4, tables.Count); // Wait for tables to be ready WaitForTableStatus(CreatedTables, TableStatus.ACTIVE); // Delete new tables Client.DeleteTable(table1Name); Client.DeleteTable(table2Name); Client.DeleteTable(table3Name); Client.DeleteTable(table4Name); // Wait for tables to be deleted WaitForTableStatus(new string[] { table1Name, table2Name, table3Name, table4Name }, null); // Count tables again tables = GetTableNames(); Assert.AreEqual(tableCount, tables.Count); CreatedTables.Remove(table1Name); CreatedTables.Remove(table2Name); CreatedTables.Remove(table3Name); CreatedTables.Remove(table4Name); }