Skip to content

Commit

Permalink
[ML] Enable change point detection functional tests (elastic#201612)
Browse files Browse the repository at this point in the history
## Summary

Fixes elastic#200091
Fixes elastic#200836

- Splits change point detection functional tests into separate groups
for dashboard and cases integrations.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
  • Loading branch information
darnautov authored Nov 28, 2024
1 parent e55232f commit 0419606
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 36 deletions.
35 changes: 1 addition & 34 deletions x-pack/test/functional/apps/aiops/change_point_detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
import { USER } from '../../services/ml/security_common';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const elasticChart = getService('elasticChart');
const esArchiver = getService('esArchiver');
const aiops = getService('aiops');
const cases = getService('cases');

// aiops lives in the ML UI so we need some related services.
const ml = getService('ml');

// FLAKY: https://github.com/elastic/kibana/issues/200091
describe.skip('change point detection', function () {
describe('change point detection UI', function () {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce');
await ml.testResources.createDataViewIfNeeded('ft_ecommerce', 'order_date');
Expand All @@ -29,7 +26,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

after(async () => {
await ml.testResources.deleteDataViewByTitle('ft_ecommerce');
await cases.api.deleteAllCases();
});

it(`loads the change point detection page`, async () => {
Expand Down Expand Up @@ -104,34 +100,5 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await aiops.changePointDetectionPage.addChangePointConfig();
await aiops.changePointDetectionPage.assertPanelExist(1);
});

it('attaches change point charts to a dashboard', async () => {
await aiops.changePointDetectionPage.assertPanelExist(0);
await aiops.changePointDetectionPage.attachChartsToDashboard(0, {
applyTimeRange: true,
maxSeries: 1,
});
});

it('attaches change point charts to a case', async () => {
await ml.navigation.navigateToMl();
await elasticChart.setNewChartUiDebugFlag(true);
await aiops.changePointDetectionPage.navigateToDataViewSelection();
await ml.jobSourceSelection.selectSourceForChangePointDetection('ft_ecommerce');
await aiops.changePointDetectionPage.assertChangePointDetectionPageExists();

await aiops.changePointDetectionPage.clickUseFullDataButton();
await aiops.changePointDetectionPage.selectMetricField(0, 'products.discount_amount');

const caseParams = {
title: 'ML Change Point Detection case',
description: 'Case with a change point detection attachment',
tag: 'ml_change_point_detection',
reporter: USER.ML_POWERUSER,
};

await aiops.changePointDetectionPage.attachChartsToCases(0, caseParams);
await ml.cases.assertCaseWithChangePointDetectionChartsAttachment(caseParams);
});
});
}
57 changes: 57 additions & 0 deletions x-pack/test/functional/apps/aiops/change_point_detection_cases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';
import { USER } from '../../services/ml/security_common';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const elasticChart = getService('elasticChart');
const esArchiver = getService('esArchiver');
const aiops = getService('aiops');
const cases = getService('cases');

// aiops lives in the ML UI so we need some related services.
const ml = getService('ml');

describe('change point detection in cases', function () {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce');
await ml.testResources.createDataViewIfNeeded('ft_ecommerce', 'order_date');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});

after(async () => {
await ml.testResources.deleteDataViewByTitle('ft_ecommerce');
await cases.api.deleteAllCases();
});

it('attaches change point charts to a case', async () => {
await ml.navigation.navigateToMl();
await elasticChart.setNewChartUiDebugFlag(true);
await aiops.changePointDetectionPage.navigateToDataViewSelection();
await ml.jobSourceSelection.selectSourceForChangePointDetection('ft_ecommerce');
await aiops.changePointDetectionPage.assertChangePointDetectionPageExists();

await aiops.changePointDetectionPage.clickUseFullDataButton();
await aiops.changePointDetectionPage.selectMetricField(0, 'products.discount_amount');

const caseParams = {
title: 'ML Change Point Detection case',
description: 'Case with a change point detection attachment',
tag: 'ml_change_point_detection',
reporter: USER.ML_POWERUSER,
};

await ml.testExecution.logTestStep('attaches chart to a case');
await aiops.changePointDetectionPage.attachChartsToCases(0, caseParams);

await ml.testExecution.logTestStep('checks if attachment is present in the case');
await ml.cases.assertCaseWithChangePointDetectionChartsAttachment(caseParams);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const elasticChart = getService('elasticChart');
const esArchiver = getService('esArchiver');
const aiops = getService('aiops');

// aiops lives in the ML UI so we need some related services.
const ml = getService('ml');

describe('change point detection in dashboard', function () {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce');
await ml.testResources.createDataViewIfNeeded('ft_ecommerce', 'order_date');
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
});

after(async () => {
await ml.testResources.deleteDataViewByTitle('ft_ecommerce');
});

it('attaches change point charts to a dashboard from the ML app', async () => {
await ml.navigation.navigateToMl();
await elasticChart.setNewChartUiDebugFlag(true);
await aiops.changePointDetectionPage.navigateToDataViewSelection();
await ml.jobSourceSelection.selectSourceForChangePointDetection('ft_ecommerce');
await aiops.changePointDetectionPage.assertChangePointDetectionPageExists();

await aiops.changePointDetectionPage.clickUseFullDataButton();
await aiops.changePointDetectionPage.selectMetricField(0, 'products.discount_amount');
await aiops.changePointDetectionPage.selectSplitField(0, 'geoip.city_name');

await aiops.changePointDetectionPage.assertPanelExist(0);
await aiops.changePointDetectionPage.attachChartsToDashboard(0, {
applyTimeRange: true,
maxSeries: 1,
});
});
});
}
2 changes: 2 additions & 0 deletions x-pack/test/functional/apps/aiops/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./log_rate_analysis_anomaly_table'));
loadTestFile(require.resolve('./log_rate_analysis_dashboard_embeddable'));
loadTestFile(require.resolve('./change_point_detection'));
loadTestFile(require.resolve('./change_point_detection_dashboard'));
loadTestFile(require.resolve('./change_point_detection_cases'));
loadTestFile(require.resolve('./log_pattern_analysis'));
loadTestFile(require.resolve('./log_pattern_analysis_in_discover'));
});
Expand Down
7 changes: 5 additions & 2 deletions x-pack/test/functional/services/cases/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@ export function CasesCreateViewServiceProvider(

async createCaseFromModal(params: CreateCaseParams) {
await casesCommon.assertCaseModalVisible(true);
await testSubjects.click('cases-table-add-case-filter-bar');

await casesCommon.assertCaseModalVisible(false);
await retry.tryForTime(5000, async () => {
await testSubjects.click('cases-table-add-case-filter-bar');
await casesCommon.assertCaseModalVisible(false);
});

await this.creteCaseFromFlyout(params);
},
};
Expand Down

0 comments on commit 0419606

Please sign in to comment.