stackdriver: adds support for primary aggregations

WIP: Hardcoded values for the aligner and alignment period. Need
to set the aligment period to the closest min interval and
research the aligner more.
This commit is contained in:
Daniel Lee
2018-09-14 09:38:16 +02:00
parent 0b5783563e
commit f4fe26c659
6 changed files with 146 additions and 26 deletions
@@ -1,5 +1,6 @@
import StackdriverDataSource from '../datasource';
import { metricDescriptors } from './testData';
import moment from 'moment';
describe('StackdriverDataSource', () => {
describe('when performing testDataSource', () => {
@@ -93,4 +94,51 @@ describe('StackdriverDataSource', () => {
});
});
});
describe('When performing query', () => {
const options = {
range: {
from: moment.utc('2017-08-22T20:00:00Z'),
to: moment.utc('2017-08-22T23:59:00Z'),
},
rangeRaw: {
from: 'now-4h',
to: 'now',
},
targets: [
{
refId: 'A',
},
],
};
describe('and no time series data is returned', () => {
let ds;
const response = {
results: {
A: {
refId: 'A',
meta: {
rawQuery: 'arawquerystring',
},
series: null,
tables: null,
},
},
};
beforeEach(() => {
const backendSrv = {
datasourceRequest: async () => Promise.resolve({ status: 200, data: response }),
};
ds = new StackdriverDataSource({}, backendSrv);
});
it('should return a list of datapoints', () => {
return ds.query(options).then(results => {
expect(results.data.length).toBe(0);
});
});
});
});
});