From 41137ecb179e5ef06c70186bf9341aae98b320d3 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 6 Jul 2023 10:21:13 +0100 Subject: [PATCH 01/12] [ML] Fix flaky update_groups api test --- x-pack/test/api_integration/apis/ml/jobs/update_groups.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts index 1702388eef4c6..a8f426dd8c749 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts @@ -68,7 +68,11 @@ export default ({ getService }: FtrProviderContext) => { }); after(async () => { + for (const job of testSetupJobConfigs) { + await ml.api.deleteAnomalyDetectionJobES(job.job_id); + } await ml.api.cleanMlIndices(); + await ml.testResources.cleanMLSavedObjects(); }); it('returns expected list of groups after update', async () => { From ab07316ff0b76ea808fc70cd5f58d588cc698e74 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 6 Jul 2023 13:54:10 +0100 Subject: [PATCH 02/12] adding sync --- x-pack/test/api_integration/apis/ml/jobs/update_groups.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts index a8f426dd8c749..ed3226c59c778 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts @@ -65,6 +65,7 @@ export default ({ getService }: FtrProviderContext) => { for (const job of testSetupJobConfigs) { await ml.api.createAnomalyDetectionJob(job); } + await ml.api.syncSavedObjects(); }); after(async () => { From de3b736003bfd98004761b93c2cb3c4015647764 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 6 Jul 2023 14:43:38 +0100 Subject: [PATCH 03/12] cleaning before running tests --- x-pack/test/api_integration/apis/ml/jobs/update_groups.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts index ed3226c59c778..3be31a6ce4c5d 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts @@ -62,10 +62,12 @@ export default ({ getService }: FtrProviderContext) => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.api.cleanMlIndices(); + await ml.testResources.cleanMLSavedObjects(); + for (const job of testSetupJobConfigs) { await ml.api.createAnomalyDetectionJob(job); } - await ml.api.syncSavedObjects(); }); after(async () => { From 8bbb23d0d914d3a888722db54c3497a714317108 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 6 Jul 2023 15:48:56 +0100 Subject: [PATCH 04/12] adding debug info --- x-pack/test/functional/services/ml/api.ts | 11 ++++++++--- x-pack/test/functional/services/ml/test_resources.ts | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index 08799392bb37c..d78c025d20175 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -83,12 +83,17 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { const esDeleteAllIndices = getService('esDeleteAllIndices'); return { - assertResponseStatusCode(expectedStatus: number, actualStatus: number, responseBody: object) { + assertResponseStatusCode( + expectedStatus: number, + actualStatus: number, + responseBody: object, + extraText?: string + ) { expect(actualStatus).to.eql( expectedStatus, `Expected status code ${expectedStatus}, got ${actualStatus} with body '${JSON.stringify( responseBody - )}'` + )}' ${extraText ?? ''}` ); }, @@ -685,7 +690,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { .put(`${space ? `/s/${space}` : ''}/internal/ml/anomaly_detectors/${jobId}`) .set(getCommonRequestHeader('1')) .send(jobConfig); - this.assertResponseStatusCode(200, status, body); + this.assertResponseStatusCode(200, status, body, 'createAnomalyDetectionJob'); await this.waitForAnomalyDetectionJobToExist(jobId); log.debug('> AD job created.'); diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index e8fb9b4e8a152..1eb2b2f7bcff9 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -108,7 +108,7 @@ export function MachineLearningTestResourcesProvider( const { body: findResponse, status } = await supertest .get(`/api/saved_objects/_find?type=${objectType}&per_page=10000`) .set(getCommonRequestHeader('1')); - mlApi.assertResponseStatusCode(200, status, findResponse); + mlApi.assertResponseStatusCode(200, status, findResponse, 'getSavedObjectIdsByType'); findResponse.saved_objects.forEach((element: any) => { savedObjectIds.push(element.id); @@ -338,7 +338,7 @@ export function MachineLearningTestResourcesProvider( .delete(`${space ? `/s/${space}` : ''}/api/saved_objects/${objectType}/${id}`) .set(getCommonRequestHeader('1')) .query({ force }); - mlApi.assertResponseStatusCode(200, status, body); + mlApi.assertResponseStatusCode(200, status, body, 'deleteSavedObjectById'); await this.assertSavedObjectNotExistsById(id, objectType, space); From b075c845eccde3fe00b6dca4eaceda37162d3132 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 6 Jul 2023 16:32:19 +0100 Subject: [PATCH 05/12] spaces clean up --- .../ml/anomaly_detectors/close_with_spaces.ts | 2 +- .../anomaly_detectors/create_with_spaces.ts | 2 +- .../anomaly_detectors/delete_with_spaces.ts | 2 +- .../anomaly_detectors/forecast_with_spaces.ts | 2 +- .../get_stats_with_spaces.ts | 2 +- .../ml/anomaly_detectors/get_with_spaces.ts | 2 +- .../ml/anomaly_detectors/open_with_spaces.ts | 2 +- .../ml/data_frame_analytics/delete_spaces.ts | 2 +- .../ml/data_frame_analytics/get_spaces.ts | 2 +- .../data_frame_analytics/jobs_exist_spaces.ts | 2 +- .../ml/data_frame_analytics/start_spaces.ts | 2 +- .../ml/data_frame_analytics/stop_spaces.ts | 2 +- .../ml/data_frame_analytics/update_spaces.ts | 2 +- .../ml/datafeeds/get_stats_with_spaces.ts | 2 +- .../apis/ml/datafeeds/get_with_spaces.ts | 2 +- .../apis/ml/datafeeds/update.ts | 2 +- .../apis/ml/jobs/close_jobs_spaces.ts | 2 +- .../apis/ml/jobs/delete_jobs_spaces.ts | 2 +- .../ml/jobs/force_start_datafeeds_spaces.ts | 2 +- .../apis/ml/jobs/jobs_exist_spaces.ts | 2 +- .../apis/ml/jobs/jobs_summary_spaces.ts | 2 +- .../apis/ml/jobs/stop_datafeeds_spaces.ts | 2 +- .../apis/ml/management/get_list.ts | 2 +- .../apis/ml/results/get_anomaly_search.ts | 2 +- .../apis/ml/saved_objects/can_delete_job.ts | 2 +- .../saved_objects/can_delete_trained_model.ts | 2 +- .../apis/ml/saved_objects/get_jobs_spaces.ts | 2 +- .../saved_objects/get_trained_model_spaces.ts | 2 +- .../initialize_trained_models.ts | 2 +- .../remove_from_current_space.ts | 2 +- .../apis/ml/saved_objects/status.ts | 2 +- .../apis/ml/saved_objects/sync_jobs.ts | 2 +- .../ml/saved_objects/sync_trained_models.ts | 2 +- .../ml/saved_objects/update_jobs_spaces.ts | 2 +- .../update_trained_model_spaces.ts | 2 +- .../notifications/notification_list.ts | 2 +- .../ml/stack_management_jobs/manage_spaces.ts | 2 +- .../functional/services/ml/test_resources.ts | 27 ++++++++++++------- 38 files changed, 55 insertions(+), 46 deletions(-) diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/close_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/close_with_spaces.ts index d4d243e13e509..b1c1f650274c5 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/close_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/close_with_spaces.ts @@ -50,7 +50,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.closeAnomalyDetectionJob(jobIdSpace1); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts index a3a20966d1ae8..af9278a337f53 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts @@ -30,7 +30,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should create a job in the current space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/delete_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/delete_with_spaces.ts index d100d6060c5d1..f9044b4863f0d 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/delete_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/delete_with_spaces.ts @@ -46,7 +46,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts index 1176452408762..ea2f2bd771839 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should not forecast for a job that has not been opened', async () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts index 6a82281d852ac..e946fd36a1c44 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should fail with non-existing job', async () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts index 908ee1728e814..01a190dc0e15a 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should fail with non-existing job', async () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/open_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/open_with_spaces.ts index 8cf0ab02507a0..ae28e3d514f6e 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/open_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/open_with_spaces.ts @@ -49,7 +49,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.closeAnomalyDetectionJob(jobIdSpace1); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts index eb3b4cb93340b..d843fecc38f00 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/delete_spaces.ts @@ -50,7 +50,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts index e294ddb51d7ea..69a67df234f1f 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts @@ -80,7 +80,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should only list jobs from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts index 73b609961fc58..67b02afb7e89a 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts @@ -68,7 +68,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should find single job from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts index 6f7d23da124f8..a97bbe278a7a7 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts @@ -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(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should start job from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts index 9f86a9f136c56..5979c6d3e953b 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts @@ -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(); + await ml.testResources.cleanMLSavedObjects([idSpace3, idSpace4]); }); it('should stop job from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts index 6b62502827c6b..e1e2f16619aa9 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts @@ -69,7 +69,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should update job from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts b/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts index 0b74e67278943..7b3f3079ef90c 100644 --- a/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts @@ -59,7 +59,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should fail with non-existing datafeed', async () => { diff --git a/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts b/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts index 152f8ceba28e0..7a4d9814e3cc6 100644 --- a/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts @@ -57,7 +57,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should fail with non-existing datafeed', async () => { diff --git a/x-pack/test/api_integration/apis/ml/datafeeds/update.ts b/x-pack/test/api_integration/apis/ml/datafeeds/update.ts index dabf2deb1de67..794ddab044bbf 100644 --- a/x-pack/test/api_integration/apis/ml/datafeeds/update.ts +++ b/x-pack/test/api_integration/apis/ml/datafeeds/update.ts @@ -57,7 +57,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should update datafeed with correct space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/close_jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/close_jobs_spaces.ts index 510b3990d45a0..203ba0dcec789 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/close_jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/close_jobs_spaces.ts @@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => { await ml.api.closeAnomalyDetectionJob(jobIdSpace1); await ml.api.closeAnomalyDetectionJob(jobIdSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/delete_jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/delete_jobs_spaces.ts index 72f87c0a56489..64ce10a3ec414 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/delete_jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/delete_jobs_spaces.ts @@ -53,7 +53,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/force_start_datafeeds_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/force_start_datafeeds_spaces.ts index 132685ba96572..457e352089c07 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/force_start_datafeeds_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/force_start_datafeeds_spaces.ts @@ -87,7 +87,7 @@ export default ({ getService }: FtrProviderContext) => { await ml.api.deleteAnomalyDetectionJobES(jobIdSpace1); await ml.api.deleteAnomalyDetectionJobES(jobIdSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts index 023b367bd8cfd..7cb147eeea5a0 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts @@ -54,7 +54,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should find single job from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts index a650b0a1d1951..b55bb482d809e 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts @@ -49,7 +49,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should list job from same space', async () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/stop_datafeeds_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/stop_datafeeds_spaces.ts index 9e8c342c8ced4..d42b94073d104 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/stop_datafeeds_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/stop_datafeeds_spaces.ts @@ -90,7 +90,7 @@ export default ({ getService }: FtrProviderContext) => { await ml.api.deleteAnomalyDetectionJobES(jobIdSpace1); await ml.api.deleteAnomalyDetectionJobES(jobIdSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/management/get_list.ts b/x-pack/test/api_integration/apis/ml/management/get_list.ts index 9cecacfa3da2c..78ad609a03c73 100644 --- a/x-pack/test/api_integration/apis/ml/management/get_list.ts +++ b/x-pack/test/api_integration/apis/ml/management/get_list.ts @@ -90,7 +90,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it(`should get AD jobs for space ${idSpace1}`, async () => { diff --git a/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts b/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts index 5cfe728abb8b7..e89e610c0b629 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts @@ -69,7 +69,7 @@ export default ({ getService }: FtrProviderContext) => { after(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); }); diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts index bce96de95a643..229ce187cdd9d 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts @@ -76,7 +76,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('job in individual spaces, single space user can only untag', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts index eeb07b1b67b2d..f36cfc99bd8b9 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts @@ -83,7 +83,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('model in individual spaces, single space user can only untag', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts index df539b07e4895..3222988693f7f 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts @@ -64,7 +64,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should list all jobs for user with access to all spaces', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts index 834d214a9bb05..9981a07def684 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts @@ -56,7 +56,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should list all trained models for user with access to all spaces', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts b/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts index bc7f4b100c28d..59ebf66e12e75 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts @@ -92,7 +92,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should initialize trained models and inherit job spaces', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts b/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts index 44232ef2dd01b..86e0d0a8a3274 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts @@ -70,7 +70,7 @@ export default ({ getService }: FtrProviderContext) => { after(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); }); diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/status.ts b/x-pack/test/api_integration/apis/ml/saved_objects/status.ts index ff6ca3792de93..c8941b273ea03 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/status.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/status.ts @@ -69,7 +69,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should list jobs and saved objects', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts b/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts index d855005a10c83..cf1b708328b4b 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts @@ -67,7 +67,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should sync datafeeds and saved objects', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts b/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts index 33c5da4d2e01c..d8a1bb647dc43 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts @@ -79,7 +79,7 @@ export default ({ getService }: FtrProviderContext) => { await spacesService.delete(idSpace1); await spacesService.delete(idSpace2); await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); it('should sync trained model saved objects', async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts index cbe3c584e89ff..1b79fdccb2feb 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/update_jobs_spaces.ts @@ -61,7 +61,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/update_trained_model_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/update_trained_model_spaces.ts index 69f5acdbcb03d..a5a87b7015c04 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/update_trained_model_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/update_trained_model_spaces.ts @@ -55,7 +55,7 @@ export default ({ getService }: FtrProviderContext) => { afterEach(async () => { await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1, idSpace2]); }); after(async () => { diff --git a/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts b/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts index 37cb71ba3c042..23fb1c1c9f67e 100644 --- a/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts +++ b/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await ml.api.deleteAnomalyDetectionJobES(jobId); } await spacesService.delete(idSpace1); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([idSpace1]); await ml.api.cleanMlIndices(); await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); }); diff --git a/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts b/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts index 03f235dcd814a..7df79d45174e7 100644 --- a/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts +++ b/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts @@ -135,7 +135,7 @@ export default function ({ getService }: FtrProviderContext) { await spacesService.delete(spaceId); } } - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([spaceIds.idSpaceDefault, spaceIds.idSpace1]); await ml.api.cleanMlIndices(); await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); await ml.testResources.deleteIndexPatternByTitle('ft_ihp_outlier'); diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index 1eb2b2f7bcff9..d8cc1ce4e39df 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -101,12 +101,14 @@ export function MachineLearningTestResourcesProvider( log.debug(` > Not found`); }, - async getSavedObjectIdsByType(objectType: SavedObjectType): Promise { + async getSavedObjectIdsByType(objectType: SavedObjectType, space?: string): Promise { const savedObjectIds: string[] = []; log.debug(`Searching for '${objectType}' ...`); const { body: findResponse, status } = await supertest - .get(`/api/saved_objects/_find?type=${objectType}&per_page=10000`) + .get( + `${space ? `/s/${space}` : ''}/api/saved_objects/_find?type=${objectType}&per_page=10000` + ) .set(getCommonRequestHeader('1')); mlApi.assertResponseStatusCode(200, status, findResponse, 'getSavedObjectIdsByType'); @@ -514,17 +516,22 @@ export function MachineLearningTestResourcesProvider( await this.assertSavedObjectExistsById(id, SavedObjectType.DASHBOARD); }, - async deleteMlSavedObjectByJobId(jobId: string, jobType: JobType) { + async deleteMlSavedObjectByJobId(jobId: string, jobType: JobType, space?: string) { const savedObjectId = `${jobType}-${jobId}`; - await this.deleteSavedObjectById(savedObjectId, SavedObjectType.ML_JOB, true); + await this.deleteSavedObjectById(savedObjectId, SavedObjectType.ML_JOB, true, space); }, - async cleanMLSavedObjects() { + async cleanMLSavedObjects(spaces?: string[]) { await this.cleanMLJobSavedObjects(); await this.cleanMLTrainedModelsSavedObjects(); + + for (const space of spaces ?? [undefined]) { + await this.cleanMLJobSavedObjects(space); + await this.cleanMLTrainedModelsSavedObjects(space); + } }, - async cleanMLJobSavedObjects() { + async cleanMLJobSavedObjects(space?: string) { log.debug('Deleting ML job saved objects ...'); const savedObjectIds = await this.getSavedObjectIdsByType(SavedObjectType.ML_JOB); for (const id of savedObjectIds) { @@ -533,10 +540,11 @@ export function MachineLearningTestResourcesProvider( log.debug('> ML job saved objects deleted.'); }, - async cleanMLTrainedModelsSavedObjects() { + async cleanMLTrainedModelsSavedObjects(space?: string) { log.debug('Deleting ML trained model saved objects ...'); const savedObjectIds = await this.getSavedObjectIdsByType( - SavedObjectType.ML_TRAINED_MODEL_SAVED_OBJECT_TYPE + SavedObjectType.ML_TRAINED_MODEL_SAVED_OBJECT_TYPE, + space ); for (const id of savedObjectIds) { if (mlApi.isInternalModelId(id)) { @@ -546,7 +554,8 @@ export function MachineLearningTestResourcesProvider( await this.deleteSavedObjectById( id, SavedObjectType.ML_TRAINED_MODEL_SAVED_OBJECT_TYPE, - true + true, + space ); } log.debug('> ML trained model saved objects deleted.'); From 0447ade6ec27532b041a97dbd12885bf29899921 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Thu, 6 Jul 2023 16:48:05 +0100 Subject: [PATCH 06/12] more debug --- x-pack/test/functional/services/ml/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index d78c025d20175..3b783558b8812 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -612,7 +612,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async getAnomalyDetectionJob(jobId: string) { const response = await esSupertest.get(`/_ml/anomaly_detectors/${jobId}`); - this.assertResponseStatusCode(200, response.status, response.body); + this.assertResponseStatusCode(200, response.status, response.body, 'getAnomalyDetectionJob'); return response; }, From 5feb1cd3ba4f3151a28ff642dc81ce9e01438ef1 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 7 Jul 2023 11:36:09 +0100 Subject: [PATCH 07/12] renaming var --- x-pack/test/functional/services/ml/test_resources.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index d8cc1ce4e39df..eebcbd162e009 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -521,11 +521,12 @@ export function MachineLearningTestResourcesProvider( await this.deleteSavedObjectById(savedObjectId, SavedObjectType.ML_JOB, true, space); }, - async cleanMLSavedObjects(spaces?: string[]) { + async cleanMLSavedObjects(additionalSpaces: string[] = []) { + // clean default space await this.cleanMLJobSavedObjects(); await this.cleanMLTrainedModelsSavedObjects(); - for (const space of spaces ?? [undefined]) { + for (const space of additionalSpaces) { await this.cleanMLJobSavedObjects(space); await this.cleanMLTrainedModelsSavedObjects(space); } From da38519f114562f1a19e16843eefc4800928156c Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 7 Jul 2023 11:46:19 +0100 Subject: [PATCH 08/12] removing debug code --- .../api_integration/apis/ml/jobs/update_groups.ts | 6 ------ x-pack/test/functional/services/ml/api.ts | 13 ++++--------- .../test/functional/services/ml/test_resources.ts | 4 ++-- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts index 3be31a6ce4c5d..454eea11b6d62 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/update_groups.ts @@ -62,18 +62,12 @@ export default ({ getService }: FtrProviderContext) => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.setKibanaTimeZoneToUTC(); - await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); - for (const job of testSetupJobConfigs) { await ml.api.createAnomalyDetectionJob(job); } }); after(async () => { - for (const job of testSetupJobConfigs) { - await ml.api.deleteAnomalyDetectionJobES(job.job_id); - } await ml.api.cleanMlIndices(); await ml.testResources.cleanMLSavedObjects(); }); diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index 3b783558b8812..08799392bb37c 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -83,17 +83,12 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { const esDeleteAllIndices = getService('esDeleteAllIndices'); return { - assertResponseStatusCode( - expectedStatus: number, - actualStatus: number, - responseBody: object, - extraText?: string - ) { + assertResponseStatusCode(expectedStatus: number, actualStatus: number, responseBody: object) { expect(actualStatus).to.eql( expectedStatus, `Expected status code ${expectedStatus}, got ${actualStatus} with body '${JSON.stringify( responseBody - )}' ${extraText ?? ''}` + )}'` ); }, @@ -612,7 +607,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async getAnomalyDetectionJob(jobId: string) { const response = await esSupertest.get(`/_ml/anomaly_detectors/${jobId}`); - this.assertResponseStatusCode(200, response.status, response.body, 'getAnomalyDetectionJob'); + this.assertResponseStatusCode(200, response.status, response.body); return response; }, @@ -690,7 +685,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { .put(`${space ? `/s/${space}` : ''}/internal/ml/anomaly_detectors/${jobId}`) .set(getCommonRequestHeader('1')) .send(jobConfig); - this.assertResponseStatusCode(200, status, body, 'createAnomalyDetectionJob'); + this.assertResponseStatusCode(200, status, body); await this.waitForAnomalyDetectionJobToExist(jobId); log.debug('> AD job created.'); diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index eebcbd162e009..bf5f6aed44789 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -110,7 +110,7 @@ export function MachineLearningTestResourcesProvider( `${space ? `/s/${space}` : ''}/api/saved_objects/_find?type=${objectType}&per_page=10000` ) .set(getCommonRequestHeader('1')); - mlApi.assertResponseStatusCode(200, status, findResponse, 'getSavedObjectIdsByType'); + mlApi.assertResponseStatusCode(200, status, findResponse); findResponse.saved_objects.forEach((element: any) => { savedObjectIds.push(element.id); @@ -340,7 +340,7 @@ export function MachineLearningTestResourcesProvider( .delete(`${space ? `/s/${space}` : ''}/api/saved_objects/${objectType}/${id}`) .set(getCommonRequestHeader('1')) .query({ force }); - mlApi.assertResponseStatusCode(200, status, body, 'deleteSavedObjectById'); + mlApi.assertResponseStatusCode(200, status, body); await this.assertSavedObjectNotExistsById(id, objectType, space); From 0fc8da0be4b7bc65fe740f39e25459bd3eaeb937 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 7 Jul 2023 11:47:52 +0100 Subject: [PATCH 09/12] unskipping reset test --- x-pack/test/api_integration/apis/ml/jobs/reset.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/ml/jobs/reset.ts b/x-pack/test/api_integration/apis/ml/jobs/reset.ts index 574124448b1e9..0b69097a907e9 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/reset.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/reset.ts @@ -52,8 +52,7 @@ export default ({ getService }: FtrProviderContext) => { [MULTI_METRIC_JOB_CONFIG.job_id]: { reset: true, task: 'cannot be predicted' }, }; - // Failing: See https://github.com/elastic/kibana/issues/160370 - describe.skip('reset_jobs', function () { + describe('reset_jobs', function () { before(async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); From dd5a0c3beb5b94cb297e721925acb4460a771898 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 7 Jul 2023 12:52:12 +0100 Subject: [PATCH 10/12] adding missing SO clean --- x-pack/test/api_integration/apis/ml/jobs/jobs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs.ts index 3929ed377a51c..b95e054151c59 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs.ts @@ -124,6 +124,7 @@ export default ({ getService }: FtrProviderContext) => { after(async () => { await ml.api.cleanMlIndices(); + await ml.testResources.cleanMLSavedObjects([idSpace1]); }); it('returns expected list of combined jobs with stats in default space', async () => { From 1dbb2737405588af1262ad76be24d08917d0f725 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 17 Jul 2023 12:07:56 +0100 Subject: [PATCH 11/12] cleaning up calls to cleanMLSavedObjects --- .../apis/ml/anomaly_detectors/create_with_spaces.ts | 2 +- .../apis/ml/anomaly_detectors/forecast_with_spaces.ts | 2 +- .../apis/ml/anomaly_detectors/get_stats_with_spaces.ts | 2 +- .../apis/ml/anomaly_detectors/get_with_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/get_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/jobs_exist_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/start_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/stop_spaces.ts | 2 +- .../apis/ml/data_frame_analytics/update_spaces.ts | 2 +- .../apis/ml/datafeeds/get_stats_with_spaces.ts | 2 +- .../api_integration/apis/ml/datafeeds/get_with_spaces.ts | 2 +- x-pack/test/api_integration/apis/ml/datafeeds/update.ts | 2 +- x-pack/test/api_integration/apis/ml/jobs/jobs.ts | 5 ++++- .../api_integration/apis/ml/jobs/jobs_exist_spaces.ts | 2 +- .../api_integration/apis/ml/jobs/jobs_summary_spaces.ts | 2 +- .../test/api_integration/apis/ml/management/get_list.ts | 2 +- .../api_integration/apis/ml/results/get_anomaly_search.ts | 4 ++-- .../apis/ml/saved_objects/can_delete_job.ts | 2 +- .../apis/ml/saved_objects/can_delete_trained_model.ts | 2 +- .../apis/ml/saved_objects/get_jobs_spaces.ts | 2 +- .../apis/ml/saved_objects/get_trained_model_spaces.ts | 2 +- .../apis/ml/saved_objects/initialize_trained_models.ts | 2 +- .../apis/ml/saved_objects/remove_from_current_space.ts | 4 ++-- .../test/api_integration/apis/ml/saved_objects/status.ts | 2 +- .../api_integration/apis/ml/saved_objects/sync_jobs.ts | 2 +- .../apis/ml/saved_objects/sync_trained_models.ts | 2 +- .../ml/short_tests/notifications/notification_list.ts | 2 +- .../apps/ml/stack_management_jobs/manage_spaces.ts | 8 +++++++- 28 files changed, 39 insertions(+), 30 deletions(-) diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts index af9278a337f53..a3a20966d1ae8 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/create_with_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts index ea2f2bd771839..1176452408762 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/forecast_with_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts index e946fd36a1c44..6a82281d852ac 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_stats_with_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts index 01a190dc0e15a..908ee1728e814 100644 --- a/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/anomaly_detectors/get_with_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts index 69a67df234f1f..e294ddb51d7ea 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts index 67b02afb7e89a..73b609961fc58 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/jobs_exist_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts index a97bbe278a7a7..6f7d23da124f8 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/start_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts index 5979c6d3e953b..9f86a9f136c56 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/stop_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts index e1e2f16619aa9..6b62502827c6b 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/update_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts b/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts index 7b3f3079ef90c..0b74e67278943 100644 --- a/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/datafeeds/get_stats_with_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts b/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts index 7a4d9814e3cc6..152f8ceba28e0 100644 --- a/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/datafeeds/get_with_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/datafeeds/update.ts b/x-pack/test/api_integration/apis/ml/datafeeds/update.ts index 794ddab044bbf..dabf2deb1de67 100644 --- a/x-pack/test/api_integration/apis/ml/datafeeds/update.ts +++ b/x-pack/test/api_integration/apis/ml/datafeeds/update.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs.ts index b95e054151c59..a6c423bd8474d 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs.ts @@ -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'; @@ -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); @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts index 7cb147eeea5a0..023b367bd8cfd 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs_exist_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts b/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts index b55bb482d809e..a650b0a1d1951 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/jobs_summary_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/management/get_list.ts b/x-pack/test/api_integration/apis/ml/management/get_list.ts index 78ad609a03c73..9cecacfa3da2c 100644 --- a/x-pack/test/api_integration/apis/ml/management/get_list.ts +++ b/x-pack/test/api_integration/apis/ml/management/get_list.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts b/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts index e89e610c0b629..9238fe5cce1c6 100644 --- a/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts +++ b/x-pack/test/api_integration/apis/ml/results/get_anomaly_search.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts index 229ce187cdd9d..bce96de95a643 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_job.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts index f36cfc99bd8b9..eeb07b1b67b2d 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/can_delete_trained_model.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts index 3222988693f7f..df539b07e4895 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/get_jobs_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts b/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts index 9981a07def684..834d214a9bb05 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/get_trained_model_spaces.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts b/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts index 59ebf66e12e75..bc7f4b100c28d 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/initialize_trained_models.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts b/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts index 86e0d0a8a3274..9cf0f50a8cbb7 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/remove_from_current_space.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/status.ts b/x-pack/test/api_integration/apis/ml/saved_objects/status.ts index c8941b273ea03..ff6ca3792de93 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/status.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/status.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts b/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts index cf1b708328b4b..d855005a10c83 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/sync_jobs.ts @@ -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 () => { diff --git a/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts b/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts index d8a1bb647dc43..33c5da4d2e01c 100644 --- a/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts +++ b/x-pack/test/api_integration/apis/ml/saved_objects/sync_trained_models.ts @@ -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 () => { diff --git a/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts b/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts index 23fb1c1c9f67e..062b2809c375d 100644 --- a/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts +++ b/x-pack/test/functional/apps/ml/short_tests/notifications/notification_list.ts @@ -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'); }); diff --git a/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts b/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts index 7df79d45174e7..4055cd00f7cb9 100644 --- a/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts +++ b/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts @@ -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(); @@ -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'); }); From e4f441bebde852209ad882d980a7e0dd22a5ac69 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 17 Jul 2023 13:02:56 +0100 Subject: [PATCH 12/12] removing create space call --- .../apps/ml/stack_management_jobs/manage_spaces.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts b/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts index 4055cd00f7cb9..55b2bdfa12063 100644 --- a/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts +++ b/x-pack/test/functional/apps/ml/stack_management_jobs/manage_spaces.ts @@ -114,12 +114,6 @@ 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(); @@ -142,7 +136,7 @@ export default function ({ getService }: FtrProviderContext) { } } await ml.api.cleanMlIndices(); - await ml.testResources.cleanMLSavedObjects(); + await ml.testResources.cleanMLSavedObjects([spaceIds.idSpace1]); await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); await ml.testResources.deleteIndexPatternByTitle('ft_ihp_outlier'); });