Skip to content

Commit

Permalink
[ML] Functional tests - some stability fixes for cloud test execution (
Browse files Browse the repository at this point in the history
…#106686)

This PR stabilizes some functional tests for cloud execution / execution in different order.

* Reset fleet setup after module tests
* Additional check and retry for anomaly explorer dashboard integration
* Stabilize DFA job wizard step navigation
  • Loading branch information
pheyos committed Jul 27, 2021
1 parent 8a42fdb commit f9bdcd7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
6 changes: 6 additions & 0 deletions x-pack/test/api_integration/apis/ml/modules/index.ts
Expand Up @@ -8,15 +8,20 @@
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const supertest = getService('supertest');

const fleetPackages = ['apache', 'nginx'];

describe('modules', function () {
before(async () => {
// use empty_kibana to make sure the fleet setup is removed correctly after the tests
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');

// Fleet need to be setup to be able to setup packages
await supertest.post(`/api/fleet/setup`).set({ 'kbn-xsrf': 'some-xsrf-token' }).expect(200);

for (const fleetPackage of fleetPackages) {
await ml.testResources.installFleetPackage(fleetPackage);
}
Expand All @@ -26,6 +31,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
for (const fleetPackage of fleetPackages) {
await ml.testResources.removeFleetPackage(fleetPackage);
}
await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana');
});

loadTestFile(require.resolve('./get_module'));
Expand Down
30 changes: 23 additions & 7 deletions x-pack/test/functional/services/ml/anomaly_explorer.ts
Expand Up @@ -10,6 +10,7 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export function MachineLearningAnomalyExplorerProvider({ getService }: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');

return {
Expand Down Expand Up @@ -82,12 +83,8 @@ export function MachineLearningAnomalyExplorerProvider({ getService }: FtrProvid
},

async addAndEditSwimlaneInDashboard(dashboardTitle: string) {
await this.filterWithSearchString(dashboardTitle);
await testSubjects.isDisplayed('mlDashboardSelectionTable > checkboxSelectAll');
await testSubjects.clickWhenNotDisabled('mlDashboardSelectionTable > checkboxSelectAll');
expect(await testSubjects.isChecked('mlDashboardSelectionTable > checkboxSelectAll')).to.be(
true
);
await this.filterDashboardSearchWithSearchString(dashboardTitle);
await this.selectAllDashboards();
await testSubjects.clickWhenNotDisabled('mlAddAndEditDashboardButton');
// changing to the dashboard app might take sime time
const embeddable = await testSubjects.find('mlAnomalySwimlaneEmbeddableWrapper', 30 * 1000);
Expand All @@ -106,11 +103,30 @@ export function MachineLearningAnomalyExplorerProvider({ getService }: FtrProvid
await testSubjects.existOrFail('~mlDashboardSelectionTable', { timeout: 60 * 1000 });
},

async filterWithSearchString(filter: string) {
async filterDashboardSearchWithSearchString(filter: string) {
await this.waitForDashboardsToLoad();
const searchBarInput = await testSubjects.find('mlDashboardsSearchBox');
await searchBarInput.clearValueWithKeyboard();
await searchBarInput.type(filter);
await this.assertDashboardSearchInputValue(filter);
},

async assertDashboardSearchInputValue(expectedSearchValue: string) {
const searchBarInput = await testSubjects.find('mlDashboardsSearchBox');
const actualSearchValue = await searchBarInput.getAttribute('value');
expect(actualSearchValue).to.eql(
expectedSearchValue,
`Dashboard search input value should be '${expectedSearchValue}' (got '${actualSearchValue}')`
);
},

async selectAllDashboards() {
await retry.tryForTime(3000, async () => {
await testSubjects.clickWhenNotDisabled('mlDashboardSelectionTable > checkboxSelectAll');
expect(
await testSubjects.isChecked('mlDashboardSelectionTable > checkboxSelectAll')
).to.eql(true, 'Checkbox to select all dashboards should be selected');
});
},

async assertClearSelectionButtonVisible(expectVisible: boolean) {
Expand Down
44 changes: 31 additions & 13 deletions x-pack/test/functional/services/ml/data_frame_analytics_creation.ts
Expand Up @@ -404,42 +404,58 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
},

async assertConfigurationStepActive() {
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardConfigurationStep active');
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardConfigurationStep active', {
timeout: 3000,
});
},

async assertAdditionalOptionsStepActive() {
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardAdvancedStep active');
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardAdvancedStep active', {
timeout: 3000,
});
},

async assertDetailsStepActive() {
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardDetailsStep active');
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardDetailsStep active', {
timeout: 3000,
});
},

async assertCreateStepActive() {
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardCreateStep active');
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardCreateStep active', {
timeout: 3000,
});
},

async assertValidationStepActive() {
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardValidationStepWrapper active');
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardValidationStepWrapper active', {
timeout: 3000,
});
},

async continueToAdditionalOptionsStep() {
await retry.tryForTime(5000, async () => {
await testSubjects.clickWhenNotDisabled('mlAnalyticsCreateJobWizardContinueButton');
await retry.tryForTime(15 * 1000, async () => {
await testSubjects.clickWhenNotDisabled(
'mlAnalyticsCreateJobWizardConfigurationStep active > mlAnalyticsCreateJobWizardContinueButton'
);
await this.assertAdditionalOptionsStepActive();
});
},

async continueToDetailsStep() {
await retry.tryForTime(5000, async () => {
await testSubjects.clickWhenNotDisabled('mlAnalyticsCreateJobWizardContinueButton');
await retry.tryForTime(15 * 1000, async () => {
await testSubjects.clickWhenNotDisabled(
'mlAnalyticsCreateJobWizardAdvancedStep active > mlAnalyticsCreateJobWizardContinueButton'
);
await this.assertDetailsStepActive();
});
},

async continueToValidationStep() {
await retry.tryForTime(5000, async () => {
await testSubjects.clickWhenNotDisabled('mlAnalyticsCreateJobWizardContinueButton');
await retry.tryForTime(15 * 1000, async () => {
await testSubjects.clickWhenNotDisabled(
'mlAnalyticsCreateJobWizardDetailsStep active > mlAnalyticsCreateJobWizardContinueButton'
);
await this.assertValidationStepActive();
});
},
Expand All @@ -456,8 +472,10 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
},

async continueToCreateStep() {
await retry.tryForTime(5000, async () => {
await testSubjects.clickWhenNotDisabled('mlAnalyticsCreateJobWizardContinueButton');
await retry.tryForTime(15 * 1000, async () => {
await testSubjects.clickWhenNotDisabled(
'mlAnalyticsCreateJobWizardValidationStepWrapper active > mlAnalyticsCreateJobWizardContinueButton'
);
await this.assertCreateStepActive();
});
},
Expand Down

0 comments on commit f9bdcd7

Please sign in to comment.