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
c2c0cdb4
Commit
c2c0cdb4
authored
Oct 02, 2018
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
6770f2e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
0 deletions
+154
-0
pkg/tsdb/stackdriver/stackdriver_test.go
+42
-0
pkg/tsdb/stackdriver/test-data/3-series-response-distribution.json
+112
-0
No files found.
pkg/tsdb/stackdriver/stackdriver_test.go
View file @
c2c0cdb4
...
...
@@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"math"
"strconv"
"testing"
"time"
...
...
@@ -341,6 +343,46 @@ func TestStackdriver(t *testing.T) {
})
})
})
Convey
(
"when data from query is distribution"
,
func
()
{
data
,
err
:=
loadTestFile
(
"./test-data/3-series-response-distribution.json"
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
data
.
TimeSeries
),
ShouldEqual
,
1
)
res
:=
&
tsdb
.
QueryResult
{
Meta
:
simplejson
.
New
(),
RefId
:
"A"
}
query
:=
&
StackdriverQuery
{
AliasBy
:
"{{bucket}}"
}
err
=
executor
.
parseResponse
(
res
,
data
,
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
res
.
Series
),
ShouldEqual
,
11
)
for
i
:=
0
;
i
<
11
;
i
++
{
if
i
==
0
{
So
(
res
.
Series
[
i
]
.
Name
,
ShouldEqual
,
"0"
)
}
else
{
So
(
res
.
Series
[
i
]
.
Name
,
ShouldEqual
,
strconv
.
FormatInt
(
int64
(
math
.
Pow
(
float64
(
2
),
float64
(
i
-
1
))),
10
))
}
So
(
len
(
res
.
Series
[
i
]
.
Points
),
ShouldEqual
,
3
)
}
Convey
(
"timestamps should be in ascending order"
,
func
()
{
So
(
res
.
Series
[
0
]
.
Points
[
0
][
1
]
.
Float64
,
ShouldEqual
,
1536668940000
)
So
(
res
.
Series
[
0
]
.
Points
[
1
][
1
]
.
Float64
,
ShouldEqual
,
1536669000000
)
So
(
res
.
Series
[
0
]
.
Points
[
2
][
1
]
.
Float64
,
ShouldEqual
,
1536669060000
)
})
Convey
(
"value should be correct"
,
func
()
{
So
(
res
.
Series
[
8
]
.
Points
[
0
][
0
]
.
Float64
,
ShouldEqual
,
1
)
So
(
res
.
Series
[
9
]
.
Points
[
0
][
0
]
.
Float64
,
ShouldEqual
,
1
)
So
(
res
.
Series
[
10
]
.
Points
[
0
][
0
]
.
Float64
,
ShouldEqual
,
1
)
So
(
res
.
Series
[
8
]
.
Points
[
1
][
0
]
.
Float64
,
ShouldEqual
,
0
)
So
(
res
.
Series
[
9
]
.
Points
[
1
][
0
]
.
Float64
,
ShouldEqual
,
0
)
So
(
res
.
Series
[
10
]
.
Points
[
1
][
0
]
.
Float64
,
ShouldEqual
,
1
)
So
(
res
.
Series
[
8
]
.
Points
[
2
][
0
]
.
Float64
,
ShouldEqual
,
0
)
So
(
res
.
Series
[
9
]
.
Points
[
2
][
0
]
.
Float64
,
ShouldEqual
,
1
)
So
(
res
.
Series
[
10
]
.
Points
[
2
][
0
]
.
Float64
,
ShouldEqual
,
0
)
})
})
})
})
}
...
...
pkg/tsdb/stackdriver/test-data/3-series-response-distribution.json
0 → 100644
View file @
c2c0cdb4
{
"timeSeries"
:
[
{
"metric"
:
{
"type"
:
"loadbalancing.googleapis.com
\/
https
\/
backend_latencies"
},
"resource"
:
{
"type"
:
"https_lb_rule"
,
"labels"
:
{
"project_id"
:
"grafana-prod"
}
},
"metricKind"
:
"DELTA"
,
"valueType"
:
"DISTRIBUTION"
,
"points"
:
[
{
"interval"
:
{
"startTime"
:
"2018-09-11T12:30:00Z"
,
"endTime"
:
"2018-09-11T12:31:00Z"
},
"value"
:
{
"distributionValue"
:
{
"count"
:
"1"
,
"bucketOptions"
:
{
"exponentialBuckets"
:
{
"numFiniteBuckets"
:
10
,
"growthFactor"
:
2
,
"scale"
:
1
}
},
"bucketCounts"
:
[
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"1"
,
"0"
]
}
}
},
{
"interval"
:
{
"startTime"
:
"2018-09-11T12:29:00Z"
,
"endTime"
:
"2018-09-11T12:30:00Z"
},
"value"
:
{
"distributionValue"
:
{
"count"
:
"1"
,
"bucketOptions"
:
{
"exponentialBuckets"
:
{
"numFiniteBuckets"
:
10
,
"growthFactor"
:
2
,
"scale"
:
1
}
},
"bucketCounts"
:
[
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"1"
]
}
}
},
{
"interval"
:
{
"startTime"
:
"2018-09-11T12:28:00Z"
,
"endTime"
:
"2018-09-11T12:29:00Z"
},
"value"
:
{
"distributionValue"
:
{
"count"
:
"3"
,
"bucketOptions"
:
{
"exponentialBuckets"
:
{
"numFiniteBuckets"
:
10
,
"growthFactor"
:
2
,
"scale"
:
1
}
},
"bucketCounts"
:
[
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"0"
,
"1"
,
"1"
,
"1"
]
}
}
}
]
}
]
}
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