Skip to content

Commit

Permalink
[ML] Edits from review
Browse files Browse the repository at this point in the history
  • Loading branch information
peteharverson committed Oct 7, 2021
1 parent e0bddc2 commit 35424af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default function ({ getService }: FtrProviderContext) {

describe('trained models', function () {
before(async () => {
await ml.trainedModels.createdTestTrainedModels('classification', 15, true);
await ml.trainedModels.createdTestTrainedModels('regression', 15);
await ml.trainedModels.createTestTrainedModels('classification', 15, true);
await ml.trainedModels.createTestTrainedModels('regression', 15);
await ml.securityUI.loginAsMlPowerUser();
await ml.navigation.navigateToTrainedModels();
});
Expand Down Expand Up @@ -125,11 +125,13 @@ export default function ({ getService }: FtrProviderContext) {

await ml.testExecution.logTestStep('should show the delete modal');
await ml.trainedModelsTable.clickDeleteAction(modelWithoutPipelineData.modelId);
await ml.trainedModelsTable.assertDeleteModalExists();

await ml.testExecution.logTestStep('should delete the model');
await ml.trainedModelsTable.confirmDeleteModel();
await ml.trainedModelsTable.assertRowNotExists(modelWithoutPipelineData.modelId);
await ml.trainedModelsTable.assertModelDisplayedInTable(
modelWithoutPipelineData.modelId,
false
);
});
});
}
2 changes: 1 addition & 1 deletion x-pack/test/functional/services/ml/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
return model;
},

async createdTestTrainedModels(
async createTestTrainedModels(
modelType: ModelType,
count: number = 10,
withIngestPipelines = false
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/services/ml/trained_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export function TrainedModelsProvider(
const retry = getService('retry');

return {
async createdTestTrainedModels(
async createTestTrainedModels(
modelType: ModelType,
count: number = 10,
withIngestPipelines = false
) {
await mlApi.createdTestTrainedModels(modelType, count, withIngestPipelines);
await mlApi.createTestTrainedModels(modelType, count, withIngestPipelines);
},

async assertStats(expectedTotalCount: number) {
Expand Down
23 changes: 6 additions & 17 deletions x-pack/test/functional/services/ml/trained_models_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,10 @@ export function TrainedModelsTableProvider({ getService }: FtrProviderContext) {
);
}

public async assertModelsDisplayedInTable(modelId: string, shouldBeDisplayed: boolean) {
if (shouldBeDisplayed) {
await this.filterWithSearchString(modelId, 1);
} else {
if (await testSubjects.exists('mlNoDataFrameModelsFound', { timeout: 1000 })) {
// no jobs at all, no other assertion needed
return;
}
await this.filterWithSearchString(modelId, 0);
}
public async assertModelDisplayedInTable(modelId: string, shouldBeDisplayed: boolean) {
await retry.tryForTime(5 * 1000, async () => {
await this.filterWithSearchString(modelId, shouldBeDisplayed === true ? 1 : 0);
});
}

public async assertModelsRowFields(modelId: string, expectedRow: TrainedModelRowData) {
Expand Down Expand Up @@ -210,14 +204,9 @@ export function TrainedModelsTableProvider({ getService }: FtrProviderContext) {
});
}

public async assertRowNotExists(modelId: string) {
await retry.tryForTime(30 * 1000, async () => {
await this.filterWithSearchString(modelId, 0);
});
}

public async clickDeleteAction(modelId: string) {
await testSubjects.click(`mlModelsTableRowDeleteAction`);
await testSubjects.click(this.rowSelector(modelId, 'mlModelsTableRowDeleteAction'));
await this.assertDeleteModalExists();
}
})();
}

0 comments on commit 35424af

Please sign in to comment.