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
b6c6cc1f
Commit
b6c6cc1f
authored
Dec 12, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update failing tests
parent
615fa6fc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
21 deletions
+56
-21
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
+4
-2
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
+1
-13
public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
+51
-6
No files found.
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
View file @
b6c6cc1f
...
@@ -52,6 +52,7 @@ export class StackdriverAggregationCtrl {
...
@@ -52,6 +52,7 @@ export class StackdriverAggregationCtrl {
}
}
setAlignOptions
()
{
setAlignOptions
()
{
console
.
log
(
'this.target.metricKind'
,
this
.
target
.
metricKind
);
const
alignments
=
getAlignmentOptionsByMetric
(
this
.
target
.
valueType
,
this
.
target
.
metricKind
).
map
(
a
=>
({
const
alignments
=
getAlignmentOptionsByMetric
(
this
.
target
.
valueType
,
this
.
target
.
metricKind
).
map
(
a
=>
({
...
a
,
...
a
,
label
:
a
.
text
,
label
:
a
.
text
,
...
@@ -78,7 +79,7 @@ export class StackdriverAggregationCtrl {
...
@@ -78,7 +79,7 @@ export class StackdriverAggregationCtrl {
}
}
if
(
this
.
target
.
aggregation
.
groupBys
.
length
>
0
)
{
if
(
this
.
target
.
aggregation
.
groupBys
.
length
>
0
)
{
aggregations
=
this
.
aggOp
tions
.
filter
(
o
=>
o
.
value
!==
'REDUCE_NONE'
);
aggregations
=
aggrega
tions
.
filter
(
o
=>
o
.
value
!==
'REDUCE_NONE'
);
this
.
deselectAggregationOption
(
'REDUCE_NONE'
);
this
.
deselectAggregationOption
(
'REDUCE_NONE'
);
}
}
this
.
aggOptions
=
[
this
.
aggOptions
=
[
...
@@ -116,7 +117,8 @@ export class StackdriverAggregationCtrl {
...
@@ -116,7 +117,8 @@ export class StackdriverAggregationCtrl {
}
}
deselectAggregationOption
(
notValidOptionValue
:
string
)
{
deselectAggregationOption
(
notValidOptionValue
:
string
)
{
const
newValue
=
this
.
aggOptions
.
find
(
o
=>
o
.
value
!==
notValidOptionValue
);
const
aggregations
=
getAggregationOptionsByMetric
(
this
.
target
.
valueType
,
this
.
target
.
metricKind
);
const
newValue
=
aggregations
.
find
(
o
=>
o
.
value
!==
notValidOptionValue
);
this
.
target
.
aggregation
.
crossSeriesReducer
=
newValue
?
newValue
.
value
:
''
;
this
.
target
.
aggregation
.
crossSeriesReducer
=
newValue
?
newValue
.
value
:
''
;
}
}
...
...
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
View file @
b6c6cc1f
...
@@ -160,23 +160,11 @@ export class StackdriverFilterCtrl {
...
@@ -160,23 +160,11 @@ export class StackdriverFilterCtrl {
options
:
this
.
templateSrv
.
variables
.
map
(
v
=>
({
options
:
this
.
templateSrv
.
variables
.
map
(
v
=>
({
label
:
`$
${
v
.
name
}
`
,
label
:
`$
${
v
.
name
}
`
,
value
:
`$
${
v
.
name
}
`
,
value
:
`$
${
v
.
name
}
`
,
description
:
`$
${
v
.
definition
}
`
,
//
description: `$${v.definition}`,
})),
})),
};
};
}
}
insertTemplateVariables
(
options
)
{
const
templateVariables
=
{
label
:
'Template Variables'
,
options
:
this
.
templateSrv
.
variables
.
map
(
v
=>
({
label
:
`$
${
v
.
name
}
`
,
value
:
`$
${
v
.
name
}
`
,
description
:
`$
${
v
.
definition
}
`
,
})),
};
return
[
templateVariables
,
{
label
:
'Metrics'
,
options
}];
}
getMetricsList
()
{
getMetricsList
()
{
const
metrics
=
this
.
metricDescriptors
.
map
(
m
=>
{
const
metrics
=
this
.
metricDescriptors
.
map
(
m
=>
{
return
{
return
{
...
...
public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
View file @
b6c6cc1f
...
@@ -17,27 +17,68 @@ describe('StackdriverAggregationCtrl', () => {
...
@@ -17,27 +17,68 @@ describe('StackdriverAggregationCtrl', () => {
},
},
{
{
replace
:
s
=>
s
,
replace
:
s
=>
s
,
variables
:
[{
name
:
'someVariable1'
},
{
name
:
'someVariable2'
}],
}
}
);
);
});
});
it
(
'should populate all aggregate options except two'
,
()
=>
{
it
(
'should populate all aggregate options except two'
,
()
=>
{
ctrl
.
setAggOptions
();
ctrl
.
setAggOptions
();
expect
(
ctrl
.
aggOptions
.
length
).
toBe
(
11
);
expect
(
ctrl
.
aggOptions
.
length
).
toBe
(
2
);
expect
(
ctrl
.
aggOptions
.
map
(
o
=>
o
.
value
)).
toEqual
(
const
[
templateVariableGroup
,
aggOptionsGroup
]
=
ctrl
.
aggOptions
;
expect
(
templateVariableGroup
.
options
.
length
).
toBe
(
2
);
expect
(
aggOptionsGroup
.
options
.
length
).
toBe
(
11
);
expect
(
aggOptionsGroup
.
options
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
])
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
])
);
);
});
});
it
(
'should populate all alignment options except two'
,
()
=>
{
it
(
'should populate all alignment options except two'
,
()
=>
{
ctrl
.
setAlignOptions
();
ctrl
.
setAlignOptions
();
expect
(
ctrl
.
alignOptions
.
length
).
toBe
(
9
);
const
[
templateVariableGroup
,
alignOptionGroup
]
=
ctrl
.
aggOptions
;
expect
(
ctrl
.
alignOptions
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
(
templateVariableGroup
.
options
.
length
).
toBe
(
2
);
expect
(
alignOptionGroup
.
options
.
length
).
toBe
(
11
);
expect
(
alignOptionGroup
.
options
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
])
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
])
);
);
});
});
});
});
describe
(
'and result is double and delta and no group by is used'
,
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
=
new
StackdriverAggregationCtrl
(
{
$on
:
()
=>
{},
target
:
{
valueType
:
'DOUBLE'
,
metricKind
:
'DELTA'
,
aggregation
:
{
crossSeriesReducer
:
''
,
groupBys
:
[]
},
},
},
{
replace
:
s
=>
s
,
variables
:
[{
name
:
'someVariable1'
},
{
name
:
'someVariable2'
}],
}
);
});
it
(
'should populate all alignment options except four'
,
()
=>
{
ctrl
.
setAlignOptions
();
const
[
templateVariableGroup
,
alignOptionGroup
]
=
ctrl
.
alignOptions
;
expect
(
templateVariableGroup
.
options
.
length
).
toBe
(
2
);
expect
(
alignOptionGroup
.
options
.
length
).
toBe
(
9
);
expect
(
alignOptionGroup
.
options
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
[
'not'
].
arrayContaining
([
'ALIGN_NEXT_OLDER'
,
'ALIGN_INTERPOLATE'
,
'ALIGN_COUNT_TRUE'
,
'ALIGN_COUNT_FALSE'
,
'ALIGN_FRACTION_TRUE'
,
])
);
});
});
describe
(
'and result is double and gauge and a group by is used'
,
()
=>
{
describe
(
'and result is double and gauge and a group by is used'
,
()
=>
{
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
=
new
StackdriverAggregationCtrl
(
ctrl
=
new
StackdriverAggregationCtrl
(
...
@@ -51,14 +92,18 @@ describe('StackdriverAggregationCtrl', () => {
...
@@ -51,14 +92,18 @@ describe('StackdriverAggregationCtrl', () => {
},
},
{
{
replace
:
s
=>
s
,
replace
:
s
=>
s
,
variables
:
[{
name
:
'someVariable1'
}],
}
}
);
);
});
});
it
(
'should populate all aggregate options except three'
,
()
=>
{
it
(
'should populate all aggregate options except three'
,
()
=>
{
ctrl
.
setAggOptions
();
ctrl
.
setAggOptions
();
expect
(
ctrl
.
aggOptions
.
length
).
toBe
(
10
);
const
[
templateVariableGroup
,
aggOptionsGroup
]
=
ctrl
.
aggOptions
;
expect
(
ctrl
.
aggOptions
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
(
ctrl
.
aggOptions
.
length
).
toBe
(
2
);
expect
(
templateVariableGroup
.
options
.
length
).
toBe
(
1
);
expect
(
aggOptionsGroup
.
options
.
length
).
toBe
(
10
);
expect
(
aggOptionsGroup
.
options
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
,
'REDUCE_NONE'
])
expect
[
'not'
].
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
,
'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