|
|
|
@ -126,6 +126,36 @@ describe('Prometheus Result Transformer', () => { |
|
|
|
|
{ target: '3', datapoints: [[10, 1445000010000], [0, 1445000020000], [10, 1445000030000]] }, |
|
|
|
|
]); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should handle missing datapoints', () => { |
|
|
|
|
const seriesList = [ |
|
|
|
|
{ datapoints: [[1, 1000], [2, 2000]] }, |
|
|
|
|
{ datapoints: [[2, 1000], [5, 2000], [1, 3000]] }, |
|
|
|
|
{ datapoints: [[3, 1000], [7, 2000]] }, |
|
|
|
|
]; |
|
|
|
|
const expected = [ |
|
|
|
|
{ datapoints: [[1, 1000], [2, 2000]] }, |
|
|
|
|
{ datapoints: [[1, 1000], [3, 2000], [1, 3000]] }, |
|
|
|
|
{ datapoints: [[1, 1000], [2, 2000]] }, |
|
|
|
|
]; |
|
|
|
|
const result = ctx.resultTransformer.transformToHistogramOverTime(seriesList); |
|
|
|
|
expect(result).toEqual(expected); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should throw error when data in wrong format', () => { |
|
|
|
|
const seriesList = [{ rows: [] }, { datapoints: [] }]; |
|
|
|
|
expect(() => { |
|
|
|
|
ctx.resultTransformer.transformToHistogramOverTime(seriesList); |
|
|
|
|
}).toThrow(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should throw error when prometheus returned non-timeseries', () => { |
|
|
|
|
// should be { metric: {}, values: [] } for timeseries
|
|
|
|
|
const metricData = { metric: {}, value: [] }; |
|
|
|
|
expect(() => { |
|
|
|
|
ctx.resultTransformer.transformMetricData(metricData, { step: 1 }, 1000, 2000); |
|
|
|
|
}).toThrow(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('When resultFormat is time series', () => { |
|
|
|
|