Skip to content

Commit

Permalink
[ML] Functional tests - stabilize df analytics clone tests (elastic#6…
Browse files Browse the repository at this point in the history
…0497)

This PR stabilizes the data frame analytics clone tests.
  • Loading branch information
pheyos committed Mar 24, 2020
1 parent a524c00 commit 9493674
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function({ getService }: FtrProviderContext) {

it('creates the analytics job', async () => {
await ml.dataFrameAnalyticsCreation.assertCreateButtonExists();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob(testData.jobId);
});

it('starts the analytics job', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export default function({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');

// failing test, see https://github.com/elastic/kibana/issues/60389
describe.skip('jobs cloning supported by UI form', function() {
describe('jobs cloning supported by UI form', function() {
this.tags(['smoke']);

const testDataList: Array<{
Expand Down Expand Up @@ -173,7 +172,7 @@ export default function({ getService }: FtrProviderContext) {
});

it('should create a clone job', async () => {
await ml.dataFrameAnalyticsCreation.createAnalyticsJob();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob(cloneJobId);
});

it('should start the clone analytics job', async () => {
Expand All @@ -186,6 +185,10 @@ export default function({ getService }: FtrProviderContext) {
await ml.dataFrameAnalyticsCreation.closeCreateAnalyticsJobFlyout();
});

it('finishes analytics processing', async () => {
await ml.dataFrameAnalytics.waitForAnalyticsCompletion(cloneJobId);
});

it('displays the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.refreshAnalyticsTable();
await ml.dataFrameAnalyticsTable.filterWithSearchString(cloneJobId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function({ getService }: FtrProviderContext) {

it('creates the analytics job', async () => {
await ml.dataFrameAnalyticsCreation.assertCreateButtonExists();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob(testData.jobId);
});

it('starts the analytics job', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function({ getService }: FtrProviderContext) {

it('creates the analytics job', async () => {
await ml.dataFrameAnalyticsCreation.assertCreateButtonExists();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob();
await ml.dataFrameAnalyticsCreation.createAnalyticsJob(testData.jobId);
});

it('starts the analytics job', async () => {
Expand Down
19 changes: 12 additions & 7 deletions x-pack/test/functional/services/machine_learning/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,20 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
},

async getDataFrameAnalyticsJob(analyticsId: string) {
log.debug(`Fetching data frame analytics job '${analyticsId}'...`);
return await esSupertest.get(`/_ml/data_frame/analytics/${analyticsId}`).expect(200);
},

async waitForDataFrameAnalyticsJobToExist(analyticsId: string) {
await retry.waitForWithTimeout(`'${analyticsId}' to exist`, 5 * 1000, async () => {
if (await this.getDataFrameAnalyticsJob(analyticsId)) {
return true;
} else {
throw new Error(`expected data frame analytics job '${analyticsId}' to exist`);
}
});
},

async createDataFrameAnalyticsJob(jobConfig: DataFrameAnalyticsConfig) {
const { id: analyticsId, ...analyticsConfig } = jobConfig;
log.debug(`Creating data frame analytic job with id '${analyticsId}'...`);
Expand All @@ -369,13 +380,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
.send(analyticsConfig)
.expect(200);

await retry.waitForWithTimeout(`'${analyticsId}' to be created`, 5 * 1000, async () => {
if (await this.getDataFrameAnalyticsJob(analyticsId)) {
return true;
} else {
throw new Error(`expected data frame analytics job '${analyticsId}' to be created`);
}
});
await this.waitForDataFrameAnalyticsJobToExist(analyticsId);
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {

import { FtrProviderContext } from '../../ftr_provider_context';
import { MlCommon } from './common';
import { MlApi } from './api';

enum ANALYSIS_CONFIG_TYPE {
OUTLIER_DETECTION = 'outlier_detection',
Expand All @@ -31,7 +32,8 @@ const isClassificationAnalysis = (arg: any): arg is ClassificationAnalysis => {

export function MachineLearningDataFrameAnalyticsCreationProvider(
{ getService }: FtrProviderContext,
mlCommon: MlCommon
mlCommon: MlCommon,
mlApi: MlApi
) {
const testSubjects = getService('testSubjects');
const comboBox = getService('comboBox');
Expand Down Expand Up @@ -333,12 +335,13 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
return !isEnabled;
},

async createAnalyticsJob() {
async createAnalyticsJob(analyticsId: string) {
await testSubjects.click('mlAnalyticsCreateJobFlyoutCreateButton');
await retry.tryForTime(5000, async () => {
await this.assertCreateButtonMissing();
await this.assertStartButtonExists();
});
await mlApi.waitForDataFrameAnalyticsJobToExist(analyticsId);
},

async assertStartButtonExists() {
Expand All @@ -362,8 +365,8 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
},

async closeCreateAnalyticsJobFlyout() {
await testSubjects.click('mlAnalyticsCreateJobFlyoutCloseButton');
await retry.tryForTime(5000, async () => {
await retry.tryForTime(10 * 1000, async () => {
await testSubjects.click('mlAnalyticsCreateJobFlyoutCloseButton');
await testSubjects.missingOrFail('mlAnalyticsCreateJobFlyout');
});
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/functional/services/ml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const dataFrameAnalytics = MachineLearningDataFrameAnalyticsProvider(context, api);
const dataFrameAnalyticsCreation = MachineLearningDataFrameAnalyticsCreationProvider(
context,
common
common,
api
);
const dataFrameAnalyticsTable = MachineLearningDataFrameAnalyticsTableProvider(context);
const dataVisualizer = MachineLearningDataVisualizerProvider(context);
Expand Down

0 comments on commit 9493674

Please sign in to comment.