Commit 15f2b2cf by Torkel Ödegaard

Annotations: fixed InfluxDB annotation query, added unit test for annotation query, Fixes #802

parent bf9eaea3
# 1.8.0 (unreleased) # 1.8.0 (2014-09-12)
**Fixes**
- [Issue #802](https://github.com/grafana/grafana/issues/802). Annotations: Fix when using InfluxDB datasource
# 1.8.0-RC1 (2014-09-12)
**UI polish / changes** **UI polish / changes**
- [Issue #725](https://github.com/grafana/grafana/issues/725). UI: All modal editors are removed and replaced by an edit pane under menu. The look of editors is also updated and polished. Search dropdown is also shown as pane under menu and has seen some UI polish. - [Issue #725](https://github.com/grafana/grafana/issues/725). UI: All modal editors are removed and replaced by an edit pane under menu. The look of editors is also updated and polished. Search dropdown is also shown as pane under menu and has seen some UI polish.
......
...@@ -64,7 +64,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { ...@@ -64,7 +64,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
InfluxDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) { InfluxDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) {
var timeFilter = getTimeFilter({ range: rangeUnparsed }); var timeFilter = getTimeFilter({ range: rangeUnparsed });
var query = annotation.query.replace('$timeFilter', timeFilter); var query = annotation.query.replace('$timeFilter', timeFilter);
query = templateSrv.replace(annotation.query); query = templateSrv.replace(query);
return this._seriesQuery(query).then(function(results) { return this._seriesQuery(query).then(function(results) {
return new InfluxSeries({ seriesList: results, annotation: annotation }).getAnnotations(); return new InfluxSeries({ seriesList: results, annotation: annotation }).getAnnotations();
......
...@@ -8,7 +8,7 @@ define([ ...@@ -8,7 +8,7 @@ define([
var ctx = new helpers.ServiceTestContext(); var ctx = new helpers.ServiceTestContext();
beforeEach(module('grafana.services')); beforeEach(module('grafana.services'));
beforeEach(ctx.providePhase()); beforeEach(ctx.providePhase(['templateSrv']));
beforeEach(ctx.createService('InfluxDatasource')); beforeEach(ctx.createService('InfluxDatasource'));
beforeEach(function() { beforeEach(function() {
ctx.ds = new ctx.service({ urls: [''], user: 'test', password: 'mupp' }); ctx.ds = new ctx.service({ urls: [''], user: 'test', password: 'mupp' });
...@@ -70,6 +70,30 @@ define([ ...@@ -70,6 +70,30 @@ define([
}); });
describe('When issuing annotation query', function() {
var results;
var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+
"+where+time+%3E+now()+-+1h&time_precision=s";
var range = { from: 'now-1h', to: 'now' };
var annotation = { query: 'select title from events.$server where $timeFilter' };
var response = [];
beforeEach(function() {
ctx.templateSrv.replace = function(str) {
return str.replace('$server', 'backend_01');
};
ctx.$httpBackend.expect('GET', urlExpected).respond(response);
ctx.ds.annotationQuery(annotation, range).then(function(data) { results = data; });
ctx.$httpBackend.flush();
});
it('should generate the correct query', function() {
ctx.$httpBackend.verifyNoOutstandingExpectation();
});
});
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment