mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.8`: - [[Data Views] Support "namespaces" param in create data view API (#155815)](https://github.com/elastic/kibana/pull/155815) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Davis McPhee","email":"davis.mcphee@elastic.co"},"sourceCommit":{"committedDate":"2023-05-08T13:03:08Z","message":"[Data Views] Support \"namespaces\" param in create data view API (#155815)\n\n## Summary\r\n\r\nThis work was originally done by @jughosta in #150712, I just added a\r\ncouple of integration tests and opened another PR for it.\r\n\r\nFixes #140426.\r\n\r\n#### Original PR summary:\r\n\r\nThis PR adds support for `namespaces` param in create data view API as\r\nper docs\r\nhttps://www.elastic.co/guide/en/kibana/current/data-views-api-create.html#data-views-api-properties\r\n\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 04 55\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217835577-fa4286ff-89f4-4de2-97b0-62c04f756858.png\">\r\n\r\nPrevious functionality is still in place:\r\n* setting \"default\" space if \"namespaces\" param is not provided\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 06 55\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217835951-d274c8ba-5bd9-4c36-9487-c2dbd5ce42de.png\">\r\n\r\n* setting the specified in URL space ID if \"namespaces\" param is not\r\nprovided\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 06 34\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217836019-81f36a16-157f-4ce9-9d19-c5685d633acc.png\">\r\n\r\n### Checklist\r\n\r\n- [ ] ~Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~\r\n- [ ]\r\n~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials~\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] ~Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard\r\naccessibility](https://webaim.org/techniques/keyboard/))~\r\n- [ ] ~Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~\r\n- [ ] ~If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~\r\n- [ ] ~This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~\r\n- [ ] ~This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)~\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>","sha":"ab2f967ba5720daffa8d404802effe688804d41c","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Data Views","Team:DataDiscovery","v8.8.0","v8.9.0"],"number":155815,"url":"https://github.com/elastic/kibana/pull/155815","mergeCommit":{"message":"[Data Views] Support \"namespaces\" param in create data view API (#155815)\n\n## Summary\r\n\r\nThis work was originally done by @jughosta in #150712, I just added a\r\ncouple of integration tests and opened another PR for it.\r\n\r\nFixes #140426.\r\n\r\n#### Original PR summary:\r\n\r\nThis PR adds support for `namespaces` param in create data view API as\r\nper docs\r\nhttps://www.elastic.co/guide/en/kibana/current/data-views-api-create.html#data-views-api-properties\r\n\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 04 55\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217835577-fa4286ff-89f4-4de2-97b0-62c04f756858.png\">\r\n\r\nPrevious functionality is still in place:\r\n* setting \"default\" space if \"namespaces\" param is not provided\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 06 55\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217835951-d274c8ba-5bd9-4c36-9487-c2dbd5ce42de.png\">\r\n\r\n* setting the specified in URL space ID if \"namespaces\" param is not\r\nprovided\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 06 34\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217836019-81f36a16-157f-4ce9-9d19-c5685d633acc.png\">\r\n\r\n### Checklist\r\n\r\n- [ ] ~Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~\r\n- [ ]\r\n~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials~\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] ~Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard\r\naccessibility](https://webaim.org/techniques/keyboard/))~\r\n- [ ] ~Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~\r\n- [ ] ~If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~\r\n- [ ] ~This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~\r\n- [ ] ~This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)~\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>","sha":"ab2f967ba5720daffa8d404802effe688804d41c"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/155815","number":155815,"mergeCommit":{"message":"[Data Views] Support \"namespaces\" param in create data view API (#155815)\n\n## Summary\r\n\r\nThis work was originally done by @jughosta in #150712, I just added a\r\ncouple of integration tests and opened another PR for it.\r\n\r\nFixes #140426.\r\n\r\n#### Original PR summary:\r\n\r\nThis PR adds support for `namespaces` param in create data view API as\r\nper docs\r\nhttps://www.elastic.co/guide/en/kibana/current/data-views-api-create.html#data-views-api-properties\r\n\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 04 55\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217835577-fa4286ff-89f4-4de2-97b0-62c04f756858.png\">\r\n\r\nPrevious functionality is still in place:\r\n* setting \"default\" space if \"namespaces\" param is not provided\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 06 55\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217835951-d274c8ba-5bd9-4c36-9487-c2dbd5ce42de.png\">\r\n\r\n* setting the specified in URL space ID if \"namespaces\" param is not\r\nprovided\r\n<img width=\"300\" alt=\"Screenshot 2023-02-09 at 15 06 34\"\r\nsrc=\"https://user-images.githubusercontent.com/1415710/217836019-81f36a16-157f-4ce9-9d19-c5685d633acc.png\">\r\n\r\n### Checklist\r\n\r\n- [ ] ~Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~\r\n- [ ]\r\n~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials~\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] ~Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard\r\naccessibility](https://webaim.org/techniques/keyboard/))~\r\n- [ ] ~Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~\r\n- [ ] ~If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~\r\n- [ ] ~This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~\r\n- [ ] ~This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)~\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>","sha":"ab2f967ba5720daffa8d404802effe688804d41c"}}]}] BACKPORT--> Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
119 lines
4 KiB
TypeScript
119 lines
4 KiB
TypeScript
/*
|
|
* 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 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import expect from '@kbn/expect';
|
|
import _ from 'lodash';
|
|
import { FtrProviderContext } from '../../../ftr_provider_context';
|
|
|
|
/**
|
|
* Test usage of different index patterns APIs in combination
|
|
*/
|
|
export default function ({ getService }: FtrProviderContext) {
|
|
const supertest = getService('supertest');
|
|
const esArchiver = getService('esArchiver');
|
|
|
|
describe('integration', () => {
|
|
before(async () => {
|
|
await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index');
|
|
});
|
|
|
|
after(async () => {
|
|
await esArchiver.unload(
|
|
'test/api_integration/fixtures/es_archiver/index_patterns/basic_index'
|
|
);
|
|
});
|
|
|
|
it('create an index pattern, add a runtime field, add a field formatter, then re-create the same index pattern', async () => {
|
|
const title = `basic_index*`;
|
|
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
|
|
override: true,
|
|
index_pattern: {
|
|
title,
|
|
},
|
|
});
|
|
const id = response1.body.index_pattern.id;
|
|
const response2 = await supertest
|
|
.post(`/api/index_patterns/index_pattern/${id}/runtime_field`)
|
|
.send({
|
|
name: 'runtimeBar',
|
|
runtimeField: {
|
|
type: 'long',
|
|
script: {
|
|
source: "emit(doc['field_name'].value)",
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response2.status).to.be(200);
|
|
|
|
const response3 = await supertest
|
|
.post(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/fields`)
|
|
.send({
|
|
fields: {
|
|
runtimeBar: {
|
|
count: 123,
|
|
customLabel: 'test',
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response3.status).to.be(200);
|
|
|
|
const response4 = await supertest
|
|
.post(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/fields`)
|
|
.send({
|
|
fields: {
|
|
runtimeBar: {
|
|
format: {
|
|
id: 'duration',
|
|
params: { inputFormat: 'milliseconds', outputFormat: 'humanizePrecise' },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response4.status).to.be(200);
|
|
|
|
const response5 = await supertest.get(
|
|
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
|
|
);
|
|
|
|
expect(response5.status).to.be(200);
|
|
|
|
const resultIndexPattern = response5.body.index_pattern;
|
|
|
|
const runtimeField = resultIndexPattern.fields.runtimeBar;
|
|
expect(runtimeField.name).to.be('runtimeBar');
|
|
expect(runtimeField.runtimeField.type).to.be('long');
|
|
expect(runtimeField.runtimeField.script.source).to.be("emit(doc['field_name'].value)");
|
|
expect(runtimeField.scripted).to.be(false);
|
|
|
|
expect(resultIndexPattern.fieldFormats.runtimeBar.id).to.be('duration');
|
|
expect(resultIndexPattern.fieldFormats.runtimeBar.params.inputFormat).to.be('milliseconds');
|
|
expect(resultIndexPattern.fieldFormats.runtimeBar.params.outputFormat).to.be(
|
|
'humanizePrecise'
|
|
);
|
|
|
|
expect(resultIndexPattern.fieldAttrs.runtimeBar.count).to.be(123);
|
|
expect(resultIndexPattern.fieldAttrs.runtimeBar.customLabel).to.be('test');
|
|
|
|
// check that retrieved object is transient and a clone can be created
|
|
const response6 = await supertest.post('/api/index_patterns/index_pattern').send({
|
|
override: true,
|
|
index_pattern: resultIndexPattern,
|
|
});
|
|
|
|
expect(response6.status).to.be(200);
|
|
const recreatedIndexPattern = response6.body.index_pattern;
|
|
|
|
expect(_.omit(recreatedIndexPattern, 'version', 'namespaces')).to.eql(
|
|
_.omit(resultIndexPattern, 'version')
|
|
);
|
|
});
|
|
});
|
|
}
|