fix(alerting): extend instant vector check for non-nullable types (#93323)
This commit is contained in:
@@ -2,6 +2,7 @@ package eval
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
@@ -1342,6 +1343,76 @@ func TestCreate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestQueryServiceResponse(t *testing.T) {
|
||||
data := `
|
||||
{
|
||||
"results": {
|
||||
"A": {
|
||||
"status": 200,
|
||||
"frames": [
|
||||
{
|
||||
"schema": {
|
||||
"refId": "A",
|
||||
"meta": {
|
||||
"type": "numeric-multi",
|
||||
"typeVersion": [
|
||||
0,
|
||||
1
|
||||
],
|
||||
"custom": {
|
||||
"resultType": "scalar"
|
||||
},
|
||||
"executedQueryString": "Expr: 1\nStep: 15s"
|
||||
},
|
||||
"fields": [
|
||||
{
|
||||
"name": "Time",
|
||||
"type": "time",
|
||||
"typeInfo": {
|
||||
"frame": "time.Time"
|
||||
},
|
||||
"config": {
|
||||
"interval": 15000
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Value",
|
||||
"type": "number",
|
||||
"typeInfo": {
|
||||
"frame": "float64"
|
||||
},
|
||||
"labels": {},
|
||||
"config": {
|
||||
"displayNameFromDS": "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"data": {
|
||||
"values": [
|
||||
[
|
||||
1719855251019
|
||||
],
|
||||
[
|
||||
1
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
var s backend.QueryDataResponse
|
||||
err := json.Unmarshal([]byte(data), &s)
|
||||
require.NoError(t, err)
|
||||
res := EvaluateAlert(&s, models.Condition{Condition: "A"}, time.Time{})
|
||||
|
||||
require.Equal(t, 1, len(res))
|
||||
require.Equal(t, Alerting, res[0].State)
|
||||
}
|
||||
|
||||
type fakeExpressionService struct {
|
||||
hook func(ctx context.Context, now time.Time, pipeline expr.DataPipeline) (*backend.QueryDataResponse, error)
|
||||
buildHook func(req *expr.Request) (expr.DataPipeline, error)
|
||||
|
||||
Reference in New Issue
Block a user