From 44ae5c223489bae4230da75efef3c41cdd7c67dc Mon Sep 17 00:00:00 2001 From: Yngrid Coello Date: Wed, 5 Oct 2022 15:45:55 +0200 Subject: [PATCH] Addressing PR changes --- .../apm_api_integration/common/registry.ts | 5 +++-- .../anomaly_detection/write_user.spec.ts | 2 +- x-pack/test/functional/services/ml/api.ts | 19 ------------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/x-pack/test/apm_api_integration/common/registry.ts b/x-pack/test/apm_api_integration/common/registry.ts index 541b3848556c9..d78f0824f1fb0 100644 --- a/x-pack/test/apm_api_integration/common/registry.ts +++ b/x-pack/test/apm_api_integration/common/registry.ts @@ -12,6 +12,7 @@ import { maybe } from '@kbn/apm-plugin/common/utils/maybe'; import { joinByKey } from '@kbn/apm-plugin/common/utils/join_by_key'; import { APMFtrConfigName } from '../configs'; import { FtrProviderContext } from './ftr_provider_context'; +import { ApmUsername, APM_TEST_PASSWORD } from '@kbn/apm-plugin/server/test_helpers/create_apm_users/authentication'; type ArchiveName = | 'apm_8.0.0' @@ -104,7 +105,7 @@ export function RegistryProvider({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const logger = getService('log'); - const ml = getService('ml'); + const supertest = getService('supertest'); const logWithTimer = () => { const start = process.hrtime(); @@ -147,7 +148,7 @@ export function RegistryProvider({ getService }: FtrProviderContext) { ); // sync jobs from .ml-config to .kibana SOs - await ml.syncMlJobs(); + await supertest.get('/api/ml/saved_objects/sync').set('kbn-xsrf', 'foo').auth(ApmUsername.editorUser, APM_TEST_PASSWORD); } if (condition.archives.length) { log('Loaded all archives'); diff --git a/x-pack/test/apm_api_integration/tests/settings/anomaly_detection/write_user.spec.ts b/x-pack/test/apm_api_integration/tests/settings/anomaly_detection/write_user.spec.ts index 0a88842f77926..0a40cfe0a8678 100644 --- a/x-pack/test/apm_api_integration/tests/settings/anomaly_detection/write_user.spec.ts +++ b/x-pack/test/apm_api_integration/tests/settings/anomaly_detection/write_user.spec.ts @@ -30,7 +30,7 @@ export default function apiTest({ getService }: FtrProviderContext) { } function deleteJobs(jobIds: string[]) { - return ml.deleteMlJobs(jobIds); + return Promise.allSettled(jobIds.map(jobId => ml.deleteAnomalyDetectionJobES(jobId))); } registry.when('ML jobs', { config: 'trial', archives: [] }, () => { diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index d639b8b3ac333..d6802d2cb0f7d 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -1463,24 +1463,5 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { log.debug('Module set up'); return module; }, - - async deleteMlJobs(jobIds: string[]) { - log.debug(`Deleting ml jobs ids [${jobIds.join(',')}]`); - const { body, status } = await kbnSupertest - .post('/api/ml/jobs/delete_jobs') - .set(COMMON_REQUEST_HEADERS) - .send({ jobIds }); - this.assertResponseStatusCode(200, status, body); - - log.debug('> ml jobs deleted'); - }, - - async syncMlJobs() { - log.debug('Syncing ml jobs'); - const { body, status } = await kbnSupertest.get('/api/ml/saved_objects/sync'); - this.assertResponseStatusCode(200, status, body); - - log.debug('> ml jobs synced'); - }, }; }