The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/loki/metricTimeSplitting.test.ts

22 lines
914 B

import { splitTimeRange } from './metricTimeSplitting';
describe('metric splitTimeRange', () => {
it('should split time range into chunks', () => {
const start = Date.parse('2022-02-06T14:10:03');
const end = Date.parse('2022-02-06T14:11:03');
const step = 10 * 1000;
expect(splitTimeRange(start, end, step, 25000)).toStrictEqual([
[Date.parse('2022-02-06T14:10:00'), Date.parse('2022-02-06T14:10:10')],
[Date.parse('2022-02-06T14:10:20'), Date.parse('2022-02-06T14:10:40')],
[Date.parse('2022-02-06T14:10:50'), Date.parse('2022-02-06T14:11:10')],
]);
});
it('should return the original interval if requested duration is smaller than step', () => {
const start = Date.parse('2022-02-06T14:10:03');
const end = Date.parse('2022-02-06T14:10:33');
const step = 10 * 1000;
expect(splitTimeRange(start, end, step, 1000)).toEqual([[start, end]]);
});
});