mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(alerting): fixes bug in query conditions
This commit is contained in:
parent
bec099cd84
commit
9511f89a22
@ -55,13 +55,13 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
||||
})
|
||||
}
|
||||
|
||||
context.Firing = evalMatch
|
||||
|
||||
// handle no data scenario
|
||||
if reducedValue == nil {
|
||||
context.NoDataFound = true
|
||||
}
|
||||
}
|
||||
|
||||
context.Firing = len(context.EvalMatches) > 0
|
||||
}
|
||||
|
||||
func (c *QueryCondition) executeQuery(context *alerting.EvalContext) (tsdb.TimeSeriesSlice, error) {
|
||||
|
@ -59,6 +59,19 @@ func TestQueryCondition(t *testing.T) {
|
||||
So(ctx.result.Error, ShouldBeNil)
|
||||
So(ctx.result.Firing, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("Should fire if only first serie matches", func() {
|
||||
one := float64(120)
|
||||
two := float64(0)
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", [][2]*float64{{&one, &two}}),
|
||||
tsdb.NewTimeSeries("test2", [][2]*float64{{&two, &two}}),
|
||||
}
|
||||
ctx.exec()
|
||||
|
||||
So(ctx.result.Error, ShouldBeNil)
|
||||
So(ctx.result.Firing, ShouldBeTrue)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user