public async Task ReadAlarmsAreCreatedForEachTable() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-a-table-ConsumedReadCapacityUnits-TestGroup", tableName: "test-a-table", metricName: "ConsumedReadCapacityUnits", threshold: 292500, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-a-table-ReadThrottleEvents-TestGroup", tableName: "test-a-table", metricName: "ReadThrottleEvents", threshold: 2, period: 60); CloudwatchVerify.AlarmWasNotPutOnMetric(mockery.Cloudwatch, "ConsumedWriteCapacityUnits"); }
public async Task BothAlarmsAreCreatedForTablesNotExcluded() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(ConfigWithExclusions(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "customer-table-ConsumedReadCapacityUnits-TestGroup", tableName: "customer-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "customer-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "customer-table", metricName: "ConsumedWriteCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "products-table-ConsumedReadCapacityUnits-TestGroup", tableName: "products-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "products-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "products-table", metricName: "ConsumedWriteCapacityUnits"); }
public void FirstTableHasAlarm() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); Assert.That(async() => await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms), Throws.Exception); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, "test-a-table-ConsumedReadCapacityUnits-TestGroup", "test-a-table", "ConsumedReadCapacityUnits"); }
public async Task AlarmsAreCreatedForEachTable() { var mockery = new DynamoAlarmGeneratorMockery(); ConfigureTables(mockery); var generator = mockery.AlarmGenerator; await generator.GenerateAlarmsFor(CatchAllConfig(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-a-table-ConsumedReadCapacityUnits-TestGroup", tableName: "test-a-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-a-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "test-a-table", metricName: "ConsumedWriteCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "customer-table-ConsumedReadCapacityUnits-TestGroup", tableName: "customer-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "customer-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "customer-table", metricName: "ConsumedWriteCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-supplier-table-ConsumedReadCapacityUnits-TestGroup", tableName: "test-supplier-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-supplier-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "test-supplier-table", metricName: "ConsumedWriteCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "products-table-ConsumedReadCapacityUnits-TestGroup", tableName: "products-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "products-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "products-table", metricName: "ConsumedWriteCapacityUnits"); }
public void FirstTableHasAlarm() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); // todo, use ThrowsAsync when nunit is updated Assert.Throws <AggregateException>( () => generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms).Wait()); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, "test-a-table-ConsumedReadCapacityUnits-TestGroup", "test-a-table", "ConsumedReadCapacityUnits"); }
public async Task OnlyReadAlarmIsCreatedWhenWriteExcluded() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(ConfigWithExclusions(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-supplier-table-ConsumedReadCapacityUnits-TestGroup", tableName: "test-supplier-table", metricName: "ConsumedReadCapacityUnits"); CloudwatchVerify.AlarmWasNotPutOnTable(mockery.Cloudwatch, tableName: "test-supplier-table", metricName: "ConsumedWriteCapacityUnits"); }
public async Task CorrectAlarmsAreCreatedForEachTable() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(ConfigWithThresholds(), RunMode.GenerateAlarms); var expectedTable1ReadThreshold = (int)AlarmThresholds.Calulate(ReadCapacity, 0.4); var expectedTable1WriteThreshold = (int)AlarmThresholds.Calulate(WriteCapacity, 0.4); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test1-ConsumedReadCapacityUnits-TestGroup", tableName: "test1", metricName: "ConsumedReadCapacityUnits", threshold: expectedTable1ReadThreshold, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test1-ConsumedWriteCapacityUnits-TestGroup", tableName: "test1", metricName: "ConsumedWriteCapacityUnits", threshold: expectedTable1WriteThreshold, period: 300); var expectedTable2ReadThreshold = (int)AlarmThresholds.Calulate(ReadCapacity, 0.65); var expectedTable2WriteThreshold = (int)AlarmThresholds.Calulate(WriteCapacity, 0.65); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test2-ConsumedReadCapacityUnits-TestGroup", tableName: "test2", metricName: "ConsumedReadCapacityUnits", threshold: expectedTable2ReadThreshold, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test2-ConsumedWriteCapacityUnits-TestGroup", tableName: "test2", metricName: "ConsumedWriteCapacityUnits", threshold: expectedTable2WriteThreshold, period: 300); }
public async Task NamedTableThatDoesNotExistIsIgnored() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); var config = new WatchmanConfiguration() { AlertingGroups = new List <AlertingGroup>() { new AlertingGroup() { Name = "TestGroup", AlarmNameSuffix = "TestGroup", DynamoDb = new DynamoDb() { Tables = new List <Table> { new Table { Name = "table-that-exists" }, new Table { Name = "missing-table" } } } } } }; await generator.GenerateAlarmsFor(config, RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "table-that-exists-ConsumedWriteCapacityUnits-TestGroup", tableName: "table-that-exists", metricName: "ConsumedWriteCapacityUnits", threshold: 144000, period: 300); }
public async Task AlarmsAreCreatedForEachTableAtCorrectLevel() { var mockery = new DynamoAlarmGeneratorMockery(); ConfigureTables(mockery); var generator = mockery.AlarmGenerator; await generator.GenerateAlarmsFor(CatchAllConfig(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-a-table-ConsumedReadCapacityUnits-TestGroup", tableName: "test-a-table", metricName: "ConsumedReadCapacityUnits", threshold: 312000, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-a-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "test-a-table", metricName: "ConsumedWriteCapacityUnits", threshold: 144000, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "customer-table-ConsumedReadCapacityUnits-TestGroup", tableName: "customer-table", metricName: "ConsumedReadCapacityUnits", threshold: 672000, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "customer-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "customer-table", metricName: "ConsumedWriteCapacityUnits", threshold: 271200, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-supplier-table-ConsumedReadCapacityUnits-TestGroup", tableName: "test-supplier-table", metricName: "ConsumedReadCapacityUnits", threshold: 96000, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "test-supplier-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "test-supplier-table", metricName: "ConsumedWriteCapacityUnits", threshold: 24000, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "products-table-ConsumedReadCapacityUnits-TestGroup", tableName: "products-table", metricName: "ConsumedReadCapacityUnits", threshold: 576000, period: 300); CloudwatchVerify.AlarmWasPutOnTable(mockery.Cloudwatch, alarmName: "products-table-ConsumedWriteCapacityUnits-TestGroup", tableName: "products-table", metricName: "ConsumedWriteCapacityUnits", threshold: 19200, period: 300); }