2023-09-08 10:51:59 -05:00
|
|
|
import { e2e } from '../utils';
|
2024-02-22 05:31:40 -06:00
|
|
|
import { waitForMonacoToLoad } from '../utils/support/monaco';
|
2021-05-13 07:17:09 -05:00
|
|
|
|
|
|
|
const dataSourceName = 'PromExemplar';
|
|
|
|
const addDataSource = () => {
|
|
|
|
e2e.flows.addDataSource({
|
|
|
|
type: 'Prometheus',
|
2023-04-27 14:54:12 -05:00
|
|
|
expectedAlertMessage: 'Prometheus',
|
2021-05-13 07:17:09 -05:00
|
|
|
name: dataSourceName,
|
|
|
|
form: () => {
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.exemplarsAddButton().click();
|
|
|
|
e2e.components.DataSource.Prometheus.configPage.internalLinkSwitch().check({ force: true });
|
2023-09-11 12:12:21 -05:00
|
|
|
e2e.components.DataSource.Prometheus.configPage.connectionSettings().type('http://prom-url:9090');
|
2024-02-16 03:40:16 -06:00
|
|
|
e2e.components.DataSourcePicker.inputV2().click().should('have.focus');
|
2021-07-14 08:04:23 -05:00
|
|
|
|
2023-09-11 05:20:54 -05:00
|
|
|
cy.contains('gdev-tempo').scrollIntoView().should('be.visible').click();
|
2021-05-13 07:17:09 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-08-18 14:47:25 -05:00
|
|
|
describe('Exemplars', () => {
|
2021-05-13 07:17:09 -05:00
|
|
|
beforeEach(() => {
|
2023-09-27 05:33:00 -05:00
|
|
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
|
|
|
|
|
|
|
cy.request({
|
|
|
|
url: `${Cypress.env('BASE_URL')}/api/datasources/name/${dataSourceName}`,
|
|
|
|
failOnStatusCode: false,
|
|
|
|
}).then((response) => {
|
|
|
|
if (response.isOkStatusCode) {
|
|
|
|
return;
|
2023-09-11 05:20:54 -05:00
|
|
|
}
|
2023-09-27 05:33:00 -05:00
|
|
|
addDataSource();
|
|
|
|
});
|
2021-05-13 07:17:09 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to navigate to configured data source', () => {
|
2023-09-11 05:20:54 -05:00
|
|
|
cy.intercept(
|
2023-04-06 14:43:10 -05:00
|
|
|
{
|
|
|
|
pathname: '/api/ds/query',
|
|
|
|
},
|
|
|
|
(req) => {
|
|
|
|
const datasourceType = req.body.queries[0].datasource.type;
|
|
|
|
if (datasourceType === 'prometheus') {
|
|
|
|
req.reply({ fixture: 'exemplars-query-response.json' });
|
|
|
|
} else if (datasourceType === 'tempo') {
|
|
|
|
req.reply({ fixture: 'tempo-response.json' });
|
|
|
|
} else {
|
|
|
|
req.reply({});
|
|
|
|
}
|
2021-10-12 06:16:09 -05:00
|
|
|
}
|
2023-04-06 14:43:10 -05:00
|
|
|
);
|
2021-05-13 07:17:09 -05:00
|
|
|
|
|
|
|
e2e.pages.Explore.visit();
|
|
|
|
|
2021-11-26 09:38:48 -06:00
|
|
|
e2e.components.DataSourcePicker.container().should('be.visible').click();
|
2023-09-11 05:20:54 -05:00
|
|
|
cy.contains(dataSourceName).scrollIntoView().should('be.visible').click();
|
2021-11-08 07:20:48 -06:00
|
|
|
|
2022-03-23 01:28:19 -05:00
|
|
|
// Switch to code editor
|
2023-11-27 06:54:07 -06:00
|
|
|
e2e.components.RadioButton.container().filter(':contains("Code")').click();
|
2022-03-23 01:28:19 -05:00
|
|
|
|
2024-02-22 05:31:40 -06:00
|
|
|
// Wait for lazy loading Monaco
|
|
|
|
waitForMonacoToLoad();
|
2021-11-08 07:20:48 -06:00
|
|
|
|
2021-05-13 07:17:09 -05:00
|
|
|
e2e.components.TimePicker.openButton().click();
|
2021-10-12 06:16:09 -05:00
|
|
|
e2e.components.TimePicker.fromField().clear().type('2021-07-10 17:10:00');
|
|
|
|
e2e.components.TimePicker.toField().clear().type('2021-07-10 17:30:00');
|
2021-05-13 07:17:09 -05:00
|
|
|
e2e.components.TimePicker.applyTimeRange().click();
|
2021-10-12 06:16:09 -05:00
|
|
|
e2e.components.QueryField.container().should('be.visible').type('exemplar-query_bucket{shift}{enter}');
|
2021-05-13 07:17:09 -05:00
|
|
|
|
2023-09-27 08:25:04 -05:00
|
|
|
cy.get(`[data-testid="time-series-zoom-to-data"]`).click();
|
2023-04-12 11:58:08 -05:00
|
|
|
|
2024-03-01 08:54:39 -06:00
|
|
|
e2e.components.DataSource.Prometheus.exemplarMarker().first().trigger('mousemove');
|
2023-09-11 05:20:54 -05:00
|
|
|
cy.contains('Query with gdev-tempo').click();
|
2021-05-13 07:17:09 -05:00
|
|
|
e2e.components.TraceViewer.spanBar().should('have.length', 11);
|
|
|
|
});
|
|
|
|
});
|