-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: extract and extend SNS dashboard tests
- Loading branch information
Showing
3 changed files
with
109 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { merge } from 'lodash' | ||
import { test } from 'tap' | ||
import { type MetricWidgetProperties } from 'cloudwatch-dashboard-types' | ||
|
||
import { type ResourceType } from '../../cf-template' | ||
import addDashboard from '../dashboard' | ||
import defaultConfig from '../../inputs/default-config' | ||
|
||
import { createTestCloudFormationTemplate, getDashboardFromTemplate, getDashboardWidgetsByTitle } from '../../tests/testing-utils' | ||
|
||
test('dashboard contains configured SNS resources', (t) => { | ||
t.test('dashboards includes SQS metrics', (t) => { | ||
const template = createTestCloudFormationTemplate() | ||
addDashboard(defaultConfig.dashboard, template) | ||
const { dashboard } = getDashboardFromTemplate(template) | ||
|
||
const widgets = getDashboardWidgetsByTitle(dashboard, | ||
/SNS Topic/ | ||
) | ||
|
||
const [snsTopicWidget] = widgets | ||
t.ok(snsTopicWidget) | ||
t.same((snsTopicWidget.properties as MetricWidgetProperties).metrics, [ | ||
['AWS/SNS', 'NumberOfNotificationsFilteredOut-InvalidAttributes', 'TopicName', '${topic.TopicName}', { stat: 'Sum', yAxis: 'left' }], | ||
['AWS/SNS', 'NumberOfNotificationsFailed', 'TopicName', '${topic.TopicName}', { stat: 'Sum', yAxis: 'left' }] | ||
]) | ||
|
||
t.end() | ||
}) | ||
|
||
t.test('service config overrides take precedence', (t) => { | ||
const template = createTestCloudFormationTemplate() | ||
|
||
const config = merge({}, defaultConfig.dashboard, { | ||
widgets: { | ||
SNS: { | ||
metricPeriod: 900, | ||
width: 8, | ||
height: 12, | ||
'NumberOfNotificationsFilteredOut-InvalidAttributes': { | ||
Statistic: ['ts80'], | ||
yAxis: 'right' | ||
}, | ||
NumberOfNotificationsFailed: { | ||
Statistic: ['ts85'], | ||
yAxis: 'left' | ||
} | ||
} | ||
} | ||
}) | ||
|
||
addDashboard(config, template) | ||
const { dashboard } = getDashboardFromTemplate(template) | ||
|
||
const widgets = getDashboardWidgetsByTitle(dashboard, | ||
/SNS Topic/ | ||
) | ||
|
||
const [snsTopicWidget] = widgets | ||
t.ok(snsTopicWidget) | ||
t.same((snsTopicWidget.properties as MetricWidgetProperties).metrics, [ | ||
['AWS/SNS', 'NumberOfNotificationsFilteredOut-InvalidAttributes', 'TopicName', '${topic.TopicName}', { stat: 'ts80', yAxis: 'right' }], | ||
['AWS/SNS', 'NumberOfNotificationsFailed', 'TopicName', '${topic.TopicName}', { stat: 'ts85', yAxis: 'left' }] | ||
]) | ||
|
||
t.end() | ||
}) | ||
|
||
t.test('resource config overrides take precedence', (t) => { | ||
const template = createTestCloudFormationTemplate(); | ||
(template.Resources as ResourceType).topic.Metadata = { | ||
slicWatch: { | ||
dashboard: { | ||
'NumberOfNotificationsFilteredOut-InvalidAttributes': { | ||
Statistic: ['ts80'], | ||
yAxis: 'right', | ||
enabled: false | ||
}, | ||
NumberOfNotificationsFailed: { | ||
Statistic: ['ts90'], | ||
yAxis: 'right' | ||
} | ||
} | ||
} | ||
} | ||
|
||
addDashboard(defaultConfig.dashboard, template) | ||
const { dashboard } = getDashboardFromTemplate(template) | ||
|
||
const widgets = getDashboardWidgetsByTitle(dashboard, | ||
/SNS Topic/ | ||
) | ||
|
||
const [snsTopicWidget] = widgets | ||
t.ok(snsTopicWidget) | ||
t.same((snsTopicWidget.properties as MetricWidgetProperties).metrics, [ | ||
['AWS/SNS', 'NumberOfNotificationsFailed', 'TopicName', '${topic.TopicName}', { stat: 'ts90', yAxis: 'right' }] | ||
]) | ||
|
||
t.end() | ||
}) | ||
|
||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters