[ML] Functional tests - stabilize anomaly charts embeddables test (#97452)

This PR stabilizes the anomaly charts embeddables test by adding a retry.
This commit is contained in:
Robert Oskamp 2021-04-20 11:38:16 +02:00 committed by GitHub
parent e4bbdda129
commit a3c2aebb9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 14 deletions

View file

@ -58,7 +58,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']);
const dashboardAddPanel = getService('dashboardAddPanel');
const a11y = getService('a11y'); /* this is the wrapping service around axe */
describe('machine learning embeddables anomaly charts', function () {
@ -96,10 +95,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('can open job selection flyout', async () => {
await PageObjects.dashboard.clickCreateDashboardPrompt();
await ml.dashboardEmbeddables.assertDashboardIsEmpty();
await dashboardAddPanel.clickEditorMenuButton();
await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml');
await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts');
await ml.dashboardJobSelectionTable.assertJobSelectionTableExists();
await ml.dashboardEmbeddables.openJobSelectionFlyout();
await a11y.testAppSnapshot();
});

View file

@ -58,7 +58,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']);
const dashboardAddPanel = getService('dashboardAddPanel');
describe('anomaly charts', function () {
this.tags(['mlqa']);
@ -87,10 +86,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('can open job selection flyout', async () => {
await PageObjects.dashboard.clickCreateDashboardPrompt();
await ml.dashboardEmbeddables.assertDashboardIsEmpty();
await dashboardAddPanel.clickEditorMenuButton();
await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml');
await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts');
await ml.dashboardJobSelectionTable.assertJobSelectionTableExists();
await ml.dashboardEmbeddables.openJobSelectionFlyout();
});
it('can select jobs', async () => {

View file

@ -8,14 +8,17 @@
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
mlCommonUI: MlCommonUI,
mlDashboardJobSelectionTable: MlDashboardJobSelectionTable
) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const find = getService('find');
const dashboardAddPanel = getService('dashboardAddPanel');
return {
async assertAnomalyChartsEmbeddableInitializerExists() {
@ -91,5 +94,17 @@ export function MachineLearningDashboardEmbeddablesProvider(
async assertAnomalyChartsExists() {
await testSubjects.existOrFail(`mlExplorerChartsContainer`);
},
async openJobSelectionFlyout() {
await retry.tryForTime(60 * 1000, async () => {
await dashboardAddPanel.clickEditorMenuButton();
await testSubjects.existOrFail('dashboardEditorContextMenu', { timeout: 2000 });
await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml');
await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts');
await mlDashboardJobSelectionTable.assertJobSelectionTableExists();
});
},
};
}

View file

@ -6,8 +6,13 @@
*/
import expect from '@kbn/expect';
import { ProvidedType } from '@kbn/test/types/ftr';
import { FtrProviderContext } from '../../ftr_provider_context';
export type MlDashboardJobSelectionTable = ProvidedType<
typeof MachineLearningDashboardJobSelectionTableProvider
>;
export function MachineLearningDashboardJobSelectionTableProvider({
getService,
}: FtrProviderContext) {
@ -16,8 +21,8 @@ export function MachineLearningDashboardJobSelectionTableProvider({
return {
async assertJobSelectionTableExists(): Promise<void> {
await retry.tryForTime(5000, async () => {
await testSubjects.existOrFail('mlCustomSelectionTable');
await retry.tryForTime(20 * 1000, async () => {
await testSubjects.existOrFail('mlCustomSelectionTable', { timeout: 2000 });
});
},

View file

@ -60,7 +60,11 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const customUrls = MachineLearningCustomUrlsProvider(context);
const dashboardJobSelectionTable = MachineLearningDashboardJobSelectionTableProvider(context);
const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider(context, commonUI);
const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider(
context,
commonUI,
dashboardJobSelectionTable
);
const dataFrameAnalytics = MachineLearningDataFrameAnalyticsProvider(context, api);
const dataFrameAnalyticsCreation = MachineLearningDataFrameAnalyticsCreationProvider(