Alerting: Fix NoDataFound for alert rules using the AND operator (#41305) (#41524)

This commit fixes an issue in alerting where NoDataFound is false
when using the AND operator to compare two conditions in an alert
rule and one of the conditions has no data.

(cherry picked from commit d6ed5d295e)
This commit is contained in:
George Robinson
2021-11-11 16:01:23 +00:00
committed by GitHub
parent d3b3f8976c
commit eddcdd8d66
2 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -182,7 +182,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
So(context.NoDataFound, ShouldBeTrue)
})
Convey("Should not return no data if at least one condition has no data and using AND", func() {
Convey("Should return no data if at least one condition has no data and using AND", func() {
context := NewEvalContext(context.TODO(), &Rule{
Conditions: []Condition{
&conditionStub{operator: "and", noData: true},
@@ -191,7 +191,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
}, &validations.OSSPluginRequestValidator{})
handler.Eval(context)
So(context.NoDataFound, ShouldBeFalse)
So(context.NoDataFound, ShouldBeTrue)
})
Convey("Should return no data if at least one condition has no data and using OR", func() {