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
bf999a4f
Commit
bf999a4f
authored
Dec 13, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes broken alert eval when first condition is using OR
closes #9318
parent
dd3dd407
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
pkg/services/alerting/eval_handler.go
+5
-0
pkg/services/alerting/eval_handler_test.go
+37
-0
No files found.
pkg/services/alerting/eval_handler.go
View file @
bf999a4f
...
...
@@ -39,6 +39,11 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) {
break
}
if
i
==
0
{
firing
=
cr
.
Firing
noDataFound
=
cr
.
NoDataFound
}
// calculating Firing based on operator
if
cr
.
Operator
==
"or"
{
firing
=
firing
||
cr
.
Firing
...
...
pkg/services/alerting/eval_handler_test.go
View file @
bf999a4f
...
...
@@ -36,6 +36,16 @@ func TestAlertingEvaluationHandler(t *testing.T) {
So
(
context
.
ConditionEvals
,
ShouldEqual
,
"true = true"
)
})
Convey
(
"Show return triggered with single passing condition2"
,
func
()
{
context
:=
NewEvalContext
(
context
.
TODO
(),
&
Rule
{
Conditions
:
[]
Condition
{
&
conditionStub
{
firing
:
true
,
operator
:
"and"
}},
})
handler
.
Eval
(
context
)
So
(
context
.
Firing
,
ShouldEqual
,
true
)
So
(
context
.
ConditionEvals
,
ShouldEqual
,
"true = true"
)
})
Convey
(
"Show return false with not passing asdf"
,
func
()
{
context
:=
NewEvalContext
(
context
.
TODO
(),
&
Rule
{
Conditions
:
[]
Condition
{
...
...
@@ -131,6 +141,33 @@ func TestAlertingEvaluationHandler(t *testing.T) {
So
(
context
.
ConditionEvals
,
ShouldEqual
,
"[[true OR false] OR true] = true"
)
})
Convey
(
"Should return false if no condition is firing using OR operator"
,
func
()
{
context
:=
NewEvalContext
(
context
.
TODO
(),
&
Rule
{
Conditions
:
[]
Condition
{
&
conditionStub
{
firing
:
false
,
operator
:
"or"
},
&
conditionStub
{
firing
:
false
,
operator
:
"or"
},
&
conditionStub
{
firing
:
false
,
operator
:
"or"
},
},
})
handler
.
Eval
(
context
)
So
(
context
.
Firing
,
ShouldEqual
,
false
)
So
(
context
.
ConditionEvals
,
ShouldEqual
,
"[[false OR false] OR false] = false"
)
})
Convey
(
"Should retuasdfrn no data if one condition has nodata"
,
func
()
{
context
:=
NewEvalContext
(
context
.
TODO
(),
&
Rule
{
Conditions
:
[]
Condition
{
&
conditionStub
{
operator
:
"or"
,
noData
:
false
},
&
conditionStub
{
operator
:
"or"
,
noData
:
false
},
&
conditionStub
{
operator
:
"or"
,
noData
:
false
},
},
})
handler
.
Eval
(
context
)
So
(
context
.
NoDataFound
,
ShouldBeFalse
)
})
Convey
(
"Should return no data if one condition has nodata"
,
func
()
{
context
:=
NewEvalContext
(
context
.
TODO
(),
&
Rule
{
Conditions
:
[]
Condition
{
...
...
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