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.
33 lines
1.1 KiB
33 lines
1.1 KiB
import { PrometheusConnector } from '../src/connectors/prometheus'; |
|
import { DatasourceType } from '../src/connectors'; |
|
|
|
import 'jest'; |
|
|
|
|
|
describe('Test Prometheus time range processing', function() { |
|
let datasource = { |
|
type: DatasourceType.PROMETHEUS, |
|
url: 'api/datasources/proxy/4/api/v1/query_range?query=node_disk_io_time_ms&start=1543411320&end=1543432950&step=30', |
|
auth: { |
|
username: 'my_user', |
|
password: 'my_password', |
|
} |
|
} |
|
let targets = []; |
|
let prometheus = new PrometheusConnector(datasource, targets); |
|
|
|
it('check that from/to present in url', function() { |
|
let from = 1234567891234; //milliseconds |
|
let to = 1234567899999; |
|
let query = prometheus.getQuery(from, to, 1000, 0); |
|
expect(query.url.indexOf(`start=${Math.floor(from / 1000)}`) !== -1).toBeTruthy(); |
|
expect(query.url.indexOf(`end=${Math.floor(to / 1000)}`) !== -1).toBeTruthy(); |
|
}); |
|
|
|
it('check that username/password present in query', function() { |
|
let query = prometheus.getQuery(0, 0, 1000, 0); |
|
|
|
expect(query.auth?.username).toBe('my_user'); |
|
expect(query.auth?.password).toBe('my_password'); |
|
}) |
|
});
|
|
|