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
3534762f
Unverified
Commit
3534762f
authored
Nov 21, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cloudwatch: handle invalid time ranges
parent
879aed7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
pkg/tsdb/cloudwatch/cloudwatch.go
+2
-2
pkg/tsdb/cloudwatch/cloudwatch_test.go
+22
-0
No files found.
pkg/tsdb/cloudwatch/cloudwatch.go
View file @
3534762f
...
...
@@ -211,8 +211,8 @@ func (e *CloudWatchExecutor) executeQuery(ctx context.Context, query *CloudWatch
return
nil
,
err
}
if
endTime
.
Before
(
start
Time
)
{
return
nil
,
fmt
.
Errorf
(
"Invalid time range:
End time can't be before start
time"
)
if
!
startTime
.
Before
(
end
Time
)
{
return
nil
,
fmt
.
Errorf
(
"Invalid time range:
Start time must be before end
time"
)
}
params
:=
&
cloudwatch
.
GetMetricStatisticsInput
{
...
...
pkg/tsdb/cloudwatch/cloudwatch_test.go
View file @
3534762f
package
cloudwatch
import
(
"context"
"testing"
"time"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/grafana/grafana/pkg/components/null"
...
...
@@ -14,6 +18,24 @@ import (
func
TestCloudWatch
(
t
*
testing
.
T
)
{
Convey
(
"CloudWatch"
,
t
,
func
()
{
Convey
(
"executeQuery"
,
func
()
{
e
:=
&
CloudWatchExecutor
{
DataSource
:
&
models
.
DataSource
{
JsonData
:
simplejson
.
New
(),
},
}
Convey
(
"End time before start time should result in error"
,
func
()
{
_
,
err
:=
e
.
executeQuery
(
context
.
Background
(),
&
CloudWatchQuery
{},
&
tsdb
.
TsdbQuery
{
TimeRange
:
tsdb
.
NewTimeRange
(
"now-1h"
,
"now-2h"
)})
So
(
err
.
Error
(),
ShouldEqual
,
"Invalid time range: Start time must be before end time"
)
})
Convey
(
"End time equals start time should result in error"
,
func
()
{
_
,
err
:=
e
.
executeQuery
(
context
.
Background
(),
&
CloudWatchQuery
{},
&
tsdb
.
TsdbQuery
{
TimeRange
:
tsdb
.
NewTimeRange
(
"now-1h"
,
"now-1h"
)})
So
(
err
.
Error
(),
ShouldEqual
,
"Invalid time range: Start time must be before end time"
)
})
})
Convey
(
"can parse cloudwatch json model"
,
func
()
{
json
:=
`
{
...
...
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