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
04029a94
Commit
04029a94
authored
Jun 14, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Karma to Jest: elastic_response
parent
71b03267
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
104 deletions
+104
-104
public/app/plugins/datasource/elasticsearch/specs/elastic_response.jest.ts
+104
-104
No files found.
public/app/plugins/datasource/elasticsearch/specs/elastic_response
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/elastic_response
.jest
.ts
View file @
04029a94
import
{
describe
,
beforeEach
,
it
,
expect
}
from
'test/lib/common'
;
import
{
ElasticResponse
}
from
'../elastic_response'
;
describe
(
'ElasticResponse'
,
function
()
{
describe
(
'ElasticResponse'
,
()
=>
{
var
targets
;
var
response
;
var
result
;
describe
(
'simple query and count'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'simple query and count'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -39,19 +39,19 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 1 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'Count'
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
.
b
e
(
1000
);
it
(
'should return 1 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'Count'
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
B
e
(
1000
);
});
});
describe
(
'simple query count & avg aggregation'
,
function
()
{
describe
(
'simple query count & avg aggregation'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -85,22 +85,22 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
.
b
e
(
1000
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'Average value'
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
.
b
e
(
88
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
.
b
e
(
99
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'Average value'
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
B
e
(
88
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
B
e
(
99
);
});
});
describe
(
'single group by query one metric'
,
function
()
{
describe
(
'single group by query one metric'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -141,18 +141,18 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server2'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server2'
);
});
});
describe
(
'single group by query two metrics'
,
function
()
{
describe
(
'single group by query two metrics'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -199,20 +199,20 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1 Count'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server1 Average @value'
);
expect
(
result
.
data
[
2
].
target
).
to
.
b
e
(
'server2 Count'
);
expect
(
result
.
data
[
3
].
target
).
to
.
b
e
(
'server2 Average @value'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1 Count'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server1 Average @value'
);
expect
(
result
.
data
[
2
].
target
).
to
B
e
(
'server2 Count'
);
expect
(
result
.
data
[
3
].
target
).
to
B
e
(
'server2 Average @value'
);
});
});
describe
(
'with percentiles '
,
function
()
{
describe
(
'with percentiles '
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -246,21 +246,21 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'p75'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'p90'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
3.3
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
.
b
e
(
1000
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
.
b
e
(
4.5
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'p75'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'p90'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
3.3
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
B
e
(
4.5
);
});
});
describe
(
'with extended_stats'
,
function
()
{
describe
(
'with extended_stats'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -322,21 +322,21 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 4 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1 Max'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server1 Std Dev Upper'
);
it
(
'should return 4 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1 Max'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server1 Std Dev Upper'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
10.2
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
.
b
e
(
3
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
10.2
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
B
e
(
3
);
});
});
describe
(
'single group by with alias pattern'
,
function
()
{
describe
(
'single group by with alias pattern'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -385,19 +385,19 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
3
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1 Count and {{not_exist}} server1'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server2 Count and {{not_exist}} server2'
);
expect
(
result
.
data
[
2
].
target
).
to
.
b
e
(
'0 Count and {{not_exist}} 0'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
3
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1 Count and {{not_exist}} server1'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server2 Count and {{not_exist}} server2'
);
expect
(
result
.
data
[
2
].
target
).
to
B
e
(
'0 Count and {{not_exist}} 0'
);
});
});
describe
(
'histogram response'
,
function
()
{
describe
(
'histogram response'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -420,16 +420,16 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return table with byte and count'
,
function
()
{
expect
(
result
.
data
[
0
].
rows
.
length
).
to
.
b
e
(
3
);
it
(
'should return table with byte and count'
,
()
=>
{
expect
(
result
.
data
[
0
].
rows
.
length
).
to
B
e
(
3
);
expect
(
result
.
data
[
0
].
columns
).
to
.
eql
([{
text
:
'bytes'
,
filterable
:
true
},
{
text
:
'Count'
}]);
});
});
describe
(
'with two filters agg'
,
function
()
{
describe
(
'with two filters agg'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -472,16 +472,16 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'@metric:cpu'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'@metric:logins.count'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'@metric:cpu'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'@metric:logins.count'
);
});
});
describe
(
'with dropfirst and last aggregation'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'with dropfirst and last aggregation'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -528,14 +528,14 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should remove first and last value'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
1
);
it
(
'should remove first and last value'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
1
);
});
});
describe
(
'No group by time'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'No group by time'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -570,21 +570,21 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return table'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
.
b
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
rows
[
0
][
0
]).
to
.
b
e
(
'server-1'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
.
b
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
.
b
e
(
369
);
it
(
'should return table'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
B
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
rows
[
0
][
0
]).
to
B
e
(
'server-1'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
B
e
(
369
);
expect
(
result
.
data
[
0
].
rows
[
1
][
0
]).
to
.
b
e
(
'server-2'
);
expect
(
result
.
data
[
0
].
rows
[
1
][
1
]).
to
.
b
e
(
2000
);
expect
(
result
.
data
[
0
].
rows
[
1
][
0
]).
to
B
e
(
'server-2'
);
expect
(
result
.
data
[
0
].
rows
[
1
][
1
]).
to
B
e
(
2000
);
});
});
describe
(
'Multiple metrics of same type'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'Multiple metrics of same type'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -615,15 +615,15 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should include field in metric name'
,
function
()
{
expect
(
result
.
data
[
0
].
type
).
to
.
b
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
.
b
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
.
b
e
(
3000
);
it
(
'should include field in metric name'
,
()
=>
{
expect
(
result
.
data
[
0
].
type
).
to
B
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
B
e
(
3000
);
});
});
describe
(
'Raw documents query'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'Raw documents query'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -657,13 +657,13 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return docs'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
.
b
e
(
'docs'
);
expect
(
result
.
data
[
0
].
total
).
to
.
b
e
(
100
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
sourceProp
).
to
.
b
e
(
'asd'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
fieldProp
).
to
.
b
e
(
'field'
);
it
(
'should return docs'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
B
e
(
'docs'
);
expect
(
result
.
data
[
0
].
total
).
to
B
e
(
100
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
sourceProp
).
to
B
e
(
'asd'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
fieldProp
).
to
B
e
(
'field'
);
});
});
});
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