* Provide from and to parameters when testing the datasource
* Strongly typed test datasource query
(cherry picked from commit 3ea9ece16e)
This commit is contained in:
+3
-6
@@ -6967,8 +6967,8 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "49"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "49"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "50"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "50"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "51"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "51"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "52"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "52"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "53"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "53"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "56"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "56"],
|
||||||
@@ -6977,10 +6977,7 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "61"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "61"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "62"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "62"]
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "63"],
|
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "64"],
|
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "65"]
|
|
||||||
],
|
],
|
||||||
"public/app/plugins/datasource/graphite/datasource_integration.test.ts:5381": [
|
"public/app/plugins/datasource/graphite/datasource_integration.test.ts:5381": [
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
QueryResultMetaStat,
|
QueryResultMetaStat,
|
||||||
ScopedVars,
|
ScopedVars,
|
||||||
TimeRange,
|
TimeRange,
|
||||||
|
TimeZone,
|
||||||
toDataFrame,
|
toDataFrame,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { getBackendSrv } from '@grafana/runtime';
|
import { getBackendSrv } from '@grafana/runtime';
|
||||||
@@ -37,8 +38,8 @@ import {
|
|||||||
GraphiteMetricLokiMatcher,
|
GraphiteMetricLokiMatcher,
|
||||||
GraphiteOptions,
|
GraphiteOptions,
|
||||||
GraphiteQuery,
|
GraphiteQuery,
|
||||||
GraphiteQueryRequest,
|
|
||||||
GraphiteQueryImportConfiguration,
|
GraphiteQueryImportConfiguration,
|
||||||
|
GraphiteQueryRequest,
|
||||||
GraphiteQueryType,
|
GraphiteQueryType,
|
||||||
GraphiteType,
|
GraphiteType,
|
||||||
MetricTankRequestMeta,
|
MetricTankRequestMeta,
|
||||||
@@ -451,7 +452,7 @@ export class GraphiteDatasource
|
|||||||
return this.templateSrv.containsTemplate(target.target ?? '');
|
return this.templateSrv.containsTemplate(target.target ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
translateTime(date: any, roundUp: any, timezone: any) {
|
translateTime(date: any, roundUp: any, timezone: TimeZone) {
|
||||||
if (isString(date)) {
|
if (isString(date)) {
|
||||||
if (date === 'now') {
|
if (date === 'now') {
|
||||||
return 'now';
|
return 'now';
|
||||||
@@ -855,15 +856,24 @@ export class GraphiteDatasource
|
|||||||
}
|
}
|
||||||
|
|
||||||
testDatasource() {
|
testDatasource() {
|
||||||
const query = {
|
const query: DataQueryRequest<GraphiteQuery> = {
|
||||||
|
app: 'graphite',
|
||||||
|
interval: '10ms',
|
||||||
|
intervalMs: 10,
|
||||||
|
requestId: 'reqId',
|
||||||
|
scopedVars: {},
|
||||||
|
startTime: 0,
|
||||||
|
timezone: 'browser',
|
||||||
panelId: 3,
|
panelId: 3,
|
||||||
rangeRaw: { from: 'now-1h', to: 'now' },
|
rangeRaw: { from: 'now-1h', to: 'now' },
|
||||||
range: {
|
range: {
|
||||||
|
from: dateTime('now-1h'),
|
||||||
|
to: dateTime('now'),
|
||||||
raw: { from: 'now-1h', to: 'now' },
|
raw: { from: 'now-1h', to: 'now' },
|
||||||
},
|
},
|
||||||
targets: [{ target: 'constantLine(100)' }],
|
targets: [{ refId: 'A', target: 'constantLine(100)' }],
|
||||||
maxDataPoints: 300,
|
maxDataPoints: 300,
|
||||||
} as unknown as DataQueryRequest<GraphiteQuery>;
|
};
|
||||||
|
|
||||||
return lastValueFrom(this.query(query)).then(() => ({ status: 'success', message: 'Data source is working' }));
|
return lastValueFrom(this.query(query)).then(() => ({ status: 'success', message: 'Data source is working' }));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user