mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] Anomaly Detection: Fix API integration tests for field caps. (#188309)
## Summary Follow up to #183110. Fixes #188382. The number of fields returned by the field caps API is different across ES versions in forward compatibility tests. In ES 8.16.0, the `_index_mode` field was added (https://github.com/elastic/elasticsearch/pull/110676). This refactors the test to not test for all fields anymore, it just checks that certain fields are returned and the overall number of fields is bigger than 20. To test this locally (you have to run this on the `7.17` branch!), the following commands for the functional tests server and runner can be used to run the tests in different forward compatibility scenarios: ``` # 7.17 tests server node scripts/functional_tests_server.js --config x-pack/test/api_integration/config.ts # 7.17 tests runner node scripts/functional_test_runner --config x-pack/test/api_integration/config.ts ``` Note in `7.17` the API integration tests are not split up yet into several configs so the commands above will run ALL Kibana API integration tests. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
parent
0e46798235
commit
d785d2f1c4
1 changed files with 9 additions and 12 deletions
|
@ -30,8 +30,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
return body;
|
||||
}
|
||||
|
||||
// FAILING ES FORWARD COMPATIBILITY: https://github.com/elastic/kibana/issues/188382
|
||||
describe.skip('field_caps', function () {
|
||||
describe('field_caps', function () {
|
||||
before(async () => {
|
||||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
|
||||
});
|
||||
|
@ -61,18 +60,16 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
1,
|
||||
`Expected number of indices to be 1, but got ${indices.length}`
|
||||
);
|
||||
const fieldsLength = Object.keys(fields).length;
|
||||
const fieldsArr = Object.keys(fields);
|
||||
|
||||
// The number of fields returned by the field caps API is different across
|
||||
// ES versions in forward compatibility tests. In ES 8.15.0, the `_ignored_source`
|
||||
// field was added (https://github.com/elastic/elasticsearch/pull/107567).
|
||||
const esVersion = getService('esVersion');
|
||||
const expectedFieldsLength = esVersion.matchRange('>=8.15') ? 22 : 21;
|
||||
// The fields we expect at least to be present. We don't check for all fields in the test here
|
||||
// because the number of fields can vary depending on the ES version.
|
||||
const expectedFieldsArr = ['@timestamp', 'airline', 'responsetime'];
|
||||
const allExpectedFieldsPresent = expectedFieldsArr.every((f) => fieldsArr.includes(f));
|
||||
expect(allExpectedFieldsPresent).to.eql(true, 'Not all expected fields are present.');
|
||||
|
||||
expect(fieldsLength).to.eql(
|
||||
expectedFieldsLength,
|
||||
`Expected number of fields to be ${expectedFieldsLength}, but got ${fieldsLength}`
|
||||
);
|
||||
// Across ES versions the number of returned meta fields can vary, but there should be at least 20.
|
||||
expect(fieldsArr.length).to.greaterThan(20, 'Expected at least 20 fields to be returned.');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue