Skip to content

Commit 747fd09

Browse files
committed
Don't fire on alerts at sev info
1 parent d334db8 commit 747fd09

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

pkg/monitortests/testframework/legacytestframeworkmonitortests/alerts.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ func isSkippedAlert(alertName string) bool {
244244
return false
245245
}
246246

247-
// runNoNewAlertsFiringTest checks all alerts to see if we:
248-
// 1. have no historical data for that alert in that namespace for this release
249-
// 2. have historical data but it was first observed less than 2 weeks ago
247+
// runNoNewAlertsFiringTest checks all firing non-info alerts to see if we:
248+
//
249+
// - have no historical data for that alert in that namespace for this release, or
250+
// - have historical data but it was first observed less than 2 weeks ago
250251
//
251252
// If either is true, this test will fail. We do not want new product alerts being added to the product that
252253
// will trigger routinely and affect the fleet when they ship.
@@ -272,6 +273,13 @@ func runNoNewAlertsFiringTest(historicalData *historicaldata.AlertBestMatcher,
272273
continue
273274
}
274275

276+
// Skip alerts with severity info, I don't totally understand the semantics here but it appears some components
277+
// use this for informational alerts. (saw two examples from Insights)
278+
// We're only interested in warning+critical for the purposes of this test.
279+
if interval.StructuredMessage.Annotations[monitorapi.AnnotationSeverity] == "info" {
280+
continue
281+
}
282+
275283
// Scan historical data to see if this alert appears new. Ignore release, namespace, level, everything but
276284
// AlertName, just see if it's in the data file and when we first observed it in either of the two releases we expect in there.
277285
var firstObserved *time.Time

pkg/monitortests/testframework/legacytestframeworkmonitortests/alerts_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,35 @@ func TestNoNewAlertsFiringBackstop(t *testing.T) {
8282
firingIntervals: monitorapi.Intervals{interval},
8383
expectedStatus: []string{"pass", "fail"},
8484
},
85+
{
86+
name: "firing severity info alert never seen before",
87+
historicalData: historicaldata.NewAlertMatcherWithHistoricalData(
88+
map[historicaldata.AlertDataKey]historicaldata.AlertStatisticalData{}),
89+
firingIntervals: monitorapi.Intervals{monitorapi.Interval{
90+
Condition: monitorapi.Condition{
91+
Level: monitorapi.Warning,
92+
StructuredLocator: monitorapi.Locator{
93+
Type: monitorapi.LocatorTypeAlert,
94+
Keys: map[monitorapi.LocatorKey]string{
95+
monitorapi.LocatorAlertKey: "FakeAlert",
96+
monitorapi.LocatorNamespaceKey: "fakens",
97+
},
98+
},
99+
StructuredMessage: monitorapi.Message{
100+
HumanMessage: "jibberish",
101+
Annotations: map[monitorapi.AnnotationKey]string{
102+
monitorapi.AnnotationAlertState: "firing",
103+
monitorapi.AnnotationSeverity: "info",
104+
},
105+
},
106+
},
107+
Source: monitorapi.SourceAlert,
108+
Display: false,
109+
From: time.Now().Add(-5 * time.Hour),
110+
To: time.Now().Add(-6 * time.Hour),
111+
}},
112+
expectedStatus: []string{"pass"}, // info severity alerts should not fail this test
113+
},
85114
{
86115
name: "firing alert observed more than two weeks ago",
87116
historicalData: historicaldata.NewAlertMatcherWithHistoricalData(

0 commit comments

Comments
 (0)