[8.13] [ML] AIOps: Enable Change point detection tests (#177324) (#177568)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[ML] AIOps: Enable Change point detection tests
(#177324)](https://github.com/elastic/kibana/pull/177324)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dima
Arnautov","email":"dmitrii.arnautov@elastic.co"},"sourceCommit":{"committedDate":"2024-02-22T10:54:51Z","message":"[ML]
AIOps: Enable Change point detection tests (#177324)\n\n##
Summary\r\n\r\nCloses #172984 \r\n\r\nEnables Change point detection
functional tests \r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"af86fc3d80c7805dcfd284661259f0e922a432da","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","test_ui_functional","release_note:skip","Team:ML","Feature:ML/AIOps","v8.13.0","v8.14.0"],"title":"[ML]
AIOps: Enable Change point detection tests
","number":177324,"url":"https://github.com/elastic/kibana/pull/177324","mergeCommit":{"message":"[ML]
AIOps: Enable Change point detection tests (#177324)\n\n##
Summary\r\n\r\nCloses #172984 \r\n\r\nEnables Change point detection
functional tests \r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"af86fc3d80c7805dcfd284661259f0e922a432da"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/177324","number":177324,"mergeCommit":{"message":"[ML]
AIOps: Enable Change point detection tests (#177324)\n\n##
Summary\r\n\r\nCloses #172984 \r\n\r\nEnables Change point detection
functional tests \r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed","sha":"af86fc3d80c7805dcfd284661259f0e922a432da"}}]}]
BACKPORT-->

Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
Kibana Machine 2024-02-22 07:13:27 -05:00 committed by GitHub
parent c2fc8da128
commit 86d88017b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 14 deletions

View file

@ -16,8 +16,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
// aiops lives in the ML UI so we need some related services.
const ml = getService('ml');
// Failing ES Promotion: https://github.com/elastic/kibana/issues/172984
describe.skip('change point detection', async function () {
describe('change point detection', async function () {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/ecommerce');
await ml.testResources.createDataViewIfNeeded('ft_ecommerce', 'order_date');
@ -43,10 +42,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await aiops.changePointDetectionPage.selectMetricField(0, 'products.discount_amount');
const result = await aiops.changePointDetectionPage.getTable(0).parseTable();
expect(result.length).to.eql(1);
expect(parseInt(result[0].pValue, 10)).to.eql(0);
expect(Number(result[0].pValue)).to.be.lessThan(1);
expect(result[0].type).to.eql('distribution_change');
await elasticChart.waitForRenderComplete('aiopChangePointPreviewChart > xyVisChart');
await ml.testExecution.logTestStep('Check the change point chart is rendered');
await elasticChart.waitForRenderComplete('aiopChangePointPreviewChart > xyVisChart', 5000);
const chartState = await elasticChart.getChartDebugData(
'aiopChangePointPreviewChart > xyVisChart',
0,
@ -64,8 +64,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await aiops.changePointDetectionPage.clickUseFullDataButton();
await aiops.changePointDetectionPage.selectMetricField(0, 'products.discount_amount');
await aiops.changePointDetectionPage.selectSplitField(0, 'geoip.city_name');
await aiops.changePointDetectionPage.getTable(0).waitForTableToLoad();
const result = await aiops.changePointDetectionPage.getTable(0).parseTable();
const tableService = aiops.changePointDetectionPage.getTable(0);
await tableService.waitForTableToLoad();
const result = await tableService.parseTable();
// the aggregation may return different results (+-1)
expect(result.length).to.be.above(4);
// assert asc sorting by p_value is applied
@ -73,20 +75,23 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});
it('allows change point selection for detailed view', async () => {
await aiops.changePointDetectionPage.getTable(0).selectAllRows();
const tableService = aiops.changePointDetectionPage.getTable(0);
await tableService.selectAllRows();
await aiops.changePointDetectionPage.viewSelected();
await aiops.changePointDetectionPage.assertDetailedView(5);
await aiops.changePointDetectionPage.closeFlyout();
// deselect
await aiops.changePointDetectionPage.getTable(0).selectAllRows();
await tableService.selectAllRows();
});
it('supports a quick filter actions', async () => {
await aiops.changePointDetectionPage
.getTable(0)
.invokeAction(0, 'aiopsChangePointFilterForValue');
await aiops.changePointDetectionPage.getTable(0).waitForTableToLoad();
const resultFor = await aiops.changePointDetectionPage.getTable(0).parseTable();
const tableService = aiops.changePointDetectionPage.getTable(0);
await tableService.invokeAction(0, 'aiopsChangePointFilterForValue', async () => {
await aiops.changePointDetectionPage.assertFiltersApplied();
await tableService.waitForTableToStartLoading();
});
const resultFor = await tableService.parseTable();
expect(resultFor.length).to.eql(1);
});

View file

@ -252,6 +252,12 @@ export function ChangePointDetectionPageProvider(
await this.completeSaveToDashboardForm({ createNew: true });
},
async assertFiltersApplied() {
await retry.tryForTime(30 * 1000, async () => {
await testSubjects.existOrFail('filter-items-group');
});
},
getTable(index: number) {
return tableService.getServiceInstance(
'ChangePointResultsTable',

View file

@ -147,7 +147,11 @@ export function MlTableServiceProvider({ getPageObject, getService }: FtrProvide
});
}
public async invokeAction(rowIndex: number, actionSubject: string) {
public async invokeAction(
rowIndex: number,
actionSubject: string,
postActionCallback: () => Promise<void>
) {
const rows = await testSubjects.findAll(
`${this.parentSubj ? `${this.parentSubj} > ` : ''}~${this.tableTestSubj} > ~${
this.tableRowSubj
@ -159,6 +163,9 @@ export function MlTableServiceProvider({ getPageObject, getService }: FtrProvide
await retry.tryForTime(5000, async () => {
await actionButton.click();
if (postActionCallback) {
await postActionCallback();
}
await this.waitForTableToLoad();
});
}