mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[ML] Data Frame Analytics audit messages api test (#125325)
* wip: add beginning of messages api test * adds dfa audit messages api test * use retry instead of running job
This commit is contained in:
parent
c961b4b1f8
commit
eafa4d998d
2 changed files with 36 additions and 1 deletions
|
@ -16,6 +16,7 @@ import {
|
||||||
} from '../../data_frame_analytics/common';
|
} from '../../data_frame_analytics/common';
|
||||||
import { DeepPartial } from '../../../../common/types/common';
|
import { DeepPartial } from '../../../../common/types/common';
|
||||||
import { NewJobCapsResponse } from '../../../../common/types/fields';
|
import { NewJobCapsResponse } from '../../../../common/types/fields';
|
||||||
|
import { JobMessage } from '../../../../common/types/audit_message';
|
||||||
import {
|
import {
|
||||||
DeleteDataFrameAnalyticsWithIndexStatus,
|
DeleteDataFrameAnalyticsWithIndexStatus,
|
||||||
AnalyticsMapReturnType,
|
AnalyticsMapReturnType,
|
||||||
|
@ -161,7 +162,7 @@ export const dataFrameAnalytics = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAnalyticsAuditMessages(analyticsId: string) {
|
getAnalyticsAuditMessages(analyticsId: string) {
|
||||||
return http<any>({
|
return http<JobMessage[]>({
|
||||||
path: `${basePath()}/data_frame/analytics/${analyticsId}/messages`,
|
path: `${basePath()}/data_frame/analytics/${analyticsId}/messages`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,6 +16,7 @@ export default ({ getService }: FtrProviderContext) => {
|
||||||
const esArchiver = getService('esArchiver');
|
const esArchiver = getService('esArchiver');
|
||||||
const supertest = getService('supertestWithoutAuth');
|
const supertest = getService('supertestWithoutAuth');
|
||||||
const ml = getService('ml');
|
const ml = getService('ml');
|
||||||
|
const retry = getService('retry');
|
||||||
|
|
||||||
const jobId = `bm_${Date.now()}`;
|
const jobId = `bm_${Date.now()}`;
|
||||||
|
|
||||||
|
@ -273,5 +274,38 @@ export default ({ getService }: FtrProviderContext) => {
|
||||||
expect(body).to.have.keys('elements', 'details', 'error');
|
expect(body).to.have.keys('elements', 'details', 'error');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('GetDataFrameAnalyticsMessages', () => {
|
||||||
|
it('should fetch single analytics job messages by id', async () => {
|
||||||
|
await retry.tryForTime(5000, async () => {
|
||||||
|
const { body } = await supertest
|
||||||
|
.get(`/api/ml/data_frame/analytics/${jobId}_1/messages`)
|
||||||
|
.auth(USER.ML_VIEWER, ml.securityCommon.getPasswordForUser(USER.ML_VIEWER))
|
||||||
|
.set(COMMON_REQUEST_HEADERS)
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(body.length).to.eql(1);
|
||||||
|
expect(body[0].job_id).to.eql(`${jobId}_1`);
|
||||||
|
expect(body[0]).to.have.keys(
|
||||||
|
'job_id',
|
||||||
|
'message',
|
||||||
|
'level',
|
||||||
|
'timestamp',
|
||||||
|
'node_name',
|
||||||
|
'job_type'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not allow to retrieve job messages without required permissions', async () => {
|
||||||
|
const { body } = await supertest
|
||||||
|
.get(`/api/ml/data_frame/analytics/${jobId}_1/messages`)
|
||||||
|
.auth(USER.ML_UNAUTHORIZED, ml.securityCommon.getPasswordForUser(USER.ML_UNAUTHORIZED))
|
||||||
|
.set(COMMON_REQUEST_HEADERS)
|
||||||
|
.expect(403);
|
||||||
|
expect(body.error).to.eql('Forbidden');
|
||||||
|
expect(body.message).to.eql('Forbidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue