mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Weird execution order for the tests...
This commit is contained in:
@@ -175,8 +175,12 @@ export class PrometheusDatasource {
|
||||
responseIndex: index,
|
||||
refId: activeTargets[index].refId,
|
||||
};
|
||||
|
||||
console.log('format: ' + transformerOptions.format);
|
||||
console.log('resultType: ' + response.data.data.resultType);
|
||||
console.log('legendFormat: ' + transformerOptions.legendFormat);
|
||||
// console.log(result);
|
||||
this.resultTransformer.transform(result, response, transformerOptions);
|
||||
// console.log(result);
|
||||
});
|
||||
|
||||
return { data: result };
|
||||
@@ -233,6 +237,7 @@ export class PrometheusDatasource {
|
||||
if (start > end) {
|
||||
throw { message: 'Invalid time range' };
|
||||
}
|
||||
// console.log(query.expr);
|
||||
|
||||
var url = '/api/v1/query_range';
|
||||
var data = {
|
||||
|
||||
@@ -6,7 +6,9 @@ export class ResultTransformer {
|
||||
|
||||
transform(result: any, response: any, options: any) {
|
||||
let prometheusResult = response.data.data.result;
|
||||
|
||||
console.log(prometheusResult);
|
||||
// console.log(options);
|
||||
// console.log(result);
|
||||
if (options.format === 'table') {
|
||||
result.push(this.transformMetricDataToTable(prometheusResult, options.responseListLength, options.refId));
|
||||
} else if (options.format === 'heatmap') {
|
||||
@@ -26,6 +28,7 @@ export class ResultTransformer {
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(result);
|
||||
}
|
||||
|
||||
transformMetricData(metricData, options, start, end) {
|
||||
@@ -137,6 +140,7 @@ export class ResultTransformer {
|
||||
if (!label || label === '{}') {
|
||||
label = options.query;
|
||||
}
|
||||
console.log(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -156,6 +160,7 @@ export class ResultTransformer {
|
||||
var labelPart = _.map(_.toPairs(labelData), function(label) {
|
||||
return label[0] + '="' + label[1] + '"';
|
||||
}).join(',');
|
||||
console.log(metricName);
|
||||
return metricName + '{' + labelPart + '}';
|
||||
}
|
||||
|
||||
|
||||
@@ -21,23 +21,7 @@ let backendSrv = <any>{
|
||||
};
|
||||
|
||||
let templateSrv = {
|
||||
replace: (target, scopedVars, format) => {
|
||||
if (!target) {
|
||||
return target;
|
||||
}
|
||||
let variable, value, fmt;
|
||||
|
||||
return target.replace(scopedVars, (match, var1, var2, fmt2, var3, fmt3) => {
|
||||
variable = this.index[var1 || var2 || var3];
|
||||
fmt = fmt2 || fmt3 || format;
|
||||
if (scopedVars) {
|
||||
value = scopedVars[var1 || var2 || var3];
|
||||
if (value) {
|
||||
return this.formatValue(value.value, fmt, variable);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
replace: jest.fn(str => str),
|
||||
};
|
||||
|
||||
let timeSrv = {
|
||||
@@ -63,10 +47,7 @@ describe('PrometheusDatasource', function() {
|
||||
// })
|
||||
// );
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.ds = new PrometheusDatasource(instanceSettings, $q, <any>backendSrv, templateSrv, timeSrv);
|
||||
});
|
||||
describe('When querying prometheus with one target using query editor target spec', function() {
|
||||
describe('When querying prometheus with one target using query editor target spec', async () => {
|
||||
var results;
|
||||
var query = {
|
||||
range: { from: time({ seconds: 63 }), to: time({ seconds: 183 }) },
|
||||
@@ -106,7 +87,7 @@ describe('PrometheusDatasource', function() {
|
||||
expect(res.method).toBe('GET');
|
||||
expect(res.url).toBe(urlExpected);
|
||||
});
|
||||
it('should return series list', function() {
|
||||
it('should return series list', async () => {
|
||||
expect(results.data.length).toBe(1);
|
||||
expect(results.data[0].target).toBe('test{job="testjob"}');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user