Skip to content

Commit

Permalink
[ML] Functional tests - add retries to custom URL service methods (#1…
Browse files Browse the repository at this point in the history
…13749) (#117854)

This PR further stabilizes the custom URLs tests by adding additional retries to the `create*CustomUrl` service methods.

Co-authored-by: Robert Oskamp <[email protected]>
  • Loading branch information
kibanamachine and pheyos authored Nov 8, 2021
1 parent a234068 commit 224affb
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export default function ({ getService }: FtrProviderContext) {
const ml = getService('ml');
const browser = getService('browser');

// FLAKY: https:/elastic/kibana/issues/106053
describe.skip('custom urls', function () {
describe('custom urls', function () {
this.tags(['mlqa']);
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
Expand Down
143 changes: 76 additions & 67 deletions x-pack/test/functional/services/ml/job_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,35 +564,38 @@ export function MachineLearningJobTableProvider(
timeRangeInterval?: string;
}
) {
await this.openEditCustomUrlsForJobTab(jobId);
await retry.tryForTime(30 * 1000, async () => {
await this.closeEditJobFlyout();
await this.openEditCustomUrlsForJobTab(jobId);

const existingCustomUrls = await testSubjects.findAll('mlJobEditCustomUrlItemLabel');
const existingCustomUrls = await testSubjects.findAll('mlJobEditCustomUrlItemLabel');

// Fill-in the form
await this.clickOpenCustomUrlEditor();
await customUrls.setCustomUrlLabel(customUrl.label);
await mlCommonUI.selectRadioGroupValue(
`mlJobCustomUrlLinkToTypeInput`,
URL_TYPE.KIBANA_DISCOVER
);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlDiscoverIndexPatternInput',
customUrl.indexPattern
);
await customUrls.setCustomUrlQueryEntityFieldNames(customUrl.queryEntityFieldNames);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlTimeRangeInput',
customUrl.timeRange
);
if (customUrl.timeRange === TIME_RANGE_TYPE.INTERVAL) {
await customUrls.setCustomUrlTimeRangeInterval(customUrl.timeRangeInterval!);
}
// Fill-in the form
await this.clickOpenCustomUrlEditor();
await customUrls.setCustomUrlLabel(customUrl.label);
await mlCommonUI.selectRadioGroupValue(
`mlJobCustomUrlLinkToTypeInput`,
URL_TYPE.KIBANA_DISCOVER
);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlDiscoverIndexPatternInput',
customUrl.indexPattern
);
await customUrls.setCustomUrlQueryEntityFieldNames(customUrl.queryEntityFieldNames);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlTimeRangeInput',
customUrl.timeRange
);
if (customUrl.timeRange === TIME_RANGE_TYPE.INTERVAL) {
await customUrls.setCustomUrlTimeRangeInterval(customUrl.timeRangeInterval!);
}

// Save custom URL
await retry.tryForTime(5000, async () => {
await testSubjects.click('mlJobAddCustomUrl');
const expectedIndex = existingCustomUrls.length;
await customUrls.assertCustomUrlLabel(expectedIndex, customUrl.label);
// Save custom URL
await retry.tryForTime(5000, async () => {
await testSubjects.click('mlJobAddCustomUrl');
const expectedIndex = existingCustomUrls.length;
await customUrls.assertCustomUrlLabel(expectedIndex, customUrl.label);
});
});

// Save the job
Expand All @@ -609,57 +612,63 @@ export function MachineLearningJobTableProvider(
timeRangeInterval?: string;
}
) {
await this.openEditCustomUrlsForJobTab(jobId);
await retry.tryForTime(30 * 1000, async () => {
await this.closeEditJobFlyout();
await this.openEditCustomUrlsForJobTab(jobId);

const existingCustomUrls = await testSubjects.findAll('mlJobEditCustomUrlItemLabel');
const existingCustomUrls = await testSubjects.findAll('mlJobEditCustomUrlItemLabel');

// Fill-in the form
await this.clickOpenCustomUrlEditor();
await customUrls.setCustomUrlLabel(customUrl.label);
await mlCommonUI.selectRadioGroupValue(
`mlJobCustomUrlLinkToTypeInput`,
URL_TYPE.KIBANA_DASHBOARD
);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlDashboardNameInput',
customUrl.dashboardName
);
await customUrls.setCustomUrlQueryEntityFieldNames(customUrl.queryEntityFieldNames);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlTimeRangeInput',
customUrl.timeRange
);
if (customUrl.timeRange === TIME_RANGE_TYPE.INTERVAL) {
await customUrls.setCustomUrlTimeRangeInterval(customUrl.timeRangeInterval!);
}
// Fill-in the form
await this.clickOpenCustomUrlEditor();
await customUrls.setCustomUrlLabel(customUrl.label);
await mlCommonUI.selectRadioGroupValue(
`mlJobCustomUrlLinkToTypeInput`,
URL_TYPE.KIBANA_DASHBOARD
);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlDashboardNameInput',
customUrl.dashboardName
);
await customUrls.setCustomUrlQueryEntityFieldNames(customUrl.queryEntityFieldNames);
await mlCommonUI.selectSelectValueByVisibleText(
'mlJobCustomUrlTimeRangeInput',
customUrl.timeRange
);
if (customUrl.timeRange === TIME_RANGE_TYPE.INTERVAL) {
await customUrls.setCustomUrlTimeRangeInterval(customUrl.timeRangeInterval!);
}

// Save custom URL
await retry.tryForTime(5000, async () => {
await testSubjects.click('mlJobAddCustomUrl');
const expectedIndex = existingCustomUrls.length;
await customUrls.assertCustomUrlLabel(expectedIndex, customUrl.label);
// Save custom URL
await retry.tryForTime(5000, async () => {
await testSubjects.click('mlJobAddCustomUrl');
const expectedIndex = existingCustomUrls.length;
await customUrls.assertCustomUrlLabel(expectedIndex, customUrl.label);
});
});

// Save the job
await this.saveEditJobFlyoutChanges();
}

public async addOtherTypeCustomUrl(jobId: string, customUrl: { label: string; url: string }) {
await this.openEditCustomUrlsForJobTab(jobId);

const existingCustomUrls = await testSubjects.findAll('mlJobEditCustomUrlItemLabel');

// Fill-in the form
await this.clickOpenCustomUrlEditor();
await customUrls.setCustomUrlLabel(customUrl.label);
await mlCommonUI.selectRadioGroupValue(`mlJobCustomUrlLinkToTypeInput`, URL_TYPE.OTHER);
await customUrls.setCustomUrlOtherTypeUrl(customUrl.url);

// Save custom URL
await retry.tryForTime(5000, async () => {
await testSubjects.click('mlJobAddCustomUrl');
const expectedIndex = existingCustomUrls.length;
await customUrls.assertCustomUrlLabel(expectedIndex, customUrl.label);
await retry.tryForTime(30 * 1000, async () => {
await this.closeEditJobFlyout();
await this.openEditCustomUrlsForJobTab(jobId);

const existingCustomUrls = await testSubjects.findAll('mlJobEditCustomUrlItemLabel');

// Fill-in the form
await this.clickOpenCustomUrlEditor();
await customUrls.setCustomUrlLabel(customUrl.label);
await mlCommonUI.selectRadioGroupValue(`mlJobCustomUrlLinkToTypeInput`, URL_TYPE.OTHER);
await customUrls.setCustomUrlOtherTypeUrl(customUrl.url);

// Save custom URL
await retry.tryForTime(5000, async () => {
await testSubjects.click('mlJobAddCustomUrl');
const expectedIndex = existingCustomUrls.length;
await customUrls.assertCustomUrlLabel(expectedIndex, customUrl.label);
});
});

// Save the job
Expand Down

0 comments on commit 224affb

Please sign in to comment.