mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
More work on restoring features after moving to plugin model for datasources, no annotations work again #1276 #1472
This commit is contained in:
parent
4a72c37fc1
commit
232f980c72
@ -38,6 +38,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
|
|||||||
|
|
||||||
var dsMap = map[string]interface{}{
|
var dsMap = map[string]interface{}{
|
||||||
"type": ds.Type,
|
"type": ds.Type,
|
||||||
|
"name": ds.Name,
|
||||||
"url": url,
|
"url": url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-include src="currentDatasource.editorSrc">
|
<div ng-include src="currentDatasource.meta.partials.annotations">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
@ -45,5 +45,5 @@
|
|||||||
|
|
||||||
<div class="editor-row">
|
<div class="editor-row">
|
||||||
<br>
|
<br>
|
||||||
<button class="btn btn-success" ng-click="addLink()">Add link</button>
|
<button class="btn btn-inverse" ng-click="addLink()"><i class="fa fa-plus"></i> Add link</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
"partials": {
|
"partials": {
|
||||||
"config": "app/plugins/datasource/elasticsearch/partials/config.html",
|
"config": "app/plugins/datasource/elasticsearch/partials/config.html",
|
||||||
"annotations": "app/plugins/datasource/elasticsearch/partials/query.editor.html"
|
"annotations": "app/plugins/datasource/elasticsearch/partials/annotations.editor.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
"annotations": true
|
"annotations": true
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"partials": {
|
"partials": {
|
||||||
"config": "app/plugins/datasource/graphite/partials/config.html",
|
"config": "app/plugins/datasource/graphite/partials/config.html",
|
||||||
"query": "app/plugins/datasource/graphite/partials/query.editor.html",
|
"query": "app/plugins/datasource/graphite/partials/query.editor.html",
|
||||||
"annotations": "app/plugins/datasource/graphite/partials/query.editor.html"
|
"annotations": "app/plugins/datasource/graphite/partials/annotations.editor.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
"metrics": true,
|
"metrics": true,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"partials": {
|
"partials": {
|
||||||
"config": "app/plugins/datasource/influxdb/partials/config.html",
|
"config": "app/plugins/datasource/influxdb/partials/config.html",
|
||||||
"query": "app/plugins/datasource/influxdb/partials/query.editor.html",
|
"query": "app/plugins/datasource/influxdb/partials/query.editor.html",
|
||||||
"annotations": "app/plugins/datasource/influxdb/partials/query.editor.html"
|
"annotations": "app/plugins/datasource/influxdb/partials/annotations.editor.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
"metrics": true,
|
"metrics": true,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"partials": {
|
"partials": {
|
||||||
"config": "app/plugins/datasource/influxdb_08/partials/config.html",
|
"config": "app/plugins/datasource/influxdb_08/partials/config.html",
|
||||||
"query": "app/plugins/datasource/influxdb_08/partials/query.editor.html",
|
"query": "app/plugins/datasource/influxdb_08/partials/query.editor.html",
|
||||||
"annotations": "app/plugins/datasource/influxdb_08/partials/query.editor.html"
|
"annotations": "app/plugins/datasource/influxdb_08/partials/annotations.editor.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
"metrics": true,
|
"metrics": true,
|
||||||
|
@ -20,13 +20,15 @@ function (angular, _, config) {
|
|||||||
|
|
||||||
_.each(config.datasources, function(value, key) {
|
_.each(config.datasources, function(value, key) {
|
||||||
if (value.meta && value.meta.metrics) {
|
if (value.meta && value.meta.metrics) {
|
||||||
self.metricSources.push({ value: key, name: key });
|
self.metricSources.push({
|
||||||
|
value: key === config.defaultDatasource ? null : key,
|
||||||
|
name: key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (value.meta && value.meta.annotations) {
|
||||||
|
self.annotationSources.push(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!config.defaultDatasource) {
|
|
||||||
$rootScope.appEvent('alert-error', ["No default data source found", ""]);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.get = function(name) {
|
this.get = function(name) {
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
define([
|
define([
|
||||||
'features/influxdb/queryBuilder'
|
'plugins/datasource/influxdb_08/queryBuilder'
|
||||||
], function(/*InfluxQueryBuilder*/) {
|
], function(InfluxQueryBuilder) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// describe('InfluxQueryBuilder', function() {
|
describe('InfluxQueryBuilder', function() {
|
||||||
//
|
|
||||||
// describe('series with conditon and group by', function() {
|
describe('series with conditon and group by', function() {
|
||||||
// var builder = new InfluxQueryBuilder({
|
var builder = new InfluxQueryBuilder({
|
||||||
// series: 'google.test',
|
series: 'google.test',
|
||||||
// column: 'value',
|
column: 'value',
|
||||||
// function: 'mean',
|
function: 'mean',
|
||||||
// condition: "code=1",
|
condition: "code=1",
|
||||||
// groupby_field: 'code'
|
groupby_field: 'code'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var query = builder.build();
|
var query = builder.build();
|
||||||
//
|
|
||||||
// it('should generate correct query', function() {
|
it('should generate correct query', function() {
|
||||||
// expect(query).to.be('select code, mean(value) from "google.test" where $timeFilter and code=1 ' +
|
expect(query).to.be('select code, mean(value) from "google.test" where $timeFilter and code=1 ' +
|
||||||
// 'group by time($interval), code order asc');
|
'group by time($interval), code order asc');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('should expose groupByFiled', function() {
|
it('should expose groupByFiled', function() {
|
||||||
// expect(builder.groupByField).to.be('code');
|
expect(builder.groupByField).to.be('code');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('series with fill and minimum group by time', function() {
|
describe('series with fill and minimum group by time', function() {
|
||||||
// var builder = new InfluxQueryBuilder({
|
var builder = new InfluxQueryBuilder({
|
||||||
// series: 'google.test',
|
series: 'google.test',
|
||||||
// column: 'value',
|
column: 'value',
|
||||||
// function: 'mean',
|
function: 'mean',
|
||||||
// fill: '0',
|
fill: '0',
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var query = builder.build();
|
var query = builder.build();
|
||||||
//
|
|
||||||
// it('should generate correct query', function() {
|
it('should generate correct query', function() {
|
||||||
// expect(query).to.be('select mean(value) from "google.test" where $timeFilter ' +
|
expect(query).to.be('select mean(value) from "google.test" where $timeFilter ' +
|
||||||
// 'group by time($interval) fill(0) order asc');
|
'group by time($interval) fill(0) order asc');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('merge function detection', function() {
|
describe('merge function detection', function() {
|
||||||
// it('should not quote wrap regex merged series', function() {
|
it('should not quote wrap regex merged series', function() {
|
||||||
// var builder = new InfluxQueryBuilder({
|
var builder = new InfluxQueryBuilder({
|
||||||
// series: 'merge(/^google.test/)',
|
series: 'merge(/^google.test/)',
|
||||||
// column: 'value',
|
column: 'value',
|
||||||
// function: 'mean'
|
function: 'mean'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var query = builder.build();
|
var query = builder.build();
|
||||||
//
|
|
||||||
// expect(query).to.be('select mean(value) from merge(/^google.test/) where $timeFilter ' +
|
expect(query).to.be('select mean(value) from merge(/^google.test/) where $timeFilter ' +
|
||||||
// 'group by time($interval) order asc');
|
'group by time($interval) order asc');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('should quote wrap series names that start with "merge"', function() {
|
it('should quote wrap series names that start with "merge"', function() {
|
||||||
// var builder = new InfluxQueryBuilder({
|
var builder = new InfluxQueryBuilder({
|
||||||
// series: 'merge.google.test',
|
series: 'merge.google.test',
|
||||||
// column: 'value',
|
column: 'value',
|
||||||
// function: 'mean'
|
function: 'mean'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var query = builder.build();
|
var query = builder.build();
|
||||||
//
|
|
||||||
// expect(query).to.be('select mean(value) from "merge.google.test" where $timeFilter ' +
|
expect(query).to.be('select mean(value) from "merge.google.test" where $timeFilter ' +
|
||||||
// 'group by time($interval) order asc');
|
'group by time($interval) order asc');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,220 +1,220 @@
|
|||||||
define([
|
define([
|
||||||
'features/influxdb/influxSeries'
|
'plugins/datasource/influxdb_08/influxSeries'
|
||||||
], function(/*InfluxSeries*/) {
|
], function(InfluxSeries) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// describe('when generating timeseries from influxdb response', function() {
|
describe('when generating timeseries from influxdb response', function() {
|
||||||
//
|
|
||||||
// describe('given two series', function() {
|
describe('given two series', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'sequence_number'],
|
columns: ['time', 'mean', 'sequence_number'],
|
||||||
// name: 'prod.server1.cpu',
|
name: 'prod.server1.cpu',
|
||||||
// points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'sequence_number'],
|
columns: ['time', 'mean', 'sequence_number'],
|
||||||
// name: 'prod.server2.cpu',
|
name: 'prod.server2.cpu',
|
||||||
// points: [[1402596000, 15, 1], [1402596001, 16, 2]]
|
points: [[1402596000, 15, 1], [1402596001, 16, 2]]
|
||||||
// }
|
}
|
||||||
// ]
|
]
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getTimeSeries();
|
var result = series.getTimeSeries();
|
||||||
//
|
|
||||||
// it('should generate two time series', function() {
|
it('should generate two time series', function() {
|
||||||
// expect(result.length).to.be(2);
|
expect(result.length).to.be(2);
|
||||||
// expect(result[0].target).to.be('prod.server1.cpu.mean');
|
expect(result[0].target).to.be('prod.server1.cpu.mean');
|
||||||
// expect(result[0].datapoints[0][0]).to.be(10);
|
expect(result[0].datapoints[0][0]).to.be(10);
|
||||||
// expect(result[0].datapoints[0][1]).to.be(1402596000);
|
expect(result[0].datapoints[0][1]).to.be(1402596000);
|
||||||
// expect(result[0].datapoints[1][0]).to.be(12);
|
expect(result[0].datapoints[1][0]).to.be(12);
|
||||||
// expect(result[0].datapoints[1][1]).to.be(1402596001);
|
expect(result[0].datapoints[1][1]).to.be(1402596001);
|
||||||
//
|
|
||||||
// expect(result[1].target).to.be('prod.server2.cpu.mean');
|
expect(result[1].target).to.be('prod.server2.cpu.mean');
|
||||||
// expect(result[1].datapoints[0][0]).to.be(15);
|
expect(result[1].datapoints[0][0]).to.be(15);
|
||||||
// expect(result[1].datapoints[0][1]).to.be(1402596000);
|
expect(result[1].datapoints[0][1]).to.be(1402596000);
|
||||||
// expect(result[1].datapoints[1][0]).to.be(16);
|
expect(result[1].datapoints[1][0]).to.be(16);
|
||||||
// expect(result[1].datapoints[1][1]).to.be(1402596001);
|
expect(result[1].datapoints[1][1]).to.be(1402596001);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('given an alias format', function() {
|
describe('given an alias format', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'sequence_number'],
|
columns: ['time', 'mean', 'sequence_number'],
|
||||||
// name: 'prod.server1.cpu',
|
name: 'prod.server1.cpu',
|
||||||
// points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// alias: '$s.testing'
|
alias: '$s.testing'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getTimeSeries();
|
var result = series.getTimeSeries();
|
||||||
//
|
|
||||||
// it('should generate correct series name', function() {
|
it('should generate correct series name', function() {
|
||||||
// expect(result[0].target).to.be('prod.server1.cpu.testing');
|
expect(result[0].target).to.be('prod.server1.cpu.testing');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('given an alias format with segment numbers', function() {
|
describe('given an alias format with segment numbers', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'sequence_number'],
|
columns: ['time', 'mean', 'sequence_number'],
|
||||||
// name: 'prod.server1.cpu',
|
name: 'prod.server1.cpu',
|
||||||
// points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// alias: '$1.mean'
|
alias: '$1.mean'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getTimeSeries();
|
var result = series.getTimeSeries();
|
||||||
//
|
|
||||||
// it('should generate correct series name', function() {
|
it('should generate correct series name', function() {
|
||||||
// expect(result[0].target).to.be('server1.mean');
|
expect(result[0].target).to.be('server1.mean');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('given an alias format and many segments', function() {
|
describe('given an alias format and many segments', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'sequence_number'],
|
columns: ['time', 'mean', 'sequence_number'],
|
||||||
// name: 'a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12',
|
name: 'a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12',
|
||||||
// points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// alias: '$5.$11.mean'
|
alias: '$5.$11.mean'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getTimeSeries();
|
var result = series.getTimeSeries();
|
||||||
//
|
|
||||||
// it('should generate correct series name', function() {
|
it('should generate correct series name', function() {
|
||||||
// expect(result[0].target).to.be('a5.a11.mean');
|
expect(result[0].target).to.be('a5.a11.mean');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
//
|
|
||||||
// describe('given an alias format with group by field', function() {
|
describe('given an alias format with group by field', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'host'],
|
columns: ['time', 'mean', 'host'],
|
||||||
// name: 'prod.cpu',
|
name: 'prod.cpu',
|
||||||
// points: [[1402596000, 10, 'A']]
|
points: [[1402596000, 10, 'A']]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// groupByField: 'host',
|
groupByField: 'host',
|
||||||
// alias: '$g.$1'
|
alias: '$g.$1'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getTimeSeries();
|
var result = series.getTimeSeries();
|
||||||
//
|
|
||||||
// it('should generate correct series name', function() {
|
it('should generate correct series name', function() {
|
||||||
// expect(result[0].target).to.be('A.cpu');
|
expect(result[0].target).to.be('A.cpu');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('given group by column', function() {
|
describe('given group by column', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'mean', 'host'],
|
columns: ['time', 'mean', 'host'],
|
||||||
// name: 'prod.cpu',
|
name: 'prod.cpu',
|
||||||
// points: [
|
points: [
|
||||||
// [1402596000, 10, 'A'],
|
[1402596000, 10, 'A'],
|
||||||
// [1402596001, 11, 'A'],
|
[1402596001, 11, 'A'],
|
||||||
// [1402596000, 5, 'B'],
|
[1402596000, 5, 'B'],
|
||||||
// [1402596001, 6, 'B'],
|
[1402596001, 6, 'B'],
|
||||||
// ]
|
]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// groupByField: 'host'
|
groupByField: 'host'
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getTimeSeries();
|
var result = series.getTimeSeries();
|
||||||
//
|
|
||||||
// it('should generate two time series', function() {
|
it('should generate two time series', function() {
|
||||||
// expect(result.length).to.be(2);
|
expect(result.length).to.be(2);
|
||||||
// expect(result[0].target).to.be('prod.cpu.A');
|
expect(result[0].target).to.be('prod.cpu.A');
|
||||||
// expect(result[0].datapoints[0][0]).to.be(10);
|
expect(result[0].datapoints[0][0]).to.be(10);
|
||||||
// expect(result[0].datapoints[0][1]).to.be(1402596000);
|
expect(result[0].datapoints[0][1]).to.be(1402596000);
|
||||||
// expect(result[0].datapoints[1][0]).to.be(11);
|
expect(result[0].datapoints[1][0]).to.be(11);
|
||||||
// expect(result[0].datapoints[1][1]).to.be(1402596001);
|
expect(result[0].datapoints[1][1]).to.be(1402596001);
|
||||||
//
|
|
||||||
// expect(result[1].target).to.be('prod.cpu.B');
|
expect(result[1].target).to.be('prod.cpu.B');
|
||||||
// expect(result[1].datapoints[0][0]).to.be(5);
|
expect(result[1].datapoints[0][0]).to.be(5);
|
||||||
// expect(result[1].datapoints[0][1]).to.be(1402596000);
|
expect(result[1].datapoints[0][1]).to.be(1402596000);
|
||||||
// expect(result[1].datapoints[1][0]).to.be(6);
|
expect(result[1].datapoints[1][0]).to.be(6);
|
||||||
// expect(result[1].datapoints[1][1]).to.be(1402596001);
|
expect(result[1].datapoints[1][1]).to.be(1402596001);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe("when creating annotations from influxdb response", function() {
|
describe("when creating annotations from influxdb response", function() {
|
||||||
// describe('given column mapping for all columns', function() {
|
describe('given column mapping for all columns', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'text', 'sequence_number', 'title', 'tags'],
|
columns: ['time', 'text', 'sequence_number', 'title', 'tags'],
|
||||||
// name: 'events1',
|
name: 'events1',
|
||||||
// points: [[1402596000000, 'some text', 1, 'Hello', 'B'], [1402596001000, 'asd', 2, 'Hello2', 'B']]
|
points: [[1402596000000, 'some text', 1, 'Hello', 'B'], [1402596001000, 'asd', 2, 'Hello2', 'B']]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// annotation: {
|
annotation: {
|
||||||
// query: 'select',
|
query: 'select',
|
||||||
// titleColumn: 'title',
|
titleColumn: 'title',
|
||||||
// tagsColumn: 'tags',
|
tagsColumn: 'tags',
|
||||||
// textColumn: 'text',
|
textColumn: 'text',
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getAnnotations();
|
var result = series.getAnnotations();
|
||||||
//
|
|
||||||
// it(' should generate 2 annnotations ', function() {
|
it(' should generate 2 annnotations ', function() {
|
||||||
// expect(result.length).to.be(2);
|
expect(result.length).to.be(2);
|
||||||
// expect(result[0].annotation.query).to.be('select');
|
expect(result[0].annotation.query).to.be('select');
|
||||||
// expect(result[0].title).to.be('Hello');
|
expect(result[0].title).to.be('Hello');
|
||||||
// expect(result[0].time).to.be(1402596000000);
|
expect(result[0].time).to.be(1402596000000);
|
||||||
// expect(result[0].tags).to.be('B');
|
expect(result[0].tags).to.be('B');
|
||||||
// expect(result[0].text).to.be('some text');
|
expect(result[0].text).to.be('some text');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('given no column mapping', function() {
|
describe('given no column mapping', function() {
|
||||||
// var series = new InfluxSeries({
|
var series = new InfluxSeries({
|
||||||
// seriesList: [
|
seriesList: [
|
||||||
// {
|
{
|
||||||
// columns: ['time', 'text', 'sequence_number'],
|
columns: ['time', 'text', 'sequence_number'],
|
||||||
// name: 'events1',
|
name: 'events1',
|
||||||
// points: [[1402596000000, 'some text', 1]]
|
points: [[1402596000000, 'some text', 1]]
|
||||||
// }
|
}
|
||||||
// ],
|
],
|
||||||
// annotation: { query: 'select' }
|
annotation: { query: 'select' }
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// var result = series.getAnnotations();
|
var result = series.getAnnotations();
|
||||||
//
|
|
||||||
// it('should generate 1 annnotation', function() {
|
it('should generate 1 annnotation', function() {
|
||||||
// expect(result.length).to.be(1);
|
expect(result.length).to.be(1);
|
||||||
// expect(result[0].title).to.be('some text');
|
expect(result[0].title).to.be('some text');
|
||||||
// expect(result[0].time).to.be(1402596000000);
|
expect(result[0].time).to.be(1402596000000);
|
||||||
// expect(result[0].tags).to.be(undefined);
|
expect(result[0].tags).to.be(undefined);
|
||||||
// expect(result[0].text).to.be(undefined);
|
expect(result[0].text).to.be(undefined);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,100 +1,100 @@
|
|||||||
define([
|
define([
|
||||||
'helpers',
|
'helpers',
|
||||||
'features/influxdb/datasource'
|
'plugins/datasource/influxdb_08/datasource'
|
||||||
], function(/*helpers*/) {
|
], function(helpers) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// describe('InfluxDatasource', function() {
|
describe('InfluxDatasource', function() {
|
||||||
// var ctx = new helpers.ServiceTestContext();
|
var ctx = new helpers.ServiceTestContext();
|
||||||
//
|
|
||||||
// beforeEach(module('grafana.services'));
|
beforeEach(module('grafana.services'));
|
||||||
// beforeEach(ctx.providePhase(['templateSrv']));
|
beforeEach(ctx.providePhase(['templateSrv']));
|
||||||
// beforeEach(ctx.createService('InfluxDatasource'));
|
beforeEach(ctx.createService('InfluxDatasource_08'));
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// ctx.ds = new ctx.service({ url: '', user: 'test', password: 'mupp' });
|
ctx.ds = new ctx.service({ url: '', user: 'test', password: 'mupp' });
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('When querying influxdb with one target using query editor target spec', function() {
|
describe('When querying influxdb with one target using query editor target spec', function() {
|
||||||
// var results;
|
var results;
|
||||||
// var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22"+
|
var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22"+
|
||||||
// "+where+time+%3E+now()-1h+group+by+time(1s)+order+asc";
|
"+where+time+%3E+now()-1h+group+by+time(1s)+order+asc";
|
||||||
// var query = {
|
var query = {
|
||||||
// range: { from: 'now-1h', to: 'now' },
|
range: { from: 'now-1h', to: 'now' },
|
||||||
// targets: [{ series: 'test', column: 'value', function: 'mean' }],
|
targets: [{ series: 'test', column: 'value', function: 'mean' }],
|
||||||
// interval: '1s'
|
interval: '1s'
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// var response = [{
|
var response = [{
|
||||||
// columns: ["time", "sequence_nr", "value"],
|
columns: ["time", "sequence_nr", "value"],
|
||||||
// name: 'test',
|
name: 'test',
|
||||||
// points: [[10, 1, 1]],
|
points: [[10, 1, 1]],
|
||||||
// }];
|
}];
|
||||||
//
|
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// ctx.$httpBackend.expect('GET', urlExpected).respond(response);
|
ctx.$httpBackend.expect('GET', urlExpected).respond(response);
|
||||||
// ctx.ds.query(query).then(function(data) { results = data; });
|
ctx.ds.query(query).then(function(data) { results = data; });
|
||||||
// ctx.$httpBackend.flush();
|
ctx.$httpBackend.flush();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('should generate the correct query', function() {
|
it('should generate the correct query', function() {
|
||||||
// ctx.$httpBackend.verifyNoOutstandingExpectation();
|
ctx.$httpBackend.verifyNoOutstandingExpectation();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('should return series list', function() {
|
it('should return series list', function() {
|
||||||
// expect(results.data.length).to.be(1);
|
expect(results.data.length).to.be(1);
|
||||||
// expect(results.data[0].target).to.be('test.value');
|
expect(results.data[0].target).to.be('test.value');
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('When querying influxdb with one raw query', function() {
|
describe('When querying influxdb with one raw query', function() {
|
||||||
// var results;
|
var results;
|
||||||
// var urlExpected = "/series?p=mupp&q=select+value+from+series"+
|
var urlExpected = "/series?p=mupp&q=select+value+from+series"+
|
||||||
// "+where+time+%3E+now()-1h";
|
"+where+time+%3E+now()-1h";
|
||||||
// var query = {
|
var query = {
|
||||||
// range: { from: 'now-1h', to: 'now' },
|
range: { from: 'now-1h', to: 'now' },
|
||||||
// targets: [{ query: "select value from series where $timeFilter", rawQuery: true }]
|
targets: [{ query: "select value from series where $timeFilter", rawQuery: true }]
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// var response = [];
|
var response = [];
|
||||||
//
|
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// ctx.$httpBackend.expect('GET', urlExpected).respond(response);
|
ctx.$httpBackend.expect('GET', urlExpected).respond(response);
|
||||||
// ctx.ds.query(query).then(function(data) { results = data; });
|
ctx.ds.query(query).then(function(data) { results = data; });
|
||||||
// ctx.$httpBackend.flush();
|
ctx.$httpBackend.flush();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('should generate the correct query', function() {
|
it('should generate the correct query', function() {
|
||||||
// ctx.$httpBackend.verifyNoOutstandingExpectation();
|
ctx.$httpBackend.verifyNoOutstandingExpectation();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// describe('When issuing annotation query', function() {
|
describe('When issuing annotation query', function() {
|
||||||
// var results;
|
var results;
|
||||||
// var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+
|
var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+
|
||||||
// "+where+time+%3E+now()-1h";
|
"+where+time+%3E+now()-1h";
|
||||||
//
|
|
||||||
// var range = { from: 'now-1h', to: 'now' };
|
var range = { from: 'now-1h', to: 'now' };
|
||||||
// var annotation = { query: 'select title from events.$server where $timeFilter' };
|
var annotation = { query: 'select title from events.$server where $timeFilter' };
|
||||||
// var response = [];
|
var response = [];
|
||||||
//
|
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// ctx.templateSrv.replace = function(str) {
|
ctx.templateSrv.replace = function(str) {
|
||||||
// return str.replace('$server', 'backend_01');
|
return str.replace('$server', 'backend_01');
|
||||||
// };
|
};
|
||||||
// ctx.$httpBackend.expect('GET', urlExpected).respond(response);
|
ctx.$httpBackend.expect('GET', urlExpected).respond(response);
|
||||||
// ctx.ds.annotationQuery(annotation, range).then(function(data) { results = data; });
|
ctx.ds.annotationQuery(annotation, range).then(function(data) { results = data; });
|
||||||
// ctx.$httpBackend.flush();
|
ctx.$httpBackend.flush();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('should generate the correct query', function() {
|
it('should generate the correct query', function() {
|
||||||
// ctx.$httpBackend.verifyNoOutstandingExpectation();
|
ctx.$httpBackend.verifyNoOutstandingExpectation();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ define([
|
|||||||
scenario.setupFn();
|
scenario.setupFn();
|
||||||
var ds = {};
|
var ds = {};
|
||||||
ds.metricFindQuery = sinon.stub().returns(ctx.$q.when(scenario.queryResult));
|
ds.metricFindQuery = sinon.stub().returns(ctx.$q.when(scenario.queryResult));
|
||||||
ctx.datasourceSrv.get = sinon.stub().returns(ds);
|
ctx.datasourceSrv.get = sinon.stub().returns(ctx.$q.when(ds));
|
||||||
|
|
||||||
ctx.service.updateOptions(scenario.variable);
|
ctx.service.updateOptions(scenario.variable);
|
||||||
ctx.$rootScope.$digest();
|
ctx.$rootScope.$digest();
|
||||||
|
Loading…
Reference in New Issue
Block a user