From 5d2014dec5dccdaf0e6d7f84a852dc1b580be61c Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Thu, 17 Dec 2020 12:35:50 -0500 Subject: [PATCH] initial api integration test for DFA map api (#86225) --- .../apis/ml/data_frame_analytics/get.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts index a11f8ca3947c5..63a20cdaca234 100644 --- a/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts +++ b/x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts @@ -235,5 +235,42 @@ export default ({ getService }: FtrProviderContext) => { expect(body.message).to.eql('Forbidden'); }); }); + + describe('GetDataFrameAnalyticsIdMap', () => { + it('should return a map of objects leading up to analytics job id', async () => { + const { body } = await supertest + .get(`/api/ml/data_frame/analytics/map/${jobId}_1`) + .auth(USER.ML_VIEWER, ml.securityCommon.getPasswordForUser(USER.ML_VIEWER)) + .set(COMMON_REQUEST_HEADERS) + .expect(200); + + expect(body).to.have.keys('elements', 'details', 'error'); + // Index node, 2 job nodes (with same source index), and 2 edge nodes to connect them + expect(body.elements.length).to.eql(5); + + for (const detailsId in body.details) { + if (detailsId.includes('analytics')) { + expect(body.details[detailsId]).to.have.keys('id', 'source', 'dest'); + } else if (detailsId.includes('index')) { + const indexId = detailsId.replace('-index', ''); + expect(body.details[detailsId][indexId]).to.have.keys('aliases', 'mappings'); + } + } + }); + + it('should return empty results and an error message if the job does not exist', async () => { + const { body } = await supertest + .get(`/api/ml/data_frame/analytics/map/${jobId}_fake`) + .auth(USER.ML_VIEWER, ml.securityCommon.getPasswordForUser(USER.ML_VIEWER)) + .set(COMMON_REQUEST_HEADERS) + .expect(200); + + expect(body.elements.length).to.eql(0); + expect(body.details).to.eql({}); + expect(body.error).to.eql(`No known job with id '${jobId}_fake'`); + + expect(body).to.have.keys('elements', 'details', 'error'); + }); + }); }); };