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
5b968329
Commit
5b968329
authored
Apr 17, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graphite: adds tests for tags and tag_values functions
parent
cfef609c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
3 deletions
+98
-3
public/app/plugins/datasource/graphite/datasource.ts
+3
-3
public/app/plugins/datasource/graphite/specs/datasource_specs.ts
+95
-0
No files found.
public/app/plugins/datasource/graphite/datasource.ts
View file @
5b968329
...
...
@@ -320,7 +320,7 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
method
:
'GET'
,
url
:
'/tags/autoComplete/tags'
,
params
:
{
expr
:
_
.
map
(
expressions
,
expression
=>
templateSrv
.
replace
(
expression
)),
expr
:
_
.
map
(
expressions
,
expression
=>
templateSrv
.
replace
(
(
expression
||
''
).
trim
()
)),
},
// for cancellations
requestId
:
options
.
requestId
,
...
...
@@ -355,8 +355,8 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
method
:
'GET'
,
url
:
'/tags/autoComplete/values'
,
params
:
{
expr
:
_
.
map
(
expressions
,
expression
=>
templateSrv
.
replace
(
expression
)),
tag
:
templateSrv
.
replace
(
tag
),
expr
:
_
.
map
(
expressions
,
expression
=>
templateSrv
.
replace
(
(
expression
||
''
).
trim
()
)),
tag
:
templateSrv
.
replace
(
(
tag
||
''
).
trim
()
),
},
// for cancellations
requestId
:
options
.
requestId
,
...
...
public/app/plugins/datasource/graphite/specs/datasource_specs.ts
View file @
5b968329
...
...
@@ -222,4 +222,99 @@ describe('graphiteDatasource', function() {
expect
(
results
.
length
).
to
.
be
(
2
);
});
});
describe
(
'querying for template variables'
,
()
=>
{
let
results
;
let
requestOptions
;
beforeEach
(()
=>
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
requestOptions
=
options
;
return
ctx
.
$q
.
when
({
data
:
[{
target
:
'prod1.count'
,
datapoints
:
[[
10
,
1
],
[
12
,
1
]]
}],
});
};
});
it
(
'should generate tags query'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tags()'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/tags'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'should generate tags query with a filter expression'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tags(server=backend_01)'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/tags'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([
'server=backend_01'
]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'should generate tag query for an expression with whitespace after'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tags(server=backend_01 )'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/tags'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([
'server=backend_01'
]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'should generate tag values query for one tag'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(server)'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/values'
);
expect
(
requestOptions
.
params
.
tag
).
to
.
be
(
'server'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'should generate tag values query for a tag and expression'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(server,server=~backend*)'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/values'
);
expect
(
requestOptions
.
params
.
tag
).
to
.
be
(
'server'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([
'server=~backend*'
]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'should generate tag values query for a tag with whitespace after'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(server )'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/values'
);
expect
(
requestOptions
.
params
.
tag
).
to
.
be
(
'server'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'should generate tag values query for a tag and expression with whitespace after'
,
()
=>
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(server , server=~backend* )'
).
then
(
data
=>
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/tags/autoComplete/values'
);
expect
(
requestOptions
.
params
.
tag
).
to
.
be
(
'server'
);
expect
(
requestOptions
.
params
.
expr
).
to
.
eql
([
'server=~backend*'
]);
expect
(
results
).
not
.
to
.
be
(
null
);
});
});
});
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