-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Add tests for anomaly embeddables migrations #116520
Merged
qn895
merged 8 commits into
elastic:main
from
qn895:ml-func-test-anomaly-dashboard-migrations
Nov 3, 2021
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4dc2786
[ML] Add tests for anomaly charts embeddable migrations
qn895 40fe1a8
Merge branch 'master' into ml-func-test-anomaly-dashboard-migrations
kibanamachine 640b06c
Merge branch 'main' into ml-func-test-anomaly-dashboard-migrations
kibanamachine eee3561
[ML] Broaden tests for anomaly swimlane as well
qn895 c32274c
[ML] Fix function rename
qn895 7e51b01
[ML] Update tests to use bulk api
qn895 7449472
[ML] Remove override
qn895 e2e1ae2
Merge branch 'main' into ml-func-test-anomaly-dashboard-migrations
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
x-pack/test/functional/apps/ml/embeddables/anomaly_embeddables_migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* 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 { JOB_CONFIG, DATAFEED_CONFIG, ML_EMBEDDABLE_TYPES } from './constants'; | ||
|
||
const testDataList = [ | ||
{ | ||
type: ML_EMBEDDABLE_TYPES.ANOMALY_SWIMLANE, | ||
panelTitle: 'ML anomaly swim lane', | ||
dashboardSavedObject: { | ||
attributes: { | ||
title: `7.15.2 ML anomaly swimlane dashboard ${Date.now()}`, | ||
description: '', | ||
panelsJSON: `[{"version":"7.15.2","type":"ml_anomaly_swimlane","gridData":{"x":0,"y":0,"w":24,"h":15,"i":"c177ed0a-dea0-40f8-8980-cfb0c6bc13a8"},"panelIndex":"c177ed0a-dea0-40f8-8980-cfb0c6bc13a8","embeddableConfig":{"jobIds":["fq_multi_1_ae"],"swimlaneType":"viewBy","viewBy":"airline","enhancements":{}},"title":"ML anomaly swim lane"}]`, | ||
optionsJSON: '{"useMargins":true,"syncColors":false,"hidePanelTitles":false}', | ||
timeRestore: true, | ||
timeTo: '2016-02-11T00:00:00.000Z', | ||
timeFrom: '2016-02-07T00:00:00.000Z', | ||
refreshInterval: { | ||
pause: true, | ||
value: 0, | ||
}, | ||
kibanaSavedObjectMeta: { | ||
searchSourceJSON: '{"query":{"query":"","language":"kuery"},"filter":[]}', | ||
}, | ||
}, | ||
coreMigrationVersion: '7.15.2', | ||
}, | ||
}, | ||
{ | ||
type: ML_EMBEDDABLE_TYPES.ANOMALY_CHARTS, | ||
panelTitle: 'ML anomaly charts', | ||
dashboardSavedObject: { | ||
attributes: { | ||
title: `7.15.2 ML anomaly charts dashboard ${Date.now()}`, | ||
description: '', | ||
panelsJSON: | ||
'[{"version":"7.15.2","type":"ml_anomaly_charts","gridData":{"x":0,"y":0,"w":38,"h":21,"i":"1155890b-c19c-4d98-8153-50e6434612f1"},"panelIndex":"1155890b-c19c-4d98-8153-50e6434612f1","embeddableConfig":{"jobIds":["fq_multi_1_ae"],"maxSeriesToPlot":6,"severityThreshold":0,"enhancements":{}},"title":"ML anomaly charts"}]', | ||
optionsJSON: '{"useMargins":true,"syncColors":false,"hidePanelTitles":false}', | ||
timeRestore: true, | ||
timeTo: '2016-02-11T00:00:00.000Z', | ||
timeFrom: '2016-02-07T00:00:00.000Z', | ||
refreshInterval: { | ||
pause: true, | ||
value: 0, | ||
}, | ||
kibanaSavedObjectMeta: { | ||
searchSourceJSON: '{"query":{"query":"","language":"kuery"},"filter":[]}', | ||
}, | ||
}, | ||
coreMigrationVersion: '7.15.2', | ||
}, | ||
}, | ||
]; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const ml = getService('ml'); | ||
const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']); | ||
|
||
describe('anomaly embeddables migration in Dashboard', function () { | ||
this.tags(['mlqa']); | ||
|
||
before(async () => { | ||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); | ||
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); | ||
await ml.testResources.setKibanaTimeZoneToUTC(); | ||
await ml.securityUI.loginAsMlPowerUser(); | ||
|
||
await ml.api.createAndRunAnomalyDetectionLookbackJob(JOB_CONFIG, DATAFEED_CONFIG); | ||
await PageObjects.common.navigateToApp('dashboard'); | ||
}); | ||
|
||
after(async () => { | ||
await ml.api.cleanMlIndices(); | ||
}); | ||
|
||
for (const testData of testDataList) { | ||
const { dashboardSavedObject, panelTitle, type } = testData; | ||
describe(`loads saved dashboard from version ${dashboardSavedObject.coreMigrationVersion}`, function () { | ||
before(async () => { | ||
await ml.testResources.createDashboardSavedObject( | ||
dashboardSavedObject.attributes.title, | ||
dashboardSavedObject, | ||
true | ||
); | ||
await PageObjects.common.navigateToApp('dashboard'); | ||
}); | ||
|
||
after(async () => { | ||
await ml.testResources.deleteDashboardByTitle(dashboardSavedObject.attributes.title); | ||
}); | ||
|
||
it(`loads saved dashboard from version ${dashboardSavedObject.coreMigrationVersion}`, async () => { | ||
await PageObjects.dashboard.loadSavedDashboard(dashboardSavedObject.attributes.title); | ||
|
||
await ml.dashboardEmbeddables.assertDashboardPanelExists(panelTitle); | ||
await PageObjects.timePicker.setAbsoluteRange( | ||
'Feb 7, 2015 @ 00:00:00.000', | ||
'Feb 11, 2016 @ 00:00:00.000' | ||
); | ||
await PageObjects.timePicker.pauseAutoRefresh(); | ||
pheyos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (type === ML_EMBEDDABLE_TYPES.ANOMALY_CHARTS) { | ||
await ml.dashboardEmbeddables.assertAnomalyChartsSeverityThresholdControlExists(); | ||
await ml.dashboardEmbeddables.assertAnomalyChartsExists(); | ||
} | ||
|
||
if (type === ML_EMBEDDABLE_TYPES.ANOMALY_SWIMLANE) { | ||
await ml.dashboardEmbeddables.assertAnomalySwimlaneExists(); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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 { Datafeed, Job } from '../../../../../plugins/ml/common/types/anomaly_detection_jobs'; | ||
|
||
// @ts-expect-error not full interface | ||
export const JOB_CONFIG: Job = { | ||
job_id: `fq_multi_1_ae`, | ||
description: | ||
'mean/min/max(responsetime) partition=airline on farequote dataset with 1h bucket span', | ||
groups: ['farequote', 'automated', 'multi-metric'], | ||
analysis_config: { | ||
bucket_span: '1h', | ||
influencers: ['airline'], | ||
detectors: [ | ||
{ function: 'mean', field_name: 'responsetime', partition_field_name: 'airline' }, | ||
{ function: 'min', field_name: 'responsetime', partition_field_name: 'airline' }, | ||
{ function: 'max', field_name: 'responsetime', partition_field_name: 'airline' }, | ||
], | ||
}, | ||
data_description: { time_field: '@timestamp' }, | ||
analysis_limits: { model_memory_limit: '20mb' }, | ||
model_plot_config: { enabled: true }, | ||
}; | ||
|
||
// @ts-expect-error not full interface | ||
export const DATAFEED_CONFIG: Datafeed = { | ||
datafeed_id: 'datafeed-fq_multi_1_ae', | ||
indices: ['ft_farequote'], | ||
job_id: 'fq_multi_1_ae', | ||
query: { bool: { must: [{ match_all: {} }] } }, | ||
}; | ||
|
||
export const ML_EMBEDDABLE_TYPES = { | ||
ANOMALY_SWIMLANE: 'ml_anomaly_swimlane', | ||
ANOMALY_CHARTS: 'ml_anomaly_charts', | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This same description is used for the test below. I think it would be good to include the
panelTitle
in the description here too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - please let's not repeat this long title and have a shorter one for either the suite or the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated here 7e51b01