Skip to content

Commit 04436c8

Browse files
committed
test(alerting): make sure the worst state is captured
1 parent 6cb4bdd commit 04436c8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/services/alerting/executor_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestAlertingExecutor(t *testing.T) {
9191
}
9292

9393
timeSeries := []*tsdb.TimeSeries{
94-
tsdb.NewTimeSeries("test1", [][2]float64{{1, 0}, {11, 0}}),
94+
tsdb.NewTimeSeries("test1", [][2]float64{{6, 0}, {11, 0}}),
9595
}
9696

9797
result := executor.evaluateRule(rule, timeSeries)
@@ -130,6 +130,22 @@ func TestAlertingExecutor(t *testing.T) {
130130
result := executor.evaluateRule(rule, timeSeries)
131131
So(result.State, ShouldEqual, alertstates.Critical)
132132
})
133+
134+
Convey("first serie is warn, second is critical", func() {
135+
rule := &AlertRule{
136+
Critical: Level{Level: 10, Operator: ">"},
137+
Warning: Level{Level: 5, Operator: ">"},
138+
Transformer: transformers.NewAggregationTransformer("avg"),
139+
}
140+
141+
timeSeries := []*tsdb.TimeSeries{
142+
tsdb.NewTimeSeries("test1", [][2]float64{{6, 0}}),
143+
tsdb.NewTimeSeries("test1", [][2]float64{{11, 0}}),
144+
}
145+
146+
result := executor.evaluateRule(rule, timeSeries)
147+
So(result.State, ShouldEqual, alertstates.Critical)
148+
})
133149
})
134150
})
135151
}

0 commit comments

Comments
 (0)