Skip to content

Commit

Permalink
cleaning up calls to cleanMLSavedObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Jul 17, 2023
1 parent 47a0174 commit 1dbb273
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should create a job in the current space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should not forecast for a job that has not been opened', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should fail with non-existing job', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should fail with non-existing job', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should only list jobs from same space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should find single job from same space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default ({ getService }: FtrProviderContext) => {
await ml.api.cleanMlIndices();
await ml.api.deleteIndices(space1JobDestIndex);
await ml.api.deleteIndices(space2JobDestIndex);
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should start job from same space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default ({ getService }: FtrProviderContext) => {
await ml.api.deleteIndices(`user-${jobIdSpace3}`);
await ml.api.deleteIndices(`user-${jobIdSpace4}`);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace3, idSpace4]);
await ml.testResources.cleanMLSavedObjects();
});

it('should stop job from same space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should update job from same space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should fail with non-existing datafeed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should fail with non-existing datafeed', async () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/ml/datafeeds/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should update datafeed with correct space', async () => {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/test/api_integration/apis/ml/jobs/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default ({ getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const supertest = getService('supertestWithoutAuth');
const ml = getService('ml');
const spacesService = getService('spaces');

const idSpace1 = 'space1';

Expand Down Expand Up @@ -95,6 +96,7 @@ export default ({ getService }: FtrProviderContext) => {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
await ml.testResources.setKibanaTimeZoneToUTC();
await spacesService.create({ id: idSpace1, name: 'space_one', disabledFeatures: [] });

for (const job of testSetupJobConfigs) {
await ml.api.createAnomalyDetectionJob(job);
Expand Down Expand Up @@ -123,8 +125,9 @@ export default ({ getService }: FtrProviderContext) => {
});

after(async () => {
await spacesService.delete(idSpace1);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1]);
await ml.testResources.cleanMLSavedObjects();
});

it('returns expected list of combined jobs with stats in default space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should find single job from same space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should list job from same space', async () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/ml/management/get_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it(`should get AD jobs for space ${idSpace1}`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export default ({ getService }: FtrProviderContext) => {
});

after(async () => {
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
});

it('should see results in current space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('job in individual spaces, single space user can only untag', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('model in individual spaces, single space user can only untag', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should list all jobs for user with access to all spaces', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should list all trained models for user with access to all spaces', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should initialize trained models and inherit job spaces', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export default ({ getService }: FtrProviderContext) => {
});

after(async () => {
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
});

it('should remove AD job from current space', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should list jobs and saved objects', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should sync datafeeds and saved objects', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default ({ getService }: FtrProviderContext) => {
await spacesService.delete(idSpace1);
await spacesService.delete(idSpace2);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]);
await ml.testResources.cleanMLSavedObjects();
});

it('should sync trained model saved objects', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await ml.api.deleteAnomalyDetectionJobES(jobId);
}
await spacesService.delete(idSpace1);
await ml.testResources.cleanMLSavedObjects([idSpace1]);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
await ml.testResources.createIndexPatternIfNeeded('ft_ihp_outlier', '@timestamp');

await spacesService.create({
id: spaceIds.idSpace1,
name: 'space_one',
disabledFeatures: [],
});

await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();

Expand All @@ -135,8 +141,8 @@ export default function ({ getService }: FtrProviderContext) {
await spacesService.delete(spaceId);
}
}
await ml.testResources.cleanMLSavedObjects([spaceIds.idSpaceDefault, spaceIds.idSpace1]);
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');
await ml.testResources.deleteIndexPatternByTitle('ft_ihp_outlier');
});
Expand Down

0 comments on commit 1dbb273

Please sign in to comment.