Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] initial api integration test for DFA map api (#86225) #86336

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
});
};