mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ML] API test for ml_node_count (#187484)
We can't be sure of the node count when running tests, so we just make sure the counts are above expected values. Also updates the route access tags to be `access:ml:canGetMlInfo` rather than `access:ml:canGetJobs` and `access:ml:canGetDatafeeds`. In serverless, AD can be disabled and these tags would be false.
This commit is contained in:
parent
3dfcb859c4
commit
ea0bbf76be
3 changed files with 46 additions and 1 deletions
|
@ -147,7 +147,7 @@ export function systemRoutes(
|
|||
path: `${ML_INTERNAL_BASE_PATH}/ml_node_count`,
|
||||
access: 'internal',
|
||||
options: {
|
||||
tags: ['access:ml:canGetJobs', 'access:ml:canGetDatafeeds'],
|
||||
tags: ['access:ml:canGetMlInfo'],
|
||||
},
|
||||
})
|
||||
.addVersion(
|
||||
|
|
|
@ -12,5 +12,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
|
|||
loadTestFile(require.resolve('./capabilities'));
|
||||
loadTestFile(require.resolve('./space_capabilities'));
|
||||
loadTestFile(require.resolve('./index_exists'));
|
||||
loadTestFile(require.resolve('./node_count'));
|
||||
});
|
||||
}
|
||||
|
|
44
x-pack/test/api_integration/apis/ml/system/node_count.ts
Normal file
44
x-pack/test/api_integration/apis/ml/system/node_count.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
import { USER } from '../../../../functional/services/ml/security_common';
|
||||
import { getCommonRequestHeader } from '../../../../functional/services/ml/common_api';
|
||||
|
||||
export default ({ getService }: FtrProviderContext) => {
|
||||
const supertest = getService('supertestWithoutAuth');
|
||||
const ml = getService('ml');
|
||||
|
||||
async function runRequest(user: USER, expectedStatusCode: number) {
|
||||
const { body, status } = await supertest
|
||||
.get(`/internal/ml/ml_node_count`)
|
||||
.auth(user, ml.securityCommon.getPasswordForUser(user))
|
||||
.set(getCommonRequestHeader('1'));
|
||||
ml.api.assertResponseStatusCode(expectedStatusCode, status, body);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
describe('GET ml/ml_node_count', function () {
|
||||
describe('get ml node count', () => {
|
||||
it('should match expected values', async () => {
|
||||
const resp = await runRequest(USER.ML_POWERUSER, 200);
|
||||
expect(resp.count).to.be.greaterThan(0, 'count should be greater than 0');
|
||||
expect(resp.lazyNodeCount).to.be.greaterThan(
|
||||
-1,
|
||||
'lazyNodeCount should be greater or equal to 0'
|
||||
);
|
||||
});
|
||||
|
||||
it('should should fail for a unauthorized user', async () => {
|
||||
await runRequest(USER.ML_UNAUTHORIZED, 403);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue