public async Task AlarmsAreCreatedForEachIncludedTable() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnIndex(mockery.Cloudwatch, alarmName: "test-a-table-ConsumerIdIndex-ConsumedReadCapacityUnits-TestGroup", tableName: "test-a-table", indexName: "ConsumerIdIndex", metricName: "ConsumedReadCapacityUnits", threshold: 312000, period: 300); CloudwatchVerify.AlarmWasPutOnIndex(mockery.Cloudwatch, alarmName: "test-a-table-ConsumerIdIndex-ConsumedWriteCapacityUnits-TestGroup", tableName: "test-a-table", indexName: "ConsumerIdIndex", metricName: "ConsumedWriteCapacityUnits", threshold: 144000, period: 300); CloudwatchVerify.AlarmWasNotPutonIndex(mockery.Cloudwatch, tableName: "products-table", indexName: "ThisIsAnIndex"); }
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"); }
private static void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.GivenAListOfTables(new string[] { "authentication-tokens" }); mockery.GivenATableWithIndex("authentication-tokens", "ThisIsAnIndex", 1300, 600); mockery.ValidSnsTopic(); }
private static void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.ValidSnsTopic(); mockery.GivenAListOfTables(new[] { "test-a-table", "other-table" }); mockery.GivenATable("test-a-table", 1300, 600); mockery.GivenATable("other-table", 1300, 600); }
public async Task DoesNotThrowIfTableIsReturnedInListingButCannotBeDescribed() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; mockery.GivenAListOfTables(new[] { "banana", "apple" }); mockery.GivenATable("apple", 1300, 600); mockery.ValidSnsTopic(); var config = new WatchmanConfiguration() { AlertingGroups = new List <AlertingGroup>() { new AlertingGroup() { Name = "TestGroup", AlarmNameSuffix = "TestGroup", DynamoDb = new DynamoDb() { Tables = new List <Table> { new Table { Pattern = "^.*$" } } } } } }; await generator.GenerateAlarmsFor(config, RunMode.GenerateAlarms); }
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"); }
private void TestRun(DynamoAlarmGeneratorMockery mockery) { ConfigureTables(mockery); var generator = mockery.AlarmGenerator; Assert.Throws <AggregateException>(() => generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms).Wait()); }
private void TestRun(DynamoAlarmGeneratorMockery mockery) { ConfigureTables(mockery); var generator = mockery.AlarmGenerator; Assert.That(async() => await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms), Throws.Exception); }
public void NoWriteAlarmIsPut() { var mockery = new DynamoAlarmGeneratorMockery(); TestRun(mockery); CloudwatchVerify.AlarmWasNotPutOnMetric(mockery.Cloudwatch, "ConsumedWriteCapacityUnits"); }
private static void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.GivenATableWithIndex("happy-table-1", "happy-index-1", 1300, 600); mockery.GivenATableWithIndex("happy-table-2", "happy-index-2", 50, 15); mockery.GivenATableDoesNotExist("failure-table-1"); mockery.ValidSnsTopic(); }
private static void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.GivenAListOfTables(new[] { "test1", "test2" }); mockery.GivenATable("test1", ReadCapacity, WriteCapacity); mockery.GivenATable("test2", ReadCapacity, WriteCapacity); mockery.ValidSnsTopic(); }
private void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.ValidSnsTopic(); mockery.GivenATable("test-a-table", 1300, 600); mockery.GivenATable("my-orders", 4000, 800); mockery.GivenATableDoesNotExist("this-table-does-not-exist"); }
public void FurtherAlarmsAreNotPut() { var mockery = new DynamoAlarmGeneratorMockery(); TestRun(mockery); CloudwatchVerify.AlarmWasNotPutOnTable(mockery.Cloudwatch, "failure-table-1"); CloudwatchVerify.AlarmWasNotPutOnTable(mockery.Cloudwatch, "happy-table-2"); }
public async Task AlarmsAreNotCreatedForExcludedTable() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(ConfigWithAnExclusion(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasNotPutOnTable(mockery.Cloudwatch, "products-table"); }
public async Task NoWriteAlarmsAreCreated() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasNotPutOnMetric(mockery.Cloudwatch, "ConsumedWriteCapacityUnits"); }
private static void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.GivenAListOfTables(new[] { "test-a-table", "customer-table", "test-supplier-table", "products-table" }); mockery.GivenATable("test-a-table", 1300, 600); mockery.GivenATable("customer-table", 2800, 1130); mockery.GivenATable("test-supplier-table", 400, 100); mockery.GivenATable("products-table", 2400, 80); mockery.ValidSnsTopic(); }
public async Task NoAlarmsAreCreated() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); mockery.Cloudwatch.Verify(x => x.PutMetricAlarm(It.IsAny <PutMetricAlarmRequest>()), Times.Never); }
public void OtherAlarmsAreNotCreated() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); Assert.That(async() => await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms), Throws.Exception); CloudwatchVerify.AlarmWasNotPutOnTable(mockery.Cloudwatch, "my-orders"); }
private static void ConfigureTables(DynamoAlarmGeneratorMockery mockery) { mockery.GivenAListOfTables( new[] { "test-a-table", "customer-table", "test-supplier-table", "products-table" }); mockery.GivenATableWithIndex("test-a-table", "ConsumerIdIndex", 1300, 600); mockery.GivenATable("customer-table", 2800, 1130); mockery.GivenATable("test-supplier-table", 400, 100); mockery.GivenATableWithIndex("products-table", "ThisIsAnIndex", 452, 550); mockery.ValidSnsTopic(); }
public void OtherAlarmsAreNotCreated() { 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.AlarmWasNotPutOnTable(mockery.Cloudwatch, "my-orders"); }
public async Task AnSnsTopicIsCreatedForTriggeringTheAlert() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); mockery.SnsTopicCreator.Verify( x => x.EnsureSnsTopic("TestGroup", false), Times.Once); }
public void TheFirstAlarmIsPut() { var mockery = new DynamoAlarmGeneratorMockery(); TestRun(mockery); CloudwatchVerify.AlarmWasPutOnIndex(mockery.Cloudwatch, alarmName: "happy-table-1-happy-index-1-ConsumedReadCapacityUnits-TestGroup", tableName: "happy-table-1", indexName: "happy-index-1", metricName: "ConsumedReadCapacityUnits", threshold: 312000, period: 300); }
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 async Task TableAlarmThresholdsAreSet() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutMatching(mockery.Cloudwatch, request => request.AlarmName == "orders-ConsumedReadCapacityUnits-TestGroup" && request.MetricName == AwsMetrics.ConsumedReadCapacity && request.Threshold.Equals(4000 * 0.5 * AwsConstants.FiveMinutesInSeconds)); }
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 AWriteAlarmIsCreatedOrUpdated() { var mockery = new DynamoAlarmGeneratorMockery(); var generator = mockery.AlarmGenerator; ConfigureTables(mockery); await generator.GenerateAlarmsFor(Config(), RunMode.GenerateAlarms); CloudwatchVerify.AlarmWasPutOnIndex(mockery.Cloudwatch, alarmName: "authentication-tokens-ThisIsAnIndex-ConsumedWriteCapacityUnits-TestGroup", tableName: "authentication-tokens", indexName: "ThisIsAnIndex", metricName: "ConsumedWriteCapacityUnits", threshold: 144000, period: 300); }
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); }