Skip to content

Commit

Permalink
Addressing PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrdyn committed Oct 6, 2022
1 parent 2e940f7 commit 44ae5c2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
5 changes: 3 additions & 2 deletions x-pack/test/apm_api_integration/common/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [] }, () => {
Expand Down
19 changes: 0 additions & 19 deletions x-pack/test/functional/services/ml/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
};
}

0 comments on commit 44ae5c2

Please sign in to comment.