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
db8bbe3c
Commit
db8bbe3c
authored
Sep 28, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: unit test group by and aggregation dropdown changes
parent
3572692f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
6 deletions
+36
-6
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
+7
-4
public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
+29
-2
No files found.
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
View file @
db8bbe3c
...
...
@@ -62,14 +62,12 @@ export class StackdriverAggregationCtrl {
});
if
(
!
this
.
aggOptions
.
find
(
o
=>
o
.
value
===
this
.
target
.
aggregation
.
crossSeriesReducer
))
{
const
newValue
=
this
.
aggOptions
.
find
(
o
=>
o
.
value
!==
'REDUCE_NONE'
);
this
.
target
.
aggregation
.
crossSeriesReducer
=
newValue
?
newValue
.
value
:
''
;
this
.
deselectAggregationOption
(
'REDUCE_NONE'
);
}
if
(
this
.
target
.
aggregation
.
groupBys
.
length
>
0
)
{
this
.
aggOptions
=
this
.
aggOptions
.
filter
(
o
=>
o
.
value
!==
'REDUCE_NONE'
);
const
newValue
=
this
.
aggOptions
.
find
(
o
=>
o
.
value
!==
'REDUCE_NONE'
);
this
.
target
.
aggregation
.
crossSeriesReducer
=
newValue
?
newValue
.
value
:
''
;
this
.
deselectAggregationOption
(
'REDUCE_NONE'
);
}
}
...
...
@@ -77,6 +75,11 @@ export class StackdriverAggregationCtrl {
const
selectedAlignment
=
this
.
alignOptions
.
find
(
ap
=>
ap
.
value
===
this
.
target
.
aggregation
.
perSeriesAligner
);
return
`
${
kbn
.
secondsToHms
(
this
.
$scope
.
alignmentPeriod
)}
interval (
${
selectedAlignment
.
text
}
)`
;
}
deselectAggregationOption
(
notValidOptionValue
:
string
)
{
const
newValue
=
this
.
aggOptions
.
find
(
o
=>
o
.
value
!==
notValidOptionValue
);
this
.
target
.
aggregation
.
crossSeriesReducer
=
newValue
?
newValue
.
value
:
''
;
}
}
angular
.
module
(
'grafana.controllers'
).
directive
(
'stackdriverAggregation'
,
StackdriverAggregation
);
...
...
public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
View file @
db8bbe3c
...
...
@@ -4,11 +4,11 @@ describe('StackdriverAggregationCtrl', () => {
let
ctrl
;
describe
(
'aggregation and alignment options'
,
()
=>
{
describe
(
'when new query result is returned from the server'
,
()
=>
{
describe
(
'and result is double and gauge'
,
()
=>
{
describe
(
'and result is double and gauge
and no group by is used
'
,
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
=
new
StackdriverAggregationCtrl
({
$on
:
()
=>
{},
target
:
{
valueType
:
'DOUBLE'
,
metricKind
:
'GAUGE'
,
aggregation
:
{
crossSeriesReducer
:
''
}
},
target
:
{
valueType
:
'DOUBLE'
,
metricKind
:
'GAUGE'
,
aggregation
:
{
crossSeriesReducer
:
''
,
groupBys
:
[]
}
},
});
});
...
...
@@ -28,6 +28,33 @@ describe('StackdriverAggregationCtrl', () => {
);
});
});
describe
(
'and result is double and gauge and a group by is used'
,
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
=
new
StackdriverAggregationCtrl
({
$on
:
()
=>
{},
target
:
{
valueType
:
'DOUBLE'
,
metricKind
:
'GAUGE'
,
aggregation
:
{
crossSeriesReducer
:
'REDUCE_NONE'
,
groupBys
:
[
'resource.label.projectid'
]
},
},
});
});
it
(
'should populate all aggregate options except three'
,
()
=>
{
ctrl
.
setAggOptions
();
expect
(
ctrl
.
aggOptions
.
length
).
toBe
(
10
);
expect
(
ctrl
.
aggOptions
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
,
'REDUCE_NONE'
])
);
});
it
(
'should select some other reducer than REDUCE_NONE'
,
()
=>
{
ctrl
.
setAggOptions
();
expect
(
ctrl
.
target
.
aggregation
.
crossSeriesReducer
).
not
.
toBe
(
''
);
expect
(
ctrl
.
target
.
aggregation
.
crossSeriesReducer
).
not
.
toBe
(
'REDUCE_NONE'
);
});
});
});
});
});
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