From 04196063288f128d2a1691c85dfbd1b4afe4fd17 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Thu, 28 Nov 2024 15:55:40 +0100 Subject: [PATCH] [ML] Enable change point detection functional tests (#201612) ## Summary Fixes https://github.com/elastic/kibana/issues/200091 Fixes https://github.com/elastic/kibana/issues/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 --- .../apps/aiops/change_point_detection.ts | 35 +----------- .../aiops/change_point_detection_cases.ts | 57 +++++++++++++++++++ .../aiops/change_point_detection_dashboard.ts | 48 ++++++++++++++++ x-pack/test/functional/apps/aiops/index.ts | 2 + .../test/functional/services/cases/create.ts | 7 ++- 5 files changed, 113 insertions(+), 36 deletions(-) create mode 100644 x-pack/test/functional/apps/aiops/change_point_detection_cases.ts create mode 100644 x-pack/test/functional/apps/aiops/change_point_detection_dashboard.ts diff --git a/x-pack/test/functional/apps/aiops/change_point_detection.ts b/x-pack/test/functional/apps/aiops/change_point_detection.ts index 3f80d9e12e1ea..6ee14d5fd31b2 100644 --- a/x-pack/test/functional/apps/aiops/change_point_detection.ts +++ b/x-pack/test/functional/apps/aiops/change_point_detection.ts @@ -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'); @@ -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 () => { @@ -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); - }); }); } diff --git a/x-pack/test/functional/apps/aiops/change_point_detection_cases.ts b/x-pack/test/functional/apps/aiops/change_point_detection_cases.ts new file mode 100644 index 0000000000000..328a102ec12f5 --- /dev/null +++ b/x-pack/test/functional/apps/aiops/change_point_detection_cases.ts @@ -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); + }); + }); +} diff --git a/x-pack/test/functional/apps/aiops/change_point_detection_dashboard.ts b/x-pack/test/functional/apps/aiops/change_point_detection_dashboard.ts new file mode 100644 index 0000000000000..b152bc45bd17b --- /dev/null +++ b/x-pack/test/functional/apps/aiops/change_point_detection_dashboard.ts @@ -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, + }); + }); + }); +} diff --git a/x-pack/test/functional/apps/aiops/index.ts b/x-pack/test/functional/apps/aiops/index.ts index 75ad41f2e21fb..5397a80c85bd0 100644 --- a/x-pack/test/functional/apps/aiops/index.ts +++ b/x-pack/test/functional/apps/aiops/index.ts @@ -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')); }); diff --git a/x-pack/test/functional/services/cases/create.ts b/x-pack/test/functional/services/cases/create.ts index 3f7b6e1e65f94..f1aec2c8a51be 100644 --- a/x-pack/test/functional/services/cases/create.ts +++ b/x-pack/test/functional/services/cases/create.ts @@ -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); }, };