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
3289225b
Commit
3289225b
authored
Jun 07, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): fixed test issues
parent
8105ec46
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
35 deletions
+19
-35
pkg/services/alerting/alerting.go
+0
-15
pkg/services/alerting/engine.go
+2
-2
pkg/services/alerting/executor_test.go
+1
-1
pkg/services/sqlstore/alert_rule_changes_test.go
+1
-0
pkg/tsdb/graphite/graphite_test.go
+1
-1
pkg/tsdb/tsdb_test.go
+14
-16
No files found.
pkg/services/alerting/alerting.go
View file @
3289225b
package
alerting
import
(
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
_
"github.com/grafana/grafana/pkg/tsdb/graphite"
)
...
...
@@ -29,15 +26,3 @@ func Init() {
// go scheduler.executor(&ExecutorImpl{})
// go scheduler.handleResponses()
}
func
saveState
(
result
*
AlertResult
)
{
cmd
:=
&
m
.
UpdateAlertStateCommand
{
AlertId
:
result
.
AlertJob
.
Rule
.
Id
,
NewState
:
result
.
State
,
Info
:
result
.
Description
,
}
if
err
:=
bus
.
Dispatch
(
cmd
);
err
!=
nil
{
log
.
Error
(
2
,
"failed to save state %v"
,
err
)
}
}
pkg/services/alerting/engine.go
View file @
3289225b
...
...
@@ -114,11 +114,11 @@ func (e *Engine) resultHandler() {
result
.
State
=
alertstates
.
Critical
result
.
Description
=
fmt
.
Sprintf
(
"Failed to run check after %d retires, Error: %v"
,
maxRetries
,
result
.
Error
)
saveState
(
result
)
e
.
saveState
(
result
)
}
}
else
{
result
.
AlertJob
.
RetryCount
=
0
saveState
(
result
)
e
.
saveState
(
result
)
}
}
}
...
...
pkg/services/alerting/executor_test.go
View file @
3289225b
...
...
@@ -10,7 +10,7 @@ import (
func
TestAlertingExecutor
(
t
*
testing
.
T
)
{
Convey
(
"Test alert execution"
,
t
,
func
()
{
executor
:=
&
ExecutorImpl
{}
executor
:=
NewExecutor
()
Convey
(
"single time serie"
,
func
()
{
Convey
(
"Show return ok since avg is above 2"
,
func
()
{
...
...
pkg/services/sqlstore/alert_rule_changes_test.go
View file @
3289225b
...
...
@@ -48,6 +48,7 @@ func TestAlertRuleChangesDataAccess(t *testing.T) {
SaveAlerts
(
&
cmd
)
query
:=
&
m
.
GetAlertChangesQuery
{
OrgId
:
FakeOrgId
}
er
:=
GetAlertRuleChanges
(
query
)
So
(
er
,
ShouldBeNil
)
So
(
len
(
query
.
Result
),
ShouldEqual
,
1
)
...
...
pkg/tsdb/graphite/graphite_test.go
View file @
3289225b
...
...
@@ -16,7 +16,7 @@ func TestGraphite(t *testing.T) {
})
queries
:=
tsdb
.
QuerySlice
{
&
tsdb
.
Query
{
Query
:
"
apps.backend.*.counters.requests.count
"
},
&
tsdb
.
Query
{
Query
:
"
{
\"
target
\"
:
\"
apps.backend.*.counters.requests.count
\"
}
"
},
}
context
:=
tsdb
.
NewQueryContext
(
queries
,
tsdb
.
TimeRange
{})
...
...
pkg/tsdb/tsdb_test.go
View file @
3289225b
...
...
@@ -55,7 +55,7 @@ func TestMetricQuery(t *testing.T) {
Convey
(
"When executing request with one query"
,
t
,
func
()
{
req
:=
&
Request
{
Queries
:
QuerySlice
{
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"test"
}},
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"test"
}},
},
}
...
...
@@ -74,8 +74,8 @@ func TestMetricQuery(t *testing.T) {
Convey
(
"When executing one request with two queries from same data source"
,
t
,
func
()
{
req
:=
&
Request
{
Queries
:
QuerySlice
{
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"test"
}},
{
RefId
:
"B"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"test"
}},
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"test"
}},
{
RefId
:
"B"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"test"
}},
},
}
...
...
@@ -100,9 +100,9 @@ func TestMetricQuery(t *testing.T) {
Convey
(
"When executing one request with three queries from different datasources"
,
t
,
func
()
{
req
:=
&
Request
{
Queries
:
QuerySlice
{
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"test"
}},
{
RefId
:
"B"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"test"
}},
{
RefId
:
"C"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
2
,
Type
:
"test"
}},
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"test"
}},
{
RefId
:
"B"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"test"
}},
{
RefId
:
"C"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
2
,
PluginId
:
"test"
}},
},
}
...
...
@@ -117,24 +117,22 @@ func TestMetricQuery(t *testing.T) {
Convey
(
"When query uses data source of unknown type"
,
t
,
func
()
{
req
:=
&
Request
{
Queries
:
QuerySlice
{
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"asdasdas"
}},
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"asdasdas"
}},
},
}
res
,
err
:=
HandleRequest
(
req
)
So
(
err
,
ShouldBeNil
)
Convey
(
"Should return error"
,
func
()
{
So
(
res
.
Results
[
"A"
]
.
Error
.
Error
(),
ShouldContainSubstring
,
"not find"
)
})
_
,
err
:=
HandleRequest
(
req
)
So
(
err
,
ShouldNotBeNil
)
})
Convey
(
"When executing request that depend on other query"
,
t
,
func
()
{
req
:=
&
Request
{
Queries
:
QuerySlice
{
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
Type
:
"test"
}},
{
RefId
:
"B"
,
Query
:
"#A / 2"
,
DataSource
:
&
DataSourceInfo
{
Id
:
2
,
Type
:
"test"
},
Depends
:
[]
string
{
"A"
},
{
RefId
:
"A"
,
Query
:
"asd"
,
DataSource
:
&
DataSourceInfo
{
Id
:
1
,
PluginId
:
"test"
},
},
{
RefId
:
"B"
,
Query
:
"#A / 2"
,
DataSource
:
&
DataSourceInfo
{
Id
:
2
,
PluginId
:
"test"
},
Depends
:
[]
string
{
"A"
},
},
},
}
...
...
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