Skip to content

Commit

Permalink
initial api integration test for DFA map api (#86225)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 authored Dec 17, 2020
1 parent 8c5f64f commit 5d2014d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions x-pack/test/api_integration/apis/ml/data_frame_analytics/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});
};

0 comments on commit 5d2014d

Please sign in to comment.