-
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] Memory usage: Functional tests #197415
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const functionalConfig = await readConfigFile(require.resolve('../../../config.base.js')); | ||
|
||
return { | ||
...functionalConfig.getAll(), | ||
testFiles: [require.resolve('.')], | ||
junit: { | ||
reportName: 'Chrome X-Pack UI Functional Tests - ML memory_usage', | ||
}, | ||
}; | ||
} |
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,33 @@ | ||
/* | ||
* 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 ({ getService, loadTestFile }: FtrProviderContext) { | ||
const ml = getService('ml'); | ||
|
||
describe('machine learning - overview page', function () { | ||
this.tags(['skipFirefox']); | ||
|
||
before(async () => { | ||
await ml.securityCommon.createMlRoles(); | ||
await ml.securityCommon.createMlUsers(); | ||
await ml.securityUI.loginAsMlPowerUser(); | ||
}); | ||
|
||
after(async () => { | ||
await ml.securityUI.logout(); | ||
|
||
await ml.securityCommon.cleanMlUsers(); | ||
await ml.securityCommon.cleanMlRoles(); | ||
|
||
await ml.testResources.resetKibanaTimeZone(); | ||
}); | ||
|
||
loadTestFile(require.resolve('./memory_usage_page')); | ||
}); | ||
} |
72 changes: 72 additions & 0 deletions
72
x-pack/test/functional/apps/ml/memory_usage/memory_usage_page.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,72 @@ | ||
/* | ||
* 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 ({ getService }: FtrProviderContext) { | ||
const ml = getService('ml'); | ||
const esArchiver = getService('esArchiver'); | ||
|
||
const jobId = 'sample_job'; | ||
|
||
describe('ML memory usage page', function () { | ||
this.tags(['ml']); | ||
|
||
before(async () => { | ||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); | ||
|
||
const jobConfig = ml.commonConfig.getADFqSingleMetricJobConfig(jobId); | ||
|
||
// Create and open AD job | ||
await ml.api.createAnomalyDetectionJob(jobConfig); | ||
await ml.api.openAnomalyDetectionJob(jobId); | ||
|
||
await ml.navigation.navigateToMl(); | ||
await ml.navigation.navigateToMemoryUsage(); | ||
}); | ||
|
||
after(async () => { | ||
await ml.api.closeAnomalyDetectionJob(jobId); | ||
await ml.api.cleanMlIndices(); | ||
}); | ||
|
||
it('opens page with nodes tab selected', async () => { | ||
await ml.memoryUsage.assertMemoryUsageTabIsSelected('nodes'); | ||
}); | ||
|
||
it('allows sorting', async () => { | ||
await ml.memoryUsage.sortColumn('tableHeaderCell_name_1'); | ||
await ml.memoryUsage.assertColumnIsSorted('tableHeaderCell_name_1', 'descending'); | ||
}); | ||
|
||
it('allows searching for a node', async () => { | ||
await ml.memoryUsage.searchForNode('ftr'); | ||
await ml.memoryUsage.assertRowCount(1); | ||
}); | ||
|
||
it('expands node details and displays memory usage details', async () => { | ||
await ml.memoryUsage.expandRow(); | ||
await ml.memoryUsage.assertNodeExpandedDetailsPanelsExist(); | ||
await ml.memoryUsage.selectNodeExpandedRowTab('mlNodesOverviewPanelMemoryTab'); | ||
await ml.memoryUsage.assertChartItemsSelectedByDefault(); | ||
await ml.memoryUsage.assertTreeChartExists(); | ||
}); | ||
|
||
it('clears selected chart items', async () => { | ||
await ml.memoryUsage.clearSelectedChartItems(); | ||
await ml.memoryUsage.assertEmptyTreeChartExists(); | ||
}); | ||
|
||
it('selects memory usage tab and displays chart', async () => { | ||
await ml.memoryUsage.selectTab('memory-usage'); | ||
await ml.memoryUsage.assertTreeChartExists(); | ||
|
||
await ml.memoryUsage.clearSelectedChartItems(); | ||
await ml.memoryUsage.assertEmptyTreeChartExists(); | ||
}); | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export function MachineLearningMemoryUsageProvider({ getService }: FtrProviderContext) { | ||
const testSubjects = getService('testSubjects'); | ||
const comboBox = getService('comboBox'); | ||
|
||
return { | ||
async assertNodeExpandedDetailsPanelsExist() { | ||
await testSubjects.existOrFail('mlNodesTableRowDetailsPanel'); | ||
await testSubjects.existOrFail('mlNodesTableRowDetailsAttributesPanel'); | ||
}, | ||
|
||
async assertTabIsSelected(tabName: string) { | ||
await testSubjects.existOrFail(`mlNodesOverviewPanel ${tabName}Tab`); | ||
}, | ||
|
||
async selectTab(tabName: string) { | ||
await testSubjects.click(`mlMemoryUsageTab-${tabName}`); | ||
}, | ||
|
||
async assertMemoryUsageTabsExist() { | ||
await testSubjects.existOrFail('mlMemoryUsageTabs'); | ||
}, | ||
|
||
async assertMemoryUsageTabIsSelected(tabName: string) { | ||
const isSelected = await testSubjects.getAttribute( | ||
`mlMemoryUsageTab-${tabName}`, | ||
'aria-selected' | ||
); | ||
expect(isSelected).to.eql('true'); | ||
}, | ||
|
||
async assertRowCount(expectedCount: number) { | ||
const rowCount = await this.getRowCount(); | ||
expect(rowCount).to.eql(expectedCount); | ||
}, | ||
|
||
async getAllRows() { | ||
return await testSubjects.findAll('~mlNodesTableRow'); | ||
}, | ||
|
||
async expandRow() { | ||
await testSubjects.click('mlNodesTableRowDetailsToggle'); | ||
}, | ||
|
||
async getRowCount() { | ||
const rows = await this.getAllRows(); | ||
return rows.length; | ||
}, | ||
|
||
async assertColumnHeaderExists(columnName: string) { | ||
await testSubjects.existOrFail(columnName); | ||
}, | ||
|
||
async assertColumnIsSorted(columnName: string, sortDirection: 'ascending' | 'descending') { | ||
const sorted = await testSubjects.getAttribute(columnName, 'aria-sort'); | ||
expect(sorted).to.eql(sortDirection); | ||
}, | ||
|
||
async sortColumn(columnName: string) { | ||
await this.assertColumnHeaderExists(columnName); | ||
await testSubjects.click(columnName); | ||
}, | ||
|
||
async assertSearchBarExists() { | ||
await testSubjects.existOrFail('mlNodesTableSearchInput'); | ||
}, | ||
|
||
async searchForNode(nodeId: string) { | ||
await this.assertSearchBarExists(); | ||
await testSubjects.setValue('mlNodesTableSearchInput', nodeId); | ||
}, | ||
|
||
async selectNodeExpandedRowTab(tabName: string) { | ||
await testSubjects.click(tabName); | ||
}, | ||
|
||
async clearSelectedChartItems() { | ||
await comboBox.clear('~mlJobTreeMap > mlJobTreeMapComboBox'); | ||
}, | ||
|
||
async getSelectedChartItems() { | ||
return await comboBox.getComboBoxSelectedOptions('~mlJobTreeMap > comboBoxInput'); | ||
}, | ||
|
||
async assertChartItemsSelectedByDefault() { | ||
const selectedOptions = await this.getSelectedChartItems(); | ||
expect(selectedOptions.length).to.be.greaterThan(0); | ||
}, | ||
|
||
async assertTreeChartExists() { | ||
await testSubjects.existOrFail('mlJobTreeMap withData'); | ||
}, | ||
|
||
async assertEmptyTreeChartExists() { | ||
await testSubjects.existOrFail('mlJobTreeMap empty'); | ||
}, | ||
}; | ||
} |
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.
Is it worth adding a step where you leave just the Anomaly Detection Job item and assert the tree chart exists, before clearing all?
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.
Hmm, I'm not sure what you mean exactly.
This test is responsible for ensuring that the chart is displayed properly in the
memory usage
tab.Then, it clears the combo box and checks if the chart displays an empty state.
The same thing was done earlier, but for a chart inside an expanded row of a particular node.
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.
Don't worry. I was thinking we could do a click on the DFA and Trained model items above the chart to get it into this state, but probably not worth the effort as there is only 1 AD job in this case.