-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
1 parent
3dfcb85
commit ea0bbf7
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); | ||
}; |