Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bdfb773a
Commit
bdfb773a
authored
Nov 27, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(alerting): fixes broken no_value evaluator
closes #6701
parent
583de8e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
pkg/services/alerting/conditions/evaluator.go
+4
-4
pkg/services/alerting/conditions/evaluator_test.go
+12
-7
No files found.
pkg/services/alerting/conditions/evaluator.go
View file @
bdfb773a
...
...
@@ -17,9 +17,9 @@ type AlertEvaluator interface {
Eval
(
reducedValue
null
.
Float
)
bool
}
type
No
Data
Evaluator
struct
{}
type
No
Value
Evaluator
struct
{}
func
(
e
*
No
Data
Evaluator
)
Eval
(
reducedValue
null
.
Float
)
bool
{
func
(
e
*
No
Value
Evaluator
)
Eval
(
reducedValue
null
.
Float
)
bool
{
return
reducedValue
.
Valid
==
false
}
...
...
@@ -118,8 +118,8 @@ func NewAlertEvaluator(model *simplejson.Json) (AlertEvaluator, error) {
return
newRangedEvaluator
(
typ
,
model
)
}
if
typ
==
"no_
data
"
{
return
&
No
Data
Evaluator
{},
nil
if
typ
==
"no_
value
"
{
return
&
No
Value
Evaluator
{},
nil
}
return
nil
,
alerting
.
ValidationError
{
Reason
:
"Evaluator invalid evaluator type: "
+
typ
}
...
...
pkg/services/alerting/conditions/evaluator_test.go
View file @
bdfb773a
...
...
@@ -44,15 +44,20 @@ func TestEvalutors(t *testing.T) {
So
(
evalutorScenario
(
`{"type": "outside_range", "params": [100, 1] }`
,
50
),
ShouldBeFalse
)
})
Convey
(
"no_data"
,
t
,
func
()
{
So
(
evalutorScenario
(
`{"type": "no_data", "params": [] }`
,
50
),
ShouldBeFalse
)
Convey
(
"no_value"
,
t
,
func
()
{
Convey
(
"should be false if serie have values"
,
func
()
{
So
(
evalutorScenario
(
`{"type": "no_value", "params": [] }`
,
50
),
ShouldBeFalse
)
})
jsonModel
,
err
:=
simplejson
.
NewJson
([]
byte
(
`{"type": "no_data", "params": [] }`
))
So
(
err
,
ShouldBeNil
)
Convey
(
"should be true when the serie have no value"
,
func
()
{
jsonModel
,
err
:=
simplejson
.
NewJson
([]
byte
(
`{"type": "no_value", "params": [] }`
))
So
(
err
,
ShouldBeNil
)
evaluator
,
err
:=
NewAlertEvaluator
(
jsonModel
)
So
(
err
,
ShouldBeNil
)
evaluator
,
err
:=
NewAlertEvaluator
(
jsonModel
)
So
(
err
,
ShouldBeNil
)
So
(
evaluator
.
Eval
(
null
.
FloatFromPtr
(
nil
)),
ShouldBeTrue
)
So
(
evaluator
.
Eval
(
null
.
FloatFromPtr
(
nil
)),
ShouldBeTrue
)
})
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment