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
1a63d9eb
Commit
1a63d9eb
authored
Sep 29, 2015
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reactivate cloudwatch test
parent
a3748d4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
155 additions
and
155 deletions
+155
-155
public/test/specs/cloudwatch-datasource-specs.js
+155
-155
No files found.
public/test/specs/cloudwatch-datasource-specs.js
View file @
1a63d9eb
//
define([
define
([
//
'./helpers',
'./helpers'
,
//
'app/plugins/datasource/cloudwatch/datasource',
'app/plugins/datasource/cloudwatch/datasource'
,
//
'aws-sdk',
'aws-sdk'
,
//
], function(helpers) {
],
function
(
helpers
)
{
//
'use strict';
'use strict'
;
//
//
describe('CloudWatchDatasource', function() {
describe
(
'CloudWatchDatasource'
,
function
()
{
//
var ctx = new helpers.ServiceTestContext();
var
ctx
=
new
helpers
.
ServiceTestContext
();
//
//
beforeEach(module('grafana.services'));
beforeEach
(
module
(
'grafana.services'
));
//
beforeEach(module('grafana.controllers'));
beforeEach
(
module
(
'grafana.controllers'
));
//
beforeEach(ctx.providePhase(['templateSrv']));
beforeEach
(
ctx
.
providePhase
([
'templateSrv'
]));
//
beforeEach(ctx.createService('CloudWatchDatasource'));
beforeEach
(
ctx
.
createService
(
'CloudWatchDatasource'
));
//
beforeEach(function() {
beforeEach
(
function
()
{
//
ctx.ds = new ctx.service({
ctx
.
ds
=
new
ctx
.
service
({
//
jsonData: {
jsonData
:
{
//
defaultRegion: 'us-east-1',
defaultRegion
:
'us-east-1'
,
//
access: 'proxy'
access
:
'proxy'
//
}
}
//
});
});
//
});
});
//
//
describe('When performing CloudWatch query', function() {
describe
(
'When performing CloudWatch query'
,
function
()
{
//
var requestParams;
var
requestParams
;
//
//
var query = {
var
query
=
{
//
range: { from: 'now-1h', to: 'now' },
range
:
{
from
:
'now-1h'
,
to
:
'now'
},
//
targets: [
targets
:
[
//
{
{
//
region: 'us-east-1',
region
:
'us-east-1'
,
//
namespace: 'AWS/EC2',
namespace
:
'AWS/EC2'
,
//
metricName: 'CPUUtilization',
metricName
:
'CPUUtilization'
,
//
dimensions: {
dimensions
:
{
//
InstanceId: 'i-12345678'
InstanceId
:
'i-12345678'
//
},
},
//
statistics: {
statistics
:
{
//
Average: true
Average
:
true
//
},
},
//
period: 300
period
:
300
//
}
}
//
]
]
//
};
};
//
//
var response = {
var
response
=
{
//
Datapoints: [
Datapoints
:
[
//
{
{
//
Average: 1,
Average
:
1
,
//
Timestamp: 'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)'
Timestamp
:
'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)'
//
}
}
//
],
],
//
Label: 'CPUUtilization'
Label
:
'CPUUtilization'
//
};
};
//
//
beforeEach(function() {
beforeEach
(
function
()
{
//
ctx.ds.getCloudWatchClient = function() {
ctx
.
ds
.
getCloudWatchClient
=
function
()
{
//
return {
return
{
//
getMetricStatistics: function(params, callback) {
getMetricStatistics
:
function
(
params
,
callback
)
{
//
setTimeout(function() {
setTimeout
(
function
()
{
//
requestParams = params;
requestParams
=
params
;
//
callback(null, response);
callback
(
null
,
response
);
//
}, 0);
},
0
);
//
}
}
//
};
};
//
};
};
//
});
});
//
//
it('should generate the correct query', function() {
it
(
'should generate the correct query'
,
function
()
{
//
ctx.ds.query(query).then(function() {
ctx
.
ds
.
query
(
query
).
then
(
function
()
{
//
expect(requestParams.Namespace).to.be(query.targets[0].namespace);
expect
(
requestParams
.
Namespace
).
to
.
be
(
query
.
targets
[
0
].
namespace
);
//
expect(requestParams.MetricName).to.be(query.targets[0].metricName);
expect
(
requestParams
.
MetricName
).
to
.
be
(
query
.
targets
[
0
].
metricName
);
//
expect(requestParams.Dimensions[0].Name).to.be(Object.keys(query.targets[0].dimensions)[0]);
expect
(
requestParams
.
Dimensions
[
0
].
Name
).
to
.
be
(
Object
.
keys
(
query
.
targets
[
0
].
dimensions
)[
0
]);
//
expect(requestParams.Dimensions[0].Value).to.be(query.targets[0].dimensions[Object.keys(query.targets[0].dimensions)[0]]);
expect
(
requestParams
.
Dimensions
[
0
].
Value
).
to
.
be
(
query
.
targets
[
0
].
dimensions
[
Object
.
keys
(
query
.
targets
[
0
].
dimensions
)[
0
]]);
//
expect(requestParams.Statistics).to.eql(Object.keys(query.targets[0].statistics));
expect
(
requestParams
.
Statistics
).
to
.
eql
(
Object
.
keys
(
query
.
targets
[
0
].
statistics
));
//
expect(requestParams.Period).to.be(query.targets[0].period);
expect
(
requestParams
.
Period
).
to
.
be
(
query
.
targets
[
0
].
period
);
//
});
});
//
});
});
//
//
it('should return series list', function() {
it
(
'should return series list'
,
function
()
{
//
ctx.ds.query(query).then(function(result) {
ctx
.
ds
.
query
(
query
).
then
(
function
(
result
)
{
//
var s = Object.keys(query.targets[0].statistics)[0];
var
s
=
Object
.
keys
(
query
.
targets
[
0
].
statistics
)[
0
];
//
expect(result.data[0].target).to.be(response.Label + s);
expect
(
result
.
data
[
0
].
target
).
to
.
be
(
response
.
Label
+
s
);
//
expect(result.data[0].datapoints[0][0]).to.be(response.Datapoints[0][s]);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
be
(
response
.
Datapoints
[
0
][
s
]);
//
});
});
//
});
});
//
});
});
//
//
describe('When performing CloudWatch metricFindQuery', function() {
describe
(
'When performing CloudWatch metricFindQuery'
,
function
()
{
//
var requestParams;
var
requestParams
;
//
//
var response = {
var
response
=
{
//
Metrics: [
Metrics
:
[
//
{
{
//
Namespace: 'AWS/EC2',
Namespace
:
'AWS/EC2'
,
//
MetricName: 'CPUUtilization',
MetricName
:
'CPUUtilization'
,
//
Dimensions: [
Dimensions
:
[
//
{
{
//
Name: 'InstanceId',
Name
:
'InstanceId'
,
//
Value: 'i-12345678'
Value
:
'i-12345678'
//
}
}
//
]
]
//
}
}
//
]
]
//
};
};
//
//
beforeEach(function() {
beforeEach
(
function
()
{
//
ctx.ds.getCloudWatchClient = function() {
ctx
.
ds
.
getCloudWatchClient
=
function
()
{
//
return {
return
{
//
listMetrics: function(params, callback) {
listMetrics
:
function
(
params
,
callback
)
{
//
setTimeout(function() {
setTimeout
(
function
()
{
//
requestParams = params;
requestParams
=
params
;
//
callback(null, response);
callback
(
null
,
response
);
//
}, 0);
},
0
);
//
}
}
//
};
};
//
};
};
//
});
});
//
//
it('should return suggest list for region()', function() {
it
(
'should return suggest list for region()'
,
function
()
{
//
var query = 'region()';
var
query
=
'region()'
;
//
ctx.ds.metricFindQuery(query).then(function(result) {
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
result
)
{
//
expect(result).to.contain('us-east-1');
expect
(
result
).
to
.
contain
(
'us-east-1'
);
//
});
});
//
});
});
//
//
it('should return suggest list for namespace()', function() {
it
(
'should return suggest list for namespace()'
,
function
()
{
//
var query = 'namespace()';
var
query
=
'namespace()'
;
//
ctx.ds.metricFindQuery(query).then(function(result) {
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
result
)
{
//
expect(result).to.contain('AWS/EC2');
expect
(
result
).
to
.
contain
(
'AWS/EC2'
);
//
});
});
//
});
});
//
//
it('should return suggest list for metrics()', function() {
it
(
'should return suggest list for metrics()'
,
function
()
{
//
var query = 'metrics(AWS/EC2)';
var
query
=
'metrics(AWS/EC2)'
;
//
ctx.ds.metricFindQuery(query).then(function(result) {
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
result
)
{
//
expect(result).to.contain('CPUUtilization');
expect
(
result
).
to
.
contain
(
'CPUUtilization'
);
//
});
});
//
});
});
//
//
it('should return suggest list for dimension_keys()', function() {
it
(
'should return suggest list for dimension_keys()'
,
function
()
{
//
var query = 'dimension_keys(AWS/EC2)';
var
query
=
'dimension_keys(AWS/EC2)'
;
//
ctx.ds.metricFindQuery(query).then(function(result) {
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
result
)
{
//
expect(result).to.contain('InstanceId');
expect
(
result
).
to
.
contain
(
'InstanceId'
);
//
});
});
//
});
});
//
//
it('should return suggest list for dimension_values()', function() {
it
(
'should return suggest list for dimension_values()'
,
function
()
{
//
var query = 'dimension_values(us-east-1,AWS/EC2,CPUUtilization)';
var
query
=
'dimension_values(us-east-1,AWS/EC2,CPUUtilization)'
;
//
ctx.ds.metricFindQuery(query).then(function(result) {
ctx
.
ds
.
metricFindQuery
(
query
).
then
(
function
(
result
)
{
//
expect(result).to.contain('InstanceId');
expect
(
result
).
to
.
contain
(
'InstanceId'
);
//
});
});
//
});
});
//
});
});
//
});
});
//
});
});
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