2024-01-22 08:42:24 -06:00
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
|
|
|
|
import { e2e } from '../utils';
|
|
|
|
|
|
|
|
const DATASOURCE_ID = 'Prometheus';
|
|
|
|
const DATASOURCE_TYPED_NAME = 'PrometheusDatasourceInstance';
|
|
|
|
|
|
|
|
describe('Prometheus config', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'), true);
|
|
|
|
|
|
|
|
e2e.pages.AddDataSource.visit();
|
|
|
|
e2e.pages.AddDataSource.dataSourcePluginsV2(DATASOURCE_ID)
|
|
|
|
.scrollIntoView()
|
|
|
|
.should('be.visible') // prevents flakiness
|
2024-02-28 08:03:36 -06:00
|
|
|
.click({ force: true });
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should have the following components:
|
|
|
|
connection settings
|
|
|
|
managed alerts
|
|
|
|
scrape interval
|
|
|
|
query timeout
|
|
|
|
default editor
|
|
|
|
disable metric lookup
|
|
|
|
prometheus type
|
|
|
|
cache level
|
|
|
|
incremental querying
|
|
|
|
disable recording rules
|
|
|
|
custom query parameters
|
|
|
|
http method
|
|
|
|
`, () => {
|
|
|
|
// connection settings
|
2024-01-22 08:42:24 -06:00
|
|
|
e2e.components.DataSource.Prometheus.configPage.connectionSettings().should('be.visible');
|
2024-02-28 08:03:36 -06:00
|
|
|
// managed alerts
|
2024-01-22 08:42:24 -06:00
|
|
|
cy.get(`#${selectors.components.DataSource.Prometheus.configPage.manageAlerts}`).scrollIntoView().should('exist');
|
2024-02-28 08:03:36 -06:00
|
|
|
// scrape interval
|
2024-01-22 08:42:24 -06:00
|
|
|
e2e.components.DataSource.Prometheus.configPage.scrapeInterval().scrollIntoView().should('exist');
|
2024-02-28 08:03:36 -06:00
|
|
|
// query timeout
|
2024-01-22 08:42:24 -06:00
|
|
|
e2e.components.DataSource.Prometheus.configPage.queryTimeout().scrollIntoView().should('exist');
|
2024-02-28 08:03:36 -06:00
|
|
|
// default editor
|
2024-01-22 08:42:24 -06:00
|
|
|
e2e.components.DataSource.Prometheus.configPage.defaultEditor().scrollIntoView().should('exist');
|
2024-02-28 08:03:36 -06:00
|
|
|
// disable metric lookup
|
|
|
|
cy.get(`#${selectors.components.DataSource.Prometheus.configPage.disableMetricLookup}`)
|
|
|
|
.scrollIntoView()
|
|
|
|
.should('exist');
|
|
|
|
// prometheus type
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.prometheusType().scrollIntoView().should('exist');
|
|
|
|
// cache level
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.cacheLevel().scrollIntoView().should('exist');
|
|
|
|
// incremental querying
|
|
|
|
cy.get(`#${selectors.components.DataSource.Prometheus.configPage.incrementalQuerying}`)
|
|
|
|
.scrollIntoView()
|
|
|
|
.should('exist');
|
|
|
|
// disable recording rules
|
|
|
|
cy.get(`#${selectors.components.DataSource.Prometheus.configPage.disableRecordingRules}`)
|
|
|
|
.scrollIntoView()
|
|
|
|
.should('exist');
|
|
|
|
// custom query parameters
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.customQueryParameters().scrollIntoView().should('exist');
|
|
|
|
// http method
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.httpMethod().scrollIntoView().should('exist');
|
2024-01-22 08:42:24 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should save the default editor when navigating to explore', () => {
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.defaultEditor().scrollIntoView().should('exist').click();
|
|
|
|
|
2024-02-28 08:03:36 -06:00
|
|
|
selectOption('Builder');
|
2024-01-22 08:42:24 -06:00
|
|
|
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.connectionSettings().type('http://prom-url:9090');
|
|
|
|
|
|
|
|
e2e.pages.DataSource.name().clear();
|
|
|
|
e2e.pages.DataSource.name().type(DATASOURCE_TYPED_NAME);
|
|
|
|
e2e.pages.DataSource.saveAndTest().click();
|
|
|
|
|
|
|
|
e2e.pages.Explore.visit();
|
|
|
|
|
|
|
|
e2e.components.DataSourcePicker.container().should('be.visible').click();
|
|
|
|
|
2024-02-28 08:03:36 -06:00
|
|
|
e2e.components.DataSourcePicker.container().type(`${DATASOURCE_TYPED_NAME}{enter}`);
|
2024-01-22 08:42:24 -06:00
|
|
|
|
2024-02-28 08:03:36 -06:00
|
|
|
e2e.components.DataSource.Prometheus.queryEditor.builder.metricSelect().should('exist');
|
2024-01-22 08:42:24 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow a user to add the version when the Prom type is selected', () => {
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.prometheusType().scrollIntoView().should('exist').click();
|
|
|
|
|
|
|
|
selectOption('Prometheus');
|
|
|
|
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.prometheusVersion().scrollIntoView().should('exist');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have a cache level component', () => {
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.cacheLevel().scrollIntoView().should('exist');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow a user to select a query overlap window when incremental querying is selected', () => {
|
|
|
|
cy.get(`#${selectors.components.DataSource.Prometheus.configPage.incrementalQuerying}`)
|
|
|
|
.scrollIntoView()
|
|
|
|
.should('exist')
|
|
|
|
.check({ force: true });
|
|
|
|
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.queryOverlapWindow().scrollIntoView().should('exist');
|
|
|
|
});
|
|
|
|
|
|
|
|
// exemplars tested in exemplar.spec
|
|
|
|
});
|
|
|
|
|
|
|
|
export function selectOption(option: string) {
|
2024-05-28 08:51:47 -05:00
|
|
|
e2e.components.Select.option().contains(option).should('be.visible').click();
|
2024-01-22 08:42:24 -06:00
|
|
|
}
|