[ML] Functional tests - adjust test retries and waiting conditions (#115592)

This PR fixes a few test stability issues, mostly by adding/adjusting retries.

* Stabilize data viz full time range selection
* Stabilize DFA wizard source data loading
* Stabilize feature importance service methods
* Stabilize DFA table row existence assertion
* Stabilize dashboard embeddable service methods
This commit is contained in:
Robert Oskamp 2021-10-20 11:25:46 +02:00 committed by GitHub
parent 22e4172781
commit f69fa6a8a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 20 deletions

View file

@ -7,12 +7,10 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
import { MlCommonUI } from './common_ui';
import { MlDashboardJobSelectionTable } from './dashboard_job_selection_table';
export function MachineLearningDashboardEmbeddablesProvider(
{ getService }: FtrProviderContext,
mlCommonUI: MlCommonUI,
mlDashboardJobSelectionTable: MlDashboardJobSelectionTable
) {
const retry = getService('retry');
@ -22,14 +20,14 @@ export function MachineLearningDashboardEmbeddablesProvider(
return {
async assertAnomalyChartsEmbeddableInitializerExists() {
await retry.tryForTime(5000, async () => {
await testSubjects.existOrFail('mlAnomalyChartsEmbeddableInitializer');
await retry.tryForTime(10 * 1000, async () => {
await testSubjects.existOrFail('mlAnomalyChartsEmbeddableInitializer', { timeout: 1000 });
});
},
async assertAnomalyChartsEmbeddableInitializerNotExists() {
await retry.tryForTime(5000, async () => {
await testSubjects.missingOrFail('mlAnomalyChartsEmbeddableInitializer');
await retry.tryForTime(10 * 1000, async () => {
await testSubjects.missingOrFail('mlAnomalyChartsEmbeddableInitializer', { timeout: 1000 });
});
},

View file

@ -18,10 +18,11 @@ import {
} from '../../../../plugins/ml/common/util/analytics_utils';
export function MachineLearningDataFrameAnalyticsCreationProvider(
{ getService }: FtrProviderContext,
{ getPageObject, getService }: FtrProviderContext,
mlCommonUI: MlCommonUI,
mlApi: MlApi
) {
const headerPage = getPageObject('header');
const testSubjects = getService('testSubjects');
const comboBox = getService('comboBox');
const retry = getService('retry');
@ -111,10 +112,12 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
},
async assertSourceDataPreviewExists() {
await headerPage.waitUntilLoadingHasFinished();
await testSubjects.existOrFail('mlAnalyticsCreationDataGrid loaded', { timeout: 5000 });
},
async assertIndexPreviewHistogramChartButtonExists() {
await headerPage.waitUntilLoadingHasFinished();
await testSubjects.existOrFail('mlAnalyticsCreationDataGridHistogramButton');
},

View file

@ -73,7 +73,7 @@ export function MachineLearningDataFrameAnalyticsResultsProvider(
async assertTotalFeatureImportanceEvaluatePanelExists() {
await testSubjects.existOrFail('mlDFExpandableSection-FeatureImportanceSummary');
await testSubjects.existOrFail('mlTotalFeatureImportanceChart', { timeout: 5000 });
await testSubjects.existOrFail('mlTotalFeatureImportanceChart', { timeout: 30 * 1000 });
},
async assertFeatureImportanceDecisionPathElementsExists() {
@ -167,17 +167,19 @@ export function MachineLearningDataFrameAnalyticsResultsProvider(
async openFeatureImportancePopover() {
this.assertResultsTableNotEmpty();
const featureImportanceCell = await this.getFirstFeatureImportanceCell();
await featureImportanceCell.focus();
const interactionButton = await featureImportanceCell.findByTagName('button');
await retry.tryForTime(30 * 1000, async () => {
const featureImportanceCell = await this.getFirstFeatureImportanceCell();
await featureImportanceCell.focus();
const interactionButton = await featureImportanceCell.findByTagName('button');
// simulate hover and wait for button to appear
await featureImportanceCell.moveMouseTo();
await this.waitForInteractionButtonToDisplay(interactionButton);
// simulate hover and wait for button to appear
await featureImportanceCell.moveMouseTo();
await this.waitForInteractionButtonToDisplay(interactionButton);
// open popover
await interactionButton.click();
await testSubjects.existOrFail('mlDFAFeatureImportancePopover');
// open popover
await interactionButton.click();
await testSubjects.existOrFail('mlDFAFeatureImportancePopover', { timeout: 1000 });
});
},
async getFirstFeatureImportanceCell(): Promise<WebElementWrapper> {

View file

@ -196,6 +196,11 @@ export function MachineLearningDataFrameAnalyticsTableProvider({ getService }: F
analyticsId: string,
shouldBeDisplayed: boolean
) {
await this.waitForRefreshButtonLoaded();
await testSubjects.click('~mlAnalyticsRefreshListButton');
await this.waitForRefreshButtonLoaded();
await testSubjects.existOrFail('mlAnalyticsJobList', { timeout: 30 * 1000 });
if (shouldBeDisplayed) {
await this.filterWithSearchString(analyticsId, 1);
} else {

View file

@ -33,8 +33,11 @@ export function MachineLearningDataVisualizerIndexBasedProvider({
},
async clickUseFullDataButton(expectedFormattedTotalDocCount: string) {
await testSubjects.clickWhenNotDisabled('dataVisualizerButtonUseFullData');
await this.assertTotalDocumentCount(expectedFormattedTotalDocCount);
await retry.tryForTime(30 * 1000, async () => {
await testSubjects.clickWhenNotDisabled('dataVisualizerButtonUseFullData');
await testSubjects.clickWhenNotDisabled('superDatePickerApplyTimeButton');
await this.assertTotalDocumentCount(expectedFormattedTotalDocCount);
});
},
async assertTotalDocCountHeaderExist() {

View file

@ -67,7 +67,6 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const dashboardJobSelectionTable = MachineLearningDashboardJobSelectionTableProvider(context);
const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider(
context,
commonUI,
dashboardJobSelectionTable
);