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
45eadae6
Commit
45eadae6
authored
Aug 06, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert datasource
parent
6f1b125c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
105 deletions
+91
-105
public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts
+0
-105
public/app/plugins/datasource/opentsdb/specs/datasource.jest.ts
+91
-0
No files found.
public/app/plugins/datasource/opentsdb/specs/datasource-specs.ts
deleted
100644 → 0
View file @
6f1b125c
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
OpenTsDatasource
from
'../datasource'
;
describe
(
'opentsdb'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
var
instanceSettings
=
{
url
:
''
,
jsonData
:
{
tsdbVersion
:
1
}
};
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
beforeEach
(
angularMocks
.
inject
(
function
(
$q
,
$rootScope
,
$httpBackend
,
$injector
)
{
ctx
.
$q
=
$q
;
ctx
.
$httpBackend
=
$httpBackend
;
ctx
.
$rootScope
=
$rootScope
;
ctx
.
ds
=
$injector
.
instantiate
(
OpenTsDatasource
,
{
instanceSettings
:
instanceSettings
,
});
$httpBackend
.
when
(
'GET'
,
/
\.
html$/
).
respond
(
''
);
})
);
describe
(
'When performing metricFindQuery'
,
function
()
{
var
results
;
var
requestOptions
;
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
requestOptions
=
options
;
return
ctx
.
$q
.
when
({
data
:
[{
target
:
'prod1.count'
,
datapoints
:
[[
10
,
1
],
[
12
,
1
]]
}],
});
};
});
it
(
'metrics() should generate api suggest query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'metrics(pew)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/suggest'
);
expect
(
requestOptions
.
params
.
type
).
to
.
be
(
'metrics'
);
expect
(
requestOptions
.
params
.
q
).
to
.
be
(
'pew'
);
expect
(
results
).
not
.
to
.
be
(
null
);
});
it
(
'tag_names(cpu) should generate lookup query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'tag_names(cpu)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
to
.
be
(
'cpu'
);
});
it
(
'tag_values(cpu, test) should generate lookup query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(cpu, hostname)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
to
.
be
(
'cpu{hostname=*}'
);
});
it
(
'tag_values(cpu, test) should generate lookup query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(cpu, hostname, env=$env)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
to
.
be
(
'cpu{hostname=*,env=$env}'
);
});
it
(
'tag_values(cpu, test) should generate lookup query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'tag_values(cpu, hostname, env=$env, region=$region)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
to
.
be
(
'cpu{hostname=*,env=$env,region=$region}'
);
});
it
(
'suggest_tagk() should generate api suggest query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'suggest_tagk(foo)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/suggest'
);
expect
(
requestOptions
.
params
.
type
).
to
.
be
(
'tagk'
);
expect
(
requestOptions
.
params
.
q
).
to
.
be
(
'foo'
);
});
it
(
'suggest_tagv() should generate api suggest query'
,
function
()
{
ctx
.
ds
.
metricFindQuery
(
'suggest_tagv(bar)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
expect
(
requestOptions
.
url
).
to
.
be
(
'/api/suggest'
);
expect
(
requestOptions
.
params
.
type
).
to
.
be
(
'tagv'
);
expect
(
requestOptions
.
params
.
q
).
to
.
be
(
'bar'
);
});
});
});
public/app/plugins/datasource/opentsdb/specs/datasource.jest.ts
0 → 100644
View file @
45eadae6
import
OpenTsDatasource
from
'../datasource'
;
import
$q
from
'q'
;
describe
(
'opentsdb'
,
()
=>
{
let
ctx
=
<
any
>
{
backendSrv
:
{},
ds
:
{},
templateSrv
:
{
replace
:
str
=>
str
,
},
};
let
instanceSettings
=
{
url
:
''
,
jsonData
:
{
tsdbVersion
:
1
}
};
beforeEach
(()
=>
{
ctx
.
ctrl
=
new
OpenTsDatasource
(
instanceSettings
,
$q
,
ctx
.
backendSrv
,
ctx
.
templateSrv
);
});
describe
(
'When performing metricFindQuery'
,
()
=>
{
var
results
;
var
requestOptions
;
beforeEach
(
async
()
=>
{
ctx
.
backendSrv
.
datasourceRequest
=
await
function
(
options
)
{
requestOptions
=
options
;
return
Promise
.
resolve
({
data
:
[{
target
:
'prod1.count'
,
datapoints
:
[[
10
,
1
],
[
12
,
1
]]
}],
});
};
});
it
(
'metrics() should generate api suggest query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'metrics(pew)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/suggest'
);
expect
(
requestOptions
.
params
.
type
).
toBe
(
'metrics'
);
expect
(
requestOptions
.
params
.
q
).
toBe
(
'pew'
);
expect
(
results
).
not
.
toBe
(
null
);
});
it
(
'tag_names(cpu) should generate lookup query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'tag_names(cpu)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
toBe
(
'cpu'
);
});
it
(
'tag_values(cpu, test) should generate lookup query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'tag_values(cpu, hostname)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
toBe
(
'cpu{hostname=*}'
);
});
it
(
'tag_values(cpu, test) should generate lookup query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'tag_values(cpu, hostname, env=$env)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
toBe
(
'cpu{hostname=*,env=$env}'
);
});
it
(
'tag_values(cpu, test) should generate lookup query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'tag_values(cpu, hostname, env=$env, region=$region)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/search/lookup'
);
expect
(
requestOptions
.
params
.
m
).
toBe
(
'cpu{hostname=*,env=$env,region=$region}'
);
});
it
(
'suggest_tagk() should generate api suggest query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'suggest_tagk(foo)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/suggest'
);
expect
(
requestOptions
.
params
.
type
).
toBe
(
'tagk'
);
expect
(
requestOptions
.
params
.
q
).
toBe
(
'foo'
);
});
it
(
'suggest_tagv() should generate api suggest query'
,
()
=>
{
ctx
.
ctrl
.
metricFindQuery
(
'suggest_tagv(bar)'
).
then
(
function
(
data
)
{
results
=
data
;
});
expect
(
requestOptions
.
url
).
toBe
(
'/api/suggest'
);
expect
(
requestOptions
.
params
.
type
).
toBe
(
'tagv'
);
expect
(
requestOptions
.
params
.
q
).
toBe
(
'bar'
);
});
});
});
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