mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Adding tests for ML's field caps endpoint (#104315)
* [ML] Adding tests for ML's field caps endpoint * fixing typos
This commit is contained in:
parent
d0986c2eee
commit
85f831bb16
3 changed files with 90 additions and 5 deletions
|
@ -68,17 +68,18 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
|
|||
await ml.testResources.resetKibanaTimeZone();
|
||||
});
|
||||
|
||||
loadTestFile(require.resolve('./modules'));
|
||||
loadTestFile(require.resolve('./annotations'));
|
||||
loadTestFile(require.resolve('./anomaly_detectors'));
|
||||
loadTestFile(require.resolve('./calendars'));
|
||||
loadTestFile(require.resolve('./data_frame_analytics'));
|
||||
loadTestFile(require.resolve('./data_visualizer'));
|
||||
loadTestFile(require.resolve('./fields_service'));
|
||||
loadTestFile(require.resolve('./filters'));
|
||||
loadTestFile(require.resolve('./indices'));
|
||||
loadTestFile(require.resolve('./job_validation'));
|
||||
loadTestFile(require.resolve('./jobs'));
|
||||
loadTestFile(require.resolve('./modules'));
|
||||
loadTestFile(require.resolve('./results'));
|
||||
loadTestFile(require.resolve('./data_frame_analytics'));
|
||||
loadTestFile(require.resolve('./filters'));
|
||||
loadTestFile(require.resolve('./calendars'));
|
||||
loadTestFile(require.resolve('./annotations'));
|
||||
loadTestFile(require.resolve('./saved_objects'));
|
||||
loadTestFile(require.resolve('./system'));
|
||||
});
|
||||
|
|
70
x-pack/test/api_integration/apis/ml/indices/field_caps.ts
Normal file
70
x-pack/test/api_integration/apis/ml/indices/field_caps.ts
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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 { COMMON_REQUEST_HEADERS } from '../../../../functional/services/ml/common_api';
|
||||
import { USER } from '../../../../functional/services/ml/security_common';
|
||||
|
||||
export default ({ getService }: FtrProviderContext) => {
|
||||
const supertest = getService('supertestWithoutAuth');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const ml = getService('ml');
|
||||
|
||||
async function runRequest(
|
||||
index: string,
|
||||
fields?: string[]
|
||||
): Promise<{ indices: string[]; fields: any }> {
|
||||
const { body } = await supertest
|
||||
.post(`/api/ml/indices/field_caps`)
|
||||
.auth(USER.ML_POWERUSER, ml.securityCommon.getPasswordForUser(USER.ML_POWERUSER))
|
||||
.set(COMMON_REQUEST_HEADERS)
|
||||
.send({ index, fields })
|
||||
.expect(200);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
describe('field_caps', () => {
|
||||
before(async () => {
|
||||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await ml.api.cleanMlIndices();
|
||||
});
|
||||
|
||||
it('selected fields in index', async () => {
|
||||
const { indices, fields } = await runRequest('ft_farequote', ['airline', 'responsetime']);
|
||||
expect(indices.length).to.eql(
|
||||
1,
|
||||
`Expected number of indices to be 1, but got ${indices.length}`
|
||||
);
|
||||
const fieldsLength = Object.keys(fields).length;
|
||||
expect(fieldsLength).to.eql(2, `Expected number of fields to be 2, but got ${fieldsLength}`);
|
||||
expect(fields.airline.keyword.type).to.eql('keyword', 'Expected airline type to be keyword');
|
||||
expect(fields.responsetime.float.type).to.eql(
|
||||
'float',
|
||||
'Expected responsetime type to be float'
|
||||
);
|
||||
});
|
||||
|
||||
it('all fields in index', async () => {
|
||||
const { indices, fields } = await runRequest('ft_farequote');
|
||||
expect(indices.length).to.eql(
|
||||
1,
|
||||
`Expected number of indices to be 1, but got ${indices.length}`
|
||||
);
|
||||
const fieldsLength = Object.keys(fields).length;
|
||||
expect(fieldsLength).to.eql(
|
||||
21,
|
||||
`Expected number of fields to be 21, but got ${fieldsLength}`
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
14
x-pack/test/api_integration/apis/ml/indices/index.ts
Normal file
14
x-pack/test/api_integration/apis/ml/indices/index.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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 { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('system', function () {
|
||||
loadTestFile(require.resolve('./field_caps'));
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue