diff --git a/.ci/Jenkinsfile_flaky b/.ci/Jenkinsfile_flaky index 8121405e5ae24..7eafc66465bc7 100644 --- a/.ci/Jenkinsfile_flaky +++ b/.ci/Jenkinsfile_flaky @@ -73,7 +73,11 @@ def agentProcess(Map params = [:]) { ]) { task { if (config.needBuild) { - kibanaPipeline.buildKibana() + if (!config.isXpack) { + kibanaPipeline.buildOss() + } else { + kibanaPipeline.buildXpack() + } } for(def i = 0; i < config.agentExecutions; i++) { diff --git a/.ci/Jenkinsfile_security_cypress b/.ci/Jenkinsfile_security_cypress index d48b9965919dc..811af44d1ca56 100644 --- a/.ci/Jenkinsfile_security_cypress +++ b/.ci/Jenkinsfile_security_cypress @@ -16,7 +16,7 @@ kibanaPipeline(timeoutMinutes: 180) { def job = 'xpack-securityCypress' workers.ci(name: job, size: 'l', ramDisk: true) { - kibanaPipeline.bash('test/scripts/jenkins_build_kibana.sh', 'Build Distributable') + kibanaPipeline.bash('test/scripts/jenkins_xpack_build_kibana.sh', 'Build Default Distributable') kibanaPipeline.functionalTestProcess(job, 'test/scripts/jenkins_security_solution_cypress_chrome.sh')() // Temporarily disabled to figure out test flake // kibanaPipeline.functionalTestProcess(job, 'test/scripts/jenkins_security_solution_cypress_firefox.sh')() diff --git a/.ci/es-snapshots/Jenkinsfile_verify_es b/.ci/es-snapshots/Jenkinsfile_verify_es index dc3a3cde7d658..d56ec61314ac7 100644 --- a/.ci/es-snapshots/Jenkinsfile_verify_es +++ b/.ci/es-snapshots/Jenkinsfile_verify_es @@ -37,8 +37,12 @@ kibanaPipeline(timeoutMinutes: 210) { ]) task { - kibanaPipeline.buildKibana(16) + kibanaPipeline.buildOss(6) tasks.ossCiGroups() + } + + task { + kibanaPipeline.buildXpack(10, true) tasks.xpackCiGroups() tasks.xpackCiGroupDocker() } diff --git a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts index 11694416807b0..29c0a03ab61fc 100644 --- a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts @@ -168,7 +168,6 @@ export async function createDefaultSpace({ index, type: '_doc', id: 'space:default', - refresh: 'wait_for', body: { type: 'space', updated_at: new Date().toISOString(), diff --git a/packages/kbn-test/src/kbn_client/kbn_client.ts b/packages/kbn-test/src/kbn_client/kbn_client.ts index e44f500593300..a0f7ff3759d40 100644 --- a/packages/kbn-test/src/kbn_client/kbn_client.ts +++ b/packages/kbn-test/src/kbn_client/kbn_client.ts @@ -8,14 +8,13 @@ import { ToolingLog } from '@kbn/dev-utils'; -import { KbnClientImportExport } from './kbn_client_import_export'; -import { KbnClientPlugins } from './kbn_client_plugins'; import { KbnClientRequester, ReqOptions } from './kbn_client_requester'; -import { KbnClientSavedObjects } from './kbn_client_saved_objects'; -import { KbnClientSpaces } from './kbn_client_spaces'; import { KbnClientStatus } from './kbn_client_status'; -import { KbnClientUiSettings, UiSettingValues } from './kbn_client_ui_settings'; +import { KbnClientPlugins } from './kbn_client_plugins'; import { KbnClientVersion } from './kbn_client_version'; +import { KbnClientSavedObjects } from './kbn_client_saved_objects'; +import { KbnClientUiSettings, UiSettingValues } from './kbn_client_ui_settings'; +import { KbnClientImportExport } from './kbn_client_import_export'; export interface KbnClientOptions { url: string; @@ -30,7 +29,6 @@ export class KbnClient { readonly plugins: KbnClientPlugins; readonly version: KbnClientVersion; readonly savedObjects: KbnClientSavedObjects; - readonly spaces: KbnClientSpaces; readonly uiSettings: KbnClientUiSettings; readonly importExport: KbnClientImportExport; @@ -61,7 +59,6 @@ export class KbnClient { this.plugins = new KbnClientPlugins(this.status); this.version = new KbnClientVersion(this.status); this.savedObjects = new KbnClientSavedObjects(this.log, this.requester); - this.spaces = new KbnClientSpaces(this.requester); this.uiSettings = new KbnClientUiSettings(this.log, this.requester, this.uiSettingDefaults); this.importExport = new KbnClientImportExport( this.log, diff --git a/packages/kbn-test/src/kbn_client/kbn_client_requester.ts b/packages/kbn-test/src/kbn_client/kbn_client_requester.ts index a194b593b3863..af75137d148e9 100644 --- a/packages/kbn-test/src/kbn_client/kbn_client_requester.ts +++ b/packages/kbn-test/src/kbn_client/kbn_client_requester.ts @@ -121,8 +121,6 @@ export class KbnClientRequester { responseType: options.responseType, // work around https://github.com/axios/axios/issues/2791 transformResponse: options.responseType === 'text' ? [(x) => x] : undefined, - maxContentLength: 30000000, - maxBodyLength: 30000000, paramsSerializer: (params) => Qs.stringify(params), }); diff --git a/packages/kbn-test/src/kbn_client/kbn_client_spaces.ts b/packages/kbn-test/src/kbn_client/kbn_client_spaces.ts deleted file mode 100644 index e88531606e917..0000000000000 --- a/packages/kbn-test/src/kbn_client/kbn_client_spaces.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 { KbnClientRequester, uriencode } from './kbn_client_requester'; - -interface UpdateBody { - name: string; - description?: string; - disabledFeatures?: string | string[]; - initials?: string; - color?: string; - imageUrl?: string; -} - -interface CreateBody extends UpdateBody { - id: string; -} - -export class KbnClientSpaces { - constructor(private readonly requester: KbnClientRequester) {} - - async create(body: CreateBody) { - await this.requester.request({ - method: 'POST', - path: '/api/spaces/space', - body, - }); - } - - async update(id: string, body: UpdateBody) { - await this.requester.request({ - method: 'PUT', - path: uriencode`/api/spaces/space/${id}`, - body, - }); - } - - async get(id: string) { - const { data } = await this.requester.request({ - method: 'GET', - path: uriencode`/api/spaces/space/${id}`, - }); - - return data; - } - - async list() { - const { data } = await this.requester.request({ - method: 'GET', - path: '/api/spaces/space', - }); - - return data; - } - - async delete(id: string) { - await this.requester.request({ - method: 'DELETE', - path: uriencode`/api/spaces/space/${id}`, - }); - } -} diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index f5b7f266a3166..5c736b35a4726 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -40,7 +40,6 @@ export const IGNORE_FILE_GLOBS = [ '.ci/pipeline-library/**/*', 'packages/kbn-test/jest-preset.js', 'test/package/Vagrantfile', - '**/test/**/fixtures/**/*', // filename must match language code which requires capital letters '**/translations/*.json', @@ -61,6 +60,8 @@ export const IGNORE_FILE_GLOBS = [ 'x-pack/plugins/apm/e2e/**/*', 'x-pack/plugins/maps/server/fonts/**/*', + // packages for the ingest manager's api integration tests could be valid semver which has dashes + 'x-pack/test/fleet_api_integration/apis/fixtures/test_packages/**/*', // Bazel default files '**/WORKSPACE.bazel', @@ -96,6 +97,7 @@ export const IGNORE_DIRECTORY_GLOBS = [ ...KEBAB_CASE_DIRECTORY_GLOBS, 'src/babel-*', 'packages/*', + 'test/functional/fixtures/es_archiver/visualize_source-filters', 'packages/kbn-pm/src/utils/__fixtures__/*', 'x-pack/dev-tools', 'packages/kbn-optimizer/src/__fixtures__/mock_repo/x-pack', diff --git a/test/accessibility/apps/dashboard_panel.ts b/test/accessibility/apps/dashboard_panel.ts index 2a6c290172a9e..77b6cf2dbb6da 100644 --- a/test/accessibility/apps/dashboard_panel.ts +++ b/test/accessibility/apps/dashboard_panel.ts @@ -63,8 +63,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('dashboard panel full screen', async () => { const header = await dashboardPanelActions.getPanelHeading('[Flights] Airline Carrier'); await dashboardPanelActions.toggleContextMenu(header); - await dashboardPanelActions.clickContextMenuMoreItem(); - await testSubjects.click('embeddablePanelAction-togglePanel'); await a11y.testAppSnapshot(); }); diff --git a/test/api_integration/apis/home/sample_data.ts b/test/api_integration/apis/home/sample_data.ts index c681ad325e56f..99327901ec8c3 100644 --- a/test/api_integration/apis/home/sample_data.ts +++ b/test/api_integration/apis/home/sample_data.ts @@ -43,7 +43,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.body).to.eql({ elasticsearchIndicesCreated: { kibana_sample_data_flights: 13059 }, - kibanaSavedObjectsLoaded: 23, + kibanaSavedObjectsLoaded: 20, }); }); diff --git a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts index 5770ed0866a90..f258804e7e122 100644 --- a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts +++ b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts @@ -13,20 +13,12 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); const es = getService('es'); describe('telemetry API', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); + before(() => esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic')); + after(() => esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic')); it('should increment the opt *in* counter in the .kibana/kql-telemetry document', async () => { await supertest diff --git a/test/api_integration/apis/saved_objects/bulk_create.ts b/test/api_integration/apis/saved_objects/bulk_create.ts index 5867b8125303a..c898649449c09 100644 --- a/test/api_integration/apis/saved_objects/bulk_create.ts +++ b/test/api_integration/apis/saved_objects/bulk_create.ts @@ -12,8 +12,8 @@ import { getKibanaVersion } from './lib/saved_objects_test_utils'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); - const SPACE_ID = 'ftr-so-bulk-create'; + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); const BULK_REQUESTS = [ { @@ -38,61 +38,103 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', - { space: SPACE_ID } - ); }); - after(() => kibanaServer.spaces.delete(SPACE_ID)); + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); - it('should return 200 with individual responses', async () => - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_bulk_create`) - .send(BULK_REQUESTS) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - saved_objects: [ - { - type: 'visualization', - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - error: { - error: 'Conflict', - message: - 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] conflict', - statusCode: 409, + it('should return 200 with individual responses', async () => + await supertest + .post(`/api/saved_objects/_bulk_create`) + .send(BULK_REQUESTS) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + saved_objects: [ + { + type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + error: { + error: 'Conflict', + message: + 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] conflict', + statusCode: 409, + }, }, - }, - { - type: 'dashboard', - id: 'a01b2f57-fcfd-4864-b735-09e28f0d815e', - updated_at: resp.body.saved_objects[1].updated_at, - version: resp.body.saved_objects[1].version, - attributes: { - title: 'A great new dashboard', + { + type: 'dashboard', + id: 'a01b2f57-fcfd-4864-b735-09e28f0d815e', + updated_at: resp.body.saved_objects[1].updated_at, + version: resp.body.saved_objects[1].version, + attributes: { + title: 'A great new dashboard', + }, + migrationVersion: { + dashboard: resp.body.saved_objects[1].migrationVersion.dashboard, + }, + coreMigrationVersion: KIBANA_VERSION, + references: [], + namespaces: ['default'], }, - migrationVersion: { - dashboard: resp.body.saved_objects[1].migrationVersion.dashboard, + ], + }); + })); + + it('should not return raw id when object id is unspecified', async () => + await supertest + .post(`/api/saved_objects/_bulk_create`) + .send(BULK_REQUESTS.map(({ id, ...rest }) => rest)) + .expect(200) + .then((resp) => { + resp.body.saved_objects.map(({ id }: { id: string }) => + expect(id).not.match(/visualization|dashboard/) + ); + })); + }); + + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 200 with errors', async () => { + await new Promise((resolve) => setTimeout(resolve, 2000)); + await supertest + .post('/api/saved_objects/_bulk_create') + .send(BULK_REQUESTS) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + saved_objects: [ + { + id: BULK_REQUESTS[0].id, + type: BULK_REQUESTS[0].type, + error: { + error: 'Internal Server Error', + message: 'An internal server error occurred', + statusCode: 500, + }, + }, + { + id: BULK_REQUESTS[1].id, + type: BULK_REQUESTS[1].type, + error: { + error: 'Internal Server Error', + message: 'An internal server error occurred', + statusCode: 500, + }, }, - coreMigrationVersion: KIBANA_VERSION, - references: [], - namespaces: [SPACE_ID], - }, - ], + ], + }); }); - })); - - it('should not return raw id when object id is unspecified', async () => - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_bulk_create`) - .send(BULK_REQUESTS.map(({ id, ...rest }) => rest)) - .expect(200) - .then((resp) => { - resp.body.saved_objects.map(({ id }: { id: string }) => - expect(id).not.match(/visualization|dashboard/) - ); - })); + }); + }); }); } diff --git a/test/api_integration/apis/saved_objects/bulk_get.ts b/test/api_integration/apis/saved_objects/bulk_get.ts index e349482960678..73765e194f93e 100644 --- a/test/api_integration/apis/saved_objects/bulk_get.ts +++ b/test/api_integration/apis/saved_objects/bulk_get.ts @@ -12,7 +12,8 @@ import { getKibanaVersion } from './lib/saved_objects_test_utils'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); const BULK_REQUESTS = [ { @@ -34,81 +35,125 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); + + it('should return 200 with individual responses', async () => + await supertest + .post(`/api/saved_objects/_bulk_get`) + .send(BULK_REQUESTS) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + saved_objects: [ + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + type: 'visualization', + updated_at: '2017-09-21T18:51:23.794Z', + version: resp.body.saved_objects[0].version, + attributes: { + title: 'Count of requests', + description: '', + version: 1, + // cheat for some of the more complex attributes + visState: resp.body.saved_objects[0].attributes.visState, + uiStateJSON: resp.body.saved_objects[0].attributes.uiStateJSON, + kibanaSavedObjectMeta: + resp.body.saved_objects[0].attributes.kibanaSavedObjectMeta, + }, + migrationVersion: resp.body.saved_objects[0].migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + namespaces: ['default'], + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: '91200a00-9efd-11e7-acb3-3dab96693fab', + }, + ], + }, + { + id: 'does not exist', + type: 'dashboard', + error: { + error: 'Not Found', + message: 'Saved object [dashboard/does not exist] not found', + statusCode: 404, + }, + }, + { + id: '7.0.0-alpha1', + type: 'config', + updated_at: '2017-09-21T18:49:16.302Z', + version: resp.body.saved_objects[2].version, + attributes: { + buildNum: 8467, + defaultIndex: '91200a00-9efd-11e7-acb3-3dab96693fab', + }, + namespaces: ['default'], + migrationVersion: resp.body.saved_objects[2].migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + references: [], + }, + ], + }); + expect(resp.body.saved_objects[0].migrationVersion).to.be.ok(); + })); }); - it('should return 200 with individual responses', async () => - await supertest - .post(`/api/saved_objects/_bulk_get`) - .send(BULK_REQUESTS) - .expect(200) - .then((resp) => { - const mockDate = '2015-01-01T00:00:00.000Z'; - resp.body.saved_objects[0].updated_at = mockDate; - resp.body.saved_objects[2].updated_at = mockDate; + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); - expect(resp.body).to.eql({ - saved_objects: [ - { - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - type: 'visualization', - updated_at: '2015-01-01T00:00:00.000Z', - version: resp.body.saved_objects[0].version, - attributes: { - title: 'Count of requests', - description: '', - version: 1, - // cheat for some of the more complex attributes - visState: resp.body.saved_objects[0].attributes.visState, - uiStateJSON: resp.body.saved_objects[0].attributes.uiStateJSON, - kibanaSavedObjectMeta: - resp.body.saved_objects[0].attributes.kibanaSavedObjectMeta, + it('should return 200 with individual responses', async () => + await supertest + .post('/api/saved_objects/_bulk_get') + .send(BULK_REQUESTS) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + saved_objects: [ + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + type: 'visualization', + error: { + error: 'Not Found', + message: + 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] not found', + statusCode: 404, + }, }, - migrationVersion: resp.body.saved_objects[0].migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - namespaces: ['default'], - references: [ - { - name: 'kibanaSavedObjectMeta.searchSourceJSON.index', - type: 'index-pattern', - id: '91200a00-9efd-11e7-acb3-3dab96693fab', + { + id: 'does not exist', + type: 'dashboard', + error: { + error: 'Not Found', + message: 'Saved object [dashboard/does not exist] not found', + statusCode: 404, }, - ], - }, - { - id: 'does not exist', - type: 'dashboard', - error: { - error: 'Not Found', - message: 'Saved object [dashboard/does not exist] not found', - statusCode: 404, }, - }, - { - id: '7.0.0-alpha1', - type: 'config', - updated_at: '2015-01-01T00:00:00.000Z', - version: resp.body.saved_objects[2].version, - attributes: { - buildNum: 8467, - defaultIndex: '91200a00-9efd-11e7-acb3-3dab96693fab', + { + id: '7.0.0-alpha1', + type: 'config', + error: { + error: 'Not Found', + message: 'Saved object [config/7.0.0-alpha1] not found', + statusCode: 404, + }, }, - namespaces: ['default'], - migrationVersion: resp.body.saved_objects[2].migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - references: [], - }, - ], - }); - expect(resp.body.saved_objects[0].migrationVersion).to.be.ok(); - })); + ], + }); + })); + }); }); } diff --git a/test/api_integration/apis/saved_objects/bulk_update.ts b/test/api_integration/apis/saved_objects/bulk_update.ts index cf402bf2f6221..c187d879a38fe 100644 --- a/test/api_integration/apis/saved_objects/bulk_update.ts +++ b/test/api_integration/apis/saved_objects/bulk_update.ts @@ -12,188 +12,243 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('bulkUpdate', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); + it('should return 200', async () => { + const response = await supertest + .put(`/api/saved_objects/_bulk_update`) + .send([ + { + type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + attributes: { + title: 'An existing visualization', + }, + }, + { + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + attributes: { + title: 'An existing dashboard', + }, + }, + ]) + .expect(200); + + const { + saved_objects: [firstObject, secondObject], + } = response.body; - it('should return 200', async () => { - const response = await supertest - .put(`/api/saved_objects/_bulk_update`) - .send([ + // loose ISO8601 UTC time with milliseconds validation + expect(firstObject) + .to.have.property('updated_at') + .match(/^[\d-]{10}T[\d:\.]{12}Z$/); + expect(_.omit(firstObject, ['updated_at'])).to.eql({ + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + type: 'visualization', + version: firstObject.version, + attributes: { + title: 'An existing visualization', + }, + namespaces: ['default'], + }); + + expect(secondObject) + .to.have.property('updated_at') + .match(/^[\d-]{10}T[\d:\.]{12}Z$/); + expect(_.omit(secondObject, ['updated_at'])).to.eql({ + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + type: 'dashboard', + version: secondObject.version, + attributes: { + title: 'An existing dashboard', + }, + namespaces: ['default'], + }); + }); + + it('does not pass references if omitted', async () => { + const { + body: { + saved_objects: [visObject, dashObject], + }, + } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ { type: 'visualization', id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - attributes: { - title: 'An existing visualization', - }, }, { type: 'dashboard', id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - attributes: { - title: 'An existing dashboard', - }, }, - ]) - .expect(200); - - const { - saved_objects: [firstObject, secondObject], - } = response.body; - - // loose ISO8601 UTC time with milliseconds validation - expect(firstObject) - .to.have.property('updated_at') - .match(/^[\d-]{10}T[\d:\.]{12}Z$/); - expect(_.omit(firstObject, ['updated_at'])).to.eql({ - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - type: 'visualization', - version: firstObject.version, - attributes: { - title: 'An existing visualization', - }, - namespaces: ['default'], - }); + ]); - expect(secondObject) - .to.have.property('updated_at') - .match(/^[\d-]{10}T[\d:\.]{12}Z$/); - expect(_.omit(secondObject, ['updated_at'])).to.eql({ - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - type: 'dashboard', - version: secondObject.version, - attributes: { - title: 'An existing dashboard', - }, - namespaces: ['default'], - }); - }); + const response = await supertest + .put(`/api/saved_objects/_bulk_update`) + .send([ + { + type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + attributes: { + title: 'Changed title but nothing else', + }, + version: visObject.version, + }, + { + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + attributes: { + title: 'Changed title and references', + }, + version: dashObject.version, + references: [{ id: 'foo', name: 'Foo', type: 'visualization' }], + }, + ]) + .expect(200); - it('does not pass references if omitted', async () => { - const { - body: { - saved_objects: [visObject, dashObject], - }, - } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ - { - type: 'visualization', - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - }, - { - type: 'dashboard', - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - }, - ]); + const { + saved_objects: [firstUpdatedObject, secondUpdatedObject], + } = response.body; + expect(firstUpdatedObject).to.not.have.property('error'); + expect(secondUpdatedObject).to.not.have.property('error'); - const response = await supertest - .put(`/api/saved_objects/_bulk_update`) - .send([ + const { + body: { + saved_objects: [visObjectAfterUpdate, dashObjectAfterUpdate], + }, + } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ { type: 'visualization', id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - attributes: { - title: 'Changed title but nothing else', - }, - version: visObject.version, }, { type: 'dashboard', id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - attributes: { - title: 'Changed title and references', - }, - version: dashObject.version, - references: [{ id: 'foo', name: 'Foo', type: 'visualization' }], }, - ]) - .expect(200); - - const { - saved_objects: [firstUpdatedObject, secondUpdatedObject], - } = response.body; - expect(firstUpdatedObject).to.not.have.property('error'); - expect(secondUpdatedObject).to.not.have.property('error'); - - const { - body: { - saved_objects: [visObjectAfterUpdate, dashObjectAfterUpdate], - }, - } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ - { - type: 'visualization', - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - }, - { - type: 'dashboard', - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - }, - ]); + ]); - expect(visObjectAfterUpdate.references).to.eql(visObject.references); - expect(dashObjectAfterUpdate.references).to.eql([ - { id: 'foo', name: 'Foo', type: 'visualization' }, - ]); - }); - - it('passes empty references array if empty references array is provided', async () => { - const { - body: { - saved_objects: [{ version }], - }, - } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ - { - type: 'visualization', - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - }, - ]); + expect(visObjectAfterUpdate.references).to.eql(visObject.references); + expect(dashObjectAfterUpdate.references).to.eql([ + { id: 'foo', name: 'Foo', type: 'visualization' }, + ]); + }); - await supertest - .put(`/api/saved_objects/_bulk_update`) - .send([ + it('passes empty references array if empty references array is provided', async () => { + const { + body: { + saved_objects: [{ version }], + }, + } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ { type: 'visualization', id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - attributes: { - title: 'Changed title but nothing else', + }, + ]); + + await supertest + .put(`/api/saved_objects/_bulk_update`) + .send([ + { + type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + attributes: { + title: 'Changed title but nothing else', + }, + version, + references: [], }, - version, - references: [], + ]) + .expect(200); + + const { + body: { + saved_objects: [visObjectAfterUpdate], }, - ]) - .expect(200); - - const { - body: { - saved_objects: [visObjectAfterUpdate], - }, - } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ - { - type: 'visualization', - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - }, - ]); + } = await supertest.post(`/api/saved_objects/_bulk_get`).send([ + { + type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + }, + ]); + + expect(visObjectAfterUpdate.references).to.eql([]); + }); + + describe('unknown id', () => { + it('should return a generic 404', async () => { + const response = await supertest + .put(`/api/saved_objects/_bulk_update`) + .send([ + { + type: 'visualization', + id: 'not an id', + attributes: { + title: 'An existing visualization', + }, + }, + { + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + attributes: { + title: 'An existing dashboard', + }, + }, + ]) + .expect(200); + + const { + saved_objects: [missingObject, updatedObject], + } = response.body; + + // loose ISO8601 UTC time with milliseconds validation + expect(missingObject).eql({ + type: 'visualization', + id: 'not an id', + error: { + statusCode: 404, + error: 'Not Found', + message: 'Saved object [visualization/not an id] not found', + }, + }); - expect(visObjectAfterUpdate.references).to.eql([]); + expect(updatedObject) + .to.have.property('updated_at') + .match(/^[\d-]{10}T[\d:\.]{12}Z$/); + expect(_.omit(updatedObject, ['updated_at', 'version'])).to.eql({ + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + type: 'dashboard', + attributes: { + title: 'An existing dashboard', + }, + namespaces: ['default'], + }); + }); + }); }); - describe('unknown id', () => { - it('should return a generic 404', async () => { + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 200 with errors', async () => { const response = await supertest .put(`/api/saved_objects/_bulk_update`) .send([ { type: 'visualization', - id: 'not an id', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', attributes: { title: 'An existing visualization', }, @@ -209,30 +264,27 @@ export default function ({ getService }: FtrProviderContext) { .expect(200); const { - saved_objects: [missingObject, updatedObject], + saved_objects: [firstObject, secondObject], } = response.body; - // loose ISO8601 UTC time with milliseconds validation - expect(missingObject).eql({ + expect(firstObject).to.eql({ + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', type: 'visualization', - id: 'not an id', error: { - statusCode: 404, - error: 'Not Found', - message: 'Saved object [visualization/not an id] not found', + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred', }, }); - expect(updatedObject) - .to.have.property('updated_at') - .match(/^[\d-]{10}T[\d:\.]{12}Z$/); - expect(_.omit(updatedObject, ['updated_at', 'version'])).to.eql({ + expect(secondObject).to.eql({ id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', type: 'dashboard', - attributes: { - title: 'An existing dashboard', + error: { + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred', }, - namespaces: ['default'], }); }); }); diff --git a/test/api_integration/apis/saved_objects/create.ts b/test/api_integration/apis/saved_objects/create.ts index 00018e47c9dd3..72eb4493e6ef0 100644 --- a/test/api_integration/apis/saved_objects/create.ts +++ b/test/api_integration/apis/saved_objects/create.ts @@ -12,74 +12,103 @@ import { getKibanaVersion } from './lib/saved_objects_test_utils'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const es = getService('es'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('create', () => { let KIBANA_VERSION: string; before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + it('should return 200', async () => { + await supertest + .post(`/api/saved_objects/visualization`) + .send({ + attributes: { + title: 'My favorite vis', + }, + }) + .expect(200) + .then((resp) => { + // loose uuid validation + expect(resp.body) + .to.have.property('id') + .match(/^[0-9a-f-]{36}$/); - it('should return 200', async () => { - await supertest - .post(`/api/saved_objects/visualization`) - .send({ - attributes: { - title: 'My favorite vis', - }, - }) - .expect(200) - .then((resp) => { - // loose uuid validation - expect(resp.body) - .to.have.property('id') - .match(/^[0-9a-f-]{36}$/); + // loose ISO8601 UTC time with milliseconds validation + expect(resp.body) + .to.have.property('updated_at') + .match(/^[\d-]{10}T[\d:\.]{12}Z$/); - // loose ISO8601 UTC time with milliseconds validation - expect(resp.body) - .to.have.property('updated_at') - .match(/^[\d-]{10}T[\d:\.]{12}Z$/); + expect(resp.body).to.eql({ + id: resp.body.id, + type: 'visualization', + migrationVersion: resp.body.migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + updated_at: resp.body.updated_at, + version: resp.body.version, + attributes: { + title: 'My favorite vis', + }, + references: [], + namespaces: ['default'], + }); + expect(resp.body.migrationVersion).to.be.ok(); + }); + }); - expect(resp.body).to.eql({ - id: resp.body.id, - type: 'visualization', - migrationVersion: resp.body.migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - updated_at: resp.body.updated_at, - version: resp.body.version, + it('result should be updated to the latest coreMigrationVersion', async () => { + await supertest + .post(`/api/saved_objects/visualization`) + .send({ attributes: { title: 'My favorite vis', }, - references: [], - namespaces: ['default'], + coreMigrationVersion: '1.2.3', + }) + .expect(200) + .then((resp) => { + expect(resp.body.coreMigrationVersion).to.eql(KIBANA_VERSION); }); - expect(resp.body.migrationVersion).to.be.ok(); - }); + }); }); - it('result should be updated to the latest coreMigrationVersion', async () => { - await supertest - .post(`/api/saved_objects/visualization`) - .send({ - attributes: { - title: 'My favorite vis', - }, - coreMigrationVersion: '1.2.3', - }) - .expect(200) - .then((resp) => { - expect(resp.body.coreMigrationVersion).to.eql(KIBANA_VERSION); - }); + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 500 and not auto-create saved objects index', async () => { + await supertest + .post(`/api/saved_objects/visualization`) + .send({ + attributes: { + title: 'My favorite vis', + }, + }) + .expect(500) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Internal Server Error', + message: 'An internal server error occurred.', + statusCode: 500, + }); + }); + + expect((await es.indices.exists({ index: '.kibana' })).body).to.be(false); + }); }); }); } diff --git a/test/api_integration/apis/saved_objects/delete.ts b/test/api_integration/apis/saved_objects/delete.ts index fc38050deabff..1145e5405f122 100644 --- a/test/api_integration/apis/saved_objects/delete.ts +++ b/test/api_integration/apis/saved_objects/delete.ts @@ -11,38 +11,57 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('delete', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); + + it('should return 200 when deleting a doc', async () => + await supertest + .delete(`/api/saved_objects/dashboard/be3733a0-9efe-11e7-acb3-3dab96693fab`) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({}); + })); + + it('should return generic 404 when deleting an unknown doc', async () => + await supertest + .delete(`/api/saved_objects/dashboard/not-a-real-id`) + .expect(404) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 404, + error: 'Not Found', + message: 'Saved object [dashboard/not-a-real-id] not found', + }); + })); }); - it('should return 200 when deleting a doc', async () => - await supertest - .delete(`/api/saved_objects/dashboard/be3733a0-9efe-11e7-acb3-3dab96693fab`) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({}); - })); + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); - it('should return generic 404 when deleting an unknown doc', async () => - await supertest - .delete(`/api/saved_objects/dashboard/not-a-real-id`) - .expect(404) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 404, - error: 'Not Found', - message: 'Saved object [dashboard/not-a-real-id] not found', - }); - })); + it('returns generic 404 when kibana index is missing', async () => + await supertest + .delete(`/api/saved_objects/dashboard/be3733a0-9efe-11e7-acb3-3dab96693fab`) + .expect(404) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 404, + error: 'Not Found', + message: 'Saved object [dashboard/be3733a0-9efe-11e7-acb3-3dab96693fab] not found', + }); + })); + }); }); } diff --git a/test/api_integration/apis/saved_objects/export.ts b/test/api_integration/apis/saved_objects/export.ts index 6314fbbe675d0..000b7f155a743 100644 --- a/test/api_integration/apis/saved_objects/export.ts +++ b/test/api_integration/apis/saved_objects/export.ts @@ -15,562 +15,581 @@ function ndjsonToObject(input: string) { } export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); - const SPACE_ID = 'ftr-so-export'; + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('export', () => { let KIBANA_VERSION: string; before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', - { space: SPACE_ID } - ); }); - after(() => kibanaServer.spaces.delete(SPACE_ID)); + describe('with kibana index', () => { + describe('basic amount of saved objects', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); - describe('basic amount of saved objects', () => { - it('should return objects in dependency order', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: ['index-pattern', 'search', 'visualization', 'dashboard'], - }) - .expect(200) - .then((resp) => { - const objects = ndjsonToObject(resp.text); - expect(objects).to.have.length(4); - expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); - expect(objects[0]).to.have.property('type', 'index-pattern'); - expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); - expect(objects[1]).to.have.property('type', 'visualization'); - expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); - expect(objects[2]).to.have.property('type', 'dashboard'); - expect(objects[3]).to.have.property('exportedCount', 3); - expect(objects[3]).to.have.property('missingRefCount', 0); - expect(objects[3].missingReferences).to.have.length(0); - }); - }); + it('should return objects in dependency order', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: ['index-pattern', 'search', 'visualization', 'dashboard'], + }) + .expect(200) + .then((resp) => { + const objects = ndjsonToObject(resp.text); + expect(objects).to.have.length(4); + expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); + expect(objects[0]).to.have.property('type', 'index-pattern'); + expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); + expect(objects[1]).to.have.property('type', 'visualization'); + expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); + expect(objects[2]).to.have.property('type', 'dashboard'); + expect(objects[3]).to.have.property('exportedCount', 3); + expect(objects[3]).to.have.property('missingRefCount', 0); + expect(objects[3].missingReferences).to.have.length(0); + }); + }); - it('should exclude the export details if asked', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: ['index-pattern', 'search', 'visualization', 'dashboard'], - excludeExportDetails: true, - }) - .expect(200) - .then((resp) => { - const objects = ndjsonToObject(resp.text); - expect(objects).to.have.length(3); - expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); - expect(objects[0]).to.have.property('type', 'index-pattern'); - expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); - expect(objects[1]).to.have.property('type', 'visualization'); - expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); - expect(objects[2]).to.have.property('type', 'dashboard'); - }); - }); + it('should exclude the export details if asked', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: ['index-pattern', 'search', 'visualization', 'dashboard'], + excludeExportDetails: true, + }) + .expect(200) + .then((resp) => { + const objects = ndjsonToObject(resp.text); + expect(objects).to.have.length(3); + expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); + expect(objects[0]).to.have.property('type', 'index-pattern'); + expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); + expect(objects[1]).to.have.property('type', 'visualization'); + expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); + expect(objects[2]).to.have.property('type', 'dashboard'); + }); + }); - it('should support including dependencies when exporting selected objects', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - includeReferencesDeep: true, - objects: [ - { - type: 'dashboard', - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - }, - ], - }) - .expect(200) - .then((resp) => { - const objects = ndjsonToObject(resp.text); - expect(objects).to.have.length(4); - expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); - expect(objects[0]).to.have.property('type', 'index-pattern'); - expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); - expect(objects[1]).to.have.property('type', 'visualization'); - expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); - expect(objects[2]).to.have.property('type', 'dashboard'); - expect(objects[3]).to.have.property('exportedCount', 3); - expect(objects[3]).to.have.property('missingRefCount', 0); - expect(objects[3].missingReferences).to.have.length(0); - }); - }); + it('should support including dependencies when exporting selected objects', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + includeReferencesDeep: true, + objects: [ + { + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + }, + ], + }) + .expect(200) + .then((resp) => { + const objects = ndjsonToObject(resp.text); + expect(objects).to.have.length(4); + expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); + expect(objects[0]).to.have.property('type', 'index-pattern'); + expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); + expect(objects[1]).to.have.property('type', 'visualization'); + expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); + expect(objects[2]).to.have.property('type', 'dashboard'); + expect(objects[3]).to.have.property('exportedCount', 3); + expect(objects[3]).to.have.property('missingRefCount', 0); + expect(objects[3].missingReferences).to.have.length(0); + }); + }); - it('should support including dependencies when exporting by type', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - includeReferencesDeep: true, - type: ['dashboard'], - }) - .expect(200) - .then((resp) => { - const objects = resp.text.split('\n').map((str) => JSON.parse(str)); - expect(objects).to.have.length(4); - expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); - expect(objects[0]).to.have.property('type', 'index-pattern'); - expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); - expect(objects[1]).to.have.property('type', 'visualization'); - expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); - expect(objects[2]).to.have.property('type', 'dashboard'); - expect(objects[3]).to.have.property('exportedCount', 3); - expect(objects[3]).to.have.property('missingRefCount', 0); - expect(objects[3].missingReferences).to.have.length(0); - }); - }); + it('should support including dependencies when exporting by type', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + includeReferencesDeep: true, + type: ['dashboard'], + }) + .expect(200) + .then((resp) => { + const objects = resp.text.split('\n').map((str) => JSON.parse(str)); + expect(objects).to.have.length(4); + expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); + expect(objects[0]).to.have.property('type', 'index-pattern'); + expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); + expect(objects[1]).to.have.property('type', 'visualization'); + expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); + expect(objects[2]).to.have.property('type', 'dashboard'); + expect(objects[3]).to.have.property('exportedCount', 3); + expect(objects[3]).to.have.property('missingRefCount', 0); + expect(objects[3].missingReferences).to.have.length(0); + }); + }); - it('should support including dependencies when exporting by type and search', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - includeReferencesDeep: true, - type: ['dashboard'], - search: 'Requests*', - }) - .expect(200) - .then((resp) => { - const objects = ndjsonToObject(resp.text); - expect(objects).to.have.length(4); - expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); - expect(objects[0]).to.have.property('type', 'index-pattern'); - expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); - expect(objects[1]).to.have.property('type', 'visualization'); - expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); - expect(objects[2]).to.have.property('type', 'dashboard'); - expect(objects[3]).to.have.property('exportedCount', 3); - expect(objects[3]).to.have.property('missingRefCount', 0); - expect(objects[3].missingReferences).to.have.length(0); - }); - }); + it('should support including dependencies when exporting by type and search', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + includeReferencesDeep: true, + type: ['dashboard'], + search: 'Requests*', + }) + .expect(200) + .then((resp) => { + const objects = ndjsonToObject(resp.text); + expect(objects).to.have.length(4); + expect(objects[0]).to.have.property('id', '91200a00-9efd-11e7-acb3-3dab96693fab'); + expect(objects[0]).to.have.property('type', 'index-pattern'); + expect(objects[1]).to.have.property('id', 'dd7caf20-9efd-11e7-acb3-3dab96693fab'); + expect(objects[1]).to.have.property('type', 'visualization'); + expect(objects[2]).to.have.property('id', 'be3733a0-9efe-11e7-acb3-3dab96693fab'); + expect(objects[2]).to.have.property('type', 'dashboard'); + expect(objects[3]).to.have.property('exportedCount', 3); + expect(objects[3]).to.have.property('missingRefCount', 0); + expect(objects[3].missingReferences).to.have.length(0); + }); + }); - it(`should throw error when object doesn't exist`, async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - objects: [ - { - type: 'dashboard', - id: '1', - }, - ], - }) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: 'Error fetching objects to export', - attributes: { - objects: [ - { - id: '1', - type: 'dashboard', - error: { - error: 'Not Found', - message: 'Saved object [dashboard/1] not found', - statusCode: 404, + it(`should throw error when object doesn't exist`, async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + objects: [ + { + type: 'dashboard', + id: '1', + }, + ], + }) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: 'Error fetching objects to export', + attributes: { + objects: [ + { + id: '1', + type: 'dashboard', + error: { + error: 'Not Found', + message: 'Saved object [dashboard/1] not found', + statusCode: 404, + }, }, - }, - ], - }, + ], + }, + }); }); - }); - }); + }); - it(`should return 400 when exporting unsupported type`, async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: ['wigwags'], - }) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: 'Trying to export non-exportable type(s): wigwags', + it(`should return 400 when exporting unsupported type`, async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: ['wigwags'], + }) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: 'Trying to export non-exportable type(s): wigwags', + }); }); - }); - }); + }); - it(`should return 400 when exporting objects with unsupported type`, async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - objects: [ - { - type: 'wigwags', - id: '1', - }, - ], - }) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: 'Trying to export object(s) with non-exportable types: wigwags:1', + it(`should return 400 when exporting objects with unsupported type`, async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + objects: [ + { + type: 'wigwags', + id: '1', + }, + ], + }) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: 'Trying to export object(s) with non-exportable types: wigwags:1', + }); }); - }); - }); + }); - it('should export object with circular refs', async () => { - const soWithCycliRefs = [ - { - type: 'dashboard', - id: 'dashboard-a', - attributes: { - title: 'dashboard-a', - }, - references: [ - { - name: 'circular-dashboard-ref', - id: 'dashboard-b', - type: 'dashboard', + it('should export object with circular refs', async () => { + const soWithCycliRefs = [ + { + type: 'dashboard', + id: 'dashboard-a', + attributes: { + title: 'dashboard-a', }, - ], - }, - { - type: 'dashboard', - id: 'dashboard-b', - attributes: { - title: 'dashboard-b', + references: [ + { + name: 'circular-dashboard-ref', + id: 'dashboard-b', + type: 'dashboard', + }, + ], }, - references: [ - { - name: 'circular-dashboard-ref', - id: 'dashboard-a', - type: 'dashboard', - }, - ], - }, - ]; - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_bulk_create`) - .send(soWithCycliRefs) - .expect(200); - const resp = await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - includeReferencesDeep: true, - type: ['dashboard'], - }) - .expect(200); - - const objects = ndjsonToObject(resp.text); - expect(objects.find((o) => o.id === 'dashboard-a')).to.be.ok(); - expect(objects.find((o) => o.id === 'dashboard-b')).to.be.ok(); - }); - }); - - describe('10,000 objects', () => { - before(async () => { - const fileChunks = []; - for (let i = 0; i <= 9995; i++) { - fileChunks.push( - JSON.stringify({ - type: 'visualization', - id: `${SPACE_ID}-${i}`, + { + type: 'dashboard', + id: 'dashboard-b', attributes: { - title: `My visualization (${i})`, - uiStateJSON: '{}', - visState: '{}', + title: 'dashboard-b', }, references: [ { - name: 'kibanaSavedObjectMeta.searchSourceJSON.index', - type: 'index-pattern', - id: '91200a00-9efd-11e7-acb3-3dab96693fab', + name: 'circular-dashboard-ref', + id: 'dashboard-a', + type: 'dashboard', }, ], + }, + ]; + await supertest.post('/api/saved_objects/_bulk_create').send(soWithCycliRefs).expect(200); + const resp = await supertest + .post('/api/saved_objects/_export') + .send({ + includeReferencesDeep: true, + type: ['dashboard'], }) - ); - } + .expect(200); - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_import`) - .attach('file', Buffer.from(fileChunks.join('\n'), 'utf8'), 'export.ndjson') - .expect(200); + const objects = ndjsonToObject(resp.text); + expect(objects.find((o) => o.id === 'dashboard-a')).to.be.ok(); + expect(objects.find((o) => o.id === 'dashboard-b')).to.be.ok(); + }); }); - it('should return 400 when exporting without type or objects passed in', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: '[request body]: expected a plain object value, but found [null] instead.', - }); - }); - }); + describe('10,000 objects', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/10k') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/10k') + ); - it('should return 200 when exporting by single type', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: 'dashboard', - excludeExportDetails: true, - }) - .expect(200) - .then((resp) => { - expect(resp.header['content-disposition']).to.eql( - 'attachment; filename="export.ndjson"' - ); - expect(resp.header['content-type']).to.eql('application/ndjson'); - const objects = ndjsonToObject(resp.text); + it('should return 400 when exporting without type or objects passed in', async () => { + await supertest + .post('/api/saved_objects/_export') + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: '[request body]: expected a plain object value, but found [null] instead.', + }); + }); + }); - // Sort values aren't deterministic so we need to exclude them - const { sort, ...obj } = objects[0]; + it('should return 200 when exporting by single type', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: 'dashboard', + excludeExportDetails: true, + }) + .expect(200) + .then((resp) => { + expect(resp.header['content-disposition']).to.eql( + 'attachment; filename="export.ndjson"' + ); + expect(resp.header['content-type']).to.eql('application/ndjson'); + const objects = ndjsonToObject(resp.text); - expect(obj).to.eql({ - attributes: { - description: '', - hits: 0, - kibanaSavedObjectMeta: { - searchSourceJSON: objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON, - }, - optionsJSON: objects[0].attributes.optionsJSON, - panelsJSON: objects[0].attributes.panelsJSON, - refreshInterval: { - display: 'Off', - pause: false, - value: 0, - }, - timeFrom: 'Wed Sep 16 2015 22:52:17 GMT-0700', - timeRestore: true, - timeTo: 'Fri Sep 18 2015 12:24:38 GMT-0700', - title: 'Requests', - version: 1, - }, - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - migrationVersion: objects[0].migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - references: [ - { - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - name: '1:panel_1', - type: 'visualization', + // Sort values aren't deterministic so we need to exclude them + const { sort, ...obj } = objects[0]; + expect(obj).to.eql({ + attributes: { + description: '', + hits: 0, + kibanaSavedObjectMeta: { + searchSourceJSON: objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON, + }, + optionsJSON: objects[0].attributes.optionsJSON, + panelsJSON: objects[0].attributes.panelsJSON, + refreshInterval: { + display: 'Off', + pause: false, + value: 0, + }, + timeFrom: 'Wed Sep 16 2015 22:52:17 GMT-0700', + timeRestore: true, + timeTo: 'Fri Sep 18 2015 12:24:38 GMT-0700', + title: 'Requests', + version: 1, }, - ], - type: 'dashboard', - updated_at: objects[0].updated_at, - version: objects[0].version, + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + migrationVersion: objects[0].migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + references: [ + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + name: '1:panel_1', + type: 'visualization', + }, + ], + type: 'dashboard', + updated_at: '2017-09-21T18:57:40.826Z', + version: objects[0].version, + }); + expect(objects[0].migrationVersion).to.be.ok(); + expect(() => + JSON.parse(objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON) + ).not.to.throwError(); + expect(() => JSON.parse(objects[0].attributes.optionsJSON)).not.to.throwError(); + expect(() => JSON.parse(objects[0].attributes.panelsJSON)).not.to.throwError(); }); - expect(objects[0].migrationVersion).to.be.ok(); - expect(() => - JSON.parse(objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON) - ).not.to.throwError(); - expect(() => JSON.parse(objects[0].attributes.optionsJSON)).not.to.throwError(); - expect(() => JSON.parse(objects[0].attributes.panelsJSON)).not.to.throwError(); - }); - }); + }); - it('should return 200 when exporting by array type', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: ['dashboard'], - excludeExportDetails: true, - }) - .expect(200) - .then((resp) => { - expect(resp.header['content-disposition']).to.eql( - 'attachment; filename="export.ndjson"' - ); - expect(resp.header['content-type']).to.eql('application/ndjson'); - const objects = ndjsonToObject(resp.text); + it('should return 200 when exporting by array type', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: ['dashboard'], + excludeExportDetails: true, + }) + .expect(200) + .then((resp) => { + expect(resp.header['content-disposition']).to.eql( + 'attachment; filename="export.ndjson"' + ); + expect(resp.header['content-type']).to.eql('application/ndjson'); + const objects = ndjsonToObject(resp.text); - // Sort values aren't deterministic so we need to exclude them - const { sort, ...obj } = objects[0]; - expect(obj).to.eql({ - attributes: { - description: '', - hits: 0, - kibanaSavedObjectMeta: { - searchSourceJSON: objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON, - }, - optionsJSON: objects[0].attributes.optionsJSON, - panelsJSON: objects[0].attributes.panelsJSON, - refreshInterval: { - display: 'Off', - pause: false, - value: 0, + // Sort values aren't deterministic so we need to exclude them + const { sort, ...obj } = objects[0]; + expect(obj).to.eql({ + attributes: { + description: '', + hits: 0, + kibanaSavedObjectMeta: { + searchSourceJSON: objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON, + }, + optionsJSON: objects[0].attributes.optionsJSON, + panelsJSON: objects[0].attributes.panelsJSON, + refreshInterval: { + display: 'Off', + pause: false, + value: 0, + }, + timeFrom: 'Wed Sep 16 2015 22:52:17 GMT-0700', + timeRestore: true, + timeTo: 'Fri Sep 18 2015 12:24:38 GMT-0700', + title: 'Requests', + version: 1, }, - timeFrom: 'Wed Sep 16 2015 22:52:17 GMT-0700', - timeRestore: true, - timeTo: 'Fri Sep 18 2015 12:24:38 GMT-0700', - title: 'Requests', - version: 1, - }, - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - migrationVersion: objects[0].migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - references: [ + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + migrationVersion: objects[0].migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + references: [ + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + name: '1:panel_1', + type: 'visualization', + }, + ], + type: 'dashboard', + updated_at: '2017-09-21T18:57:40.826Z', + version: objects[0].version, + }); + expect(objects[0].migrationVersion).to.be.ok(); + expect(() => + JSON.parse(objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON) + ).not.to.throwError(); + expect(() => JSON.parse(objects[0].attributes.optionsJSON)).not.to.throwError(); + expect(() => JSON.parse(objects[0].attributes.panelsJSON)).not.to.throwError(); + }); + }); + + it('should return 200 when exporting by objects', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + objects: [ { - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - name: '1:panel_1', - type: 'visualization', + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', }, ], - type: 'dashboard', - updated_at: objects[0].updated_at, - version: objects[0].version, - }); - expect(objects[0].migrationVersion).to.be.ok(); - expect(() => - JSON.parse(objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON) - ).not.to.throwError(); - expect(() => JSON.parse(objects[0].attributes.optionsJSON)).not.to.throwError(); - expect(() => JSON.parse(objects[0].attributes.panelsJSON)).not.to.throwError(); - }); - }); + excludeExportDetails: true, + }) + .expect(200) + .then((resp) => { + expect(resp.header['content-disposition']).to.eql( + 'attachment; filename="export.ndjson"' + ); + expect(resp.header['content-type']).to.eql('application/ndjson'); + const objects = ndjsonToObject(resp.text); - it('should return 200 when exporting by objects', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - objects: [ - { - type: 'dashboard', + // Sort values aren't deterministic so we need to exclude them + const { sort, ...obj } = objects[0]; + expect(obj).to.eql({ + attributes: { + description: '', + hits: 0, + kibanaSavedObjectMeta: { + searchSourceJSON: objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON, + }, + optionsJSON: objects[0].attributes.optionsJSON, + panelsJSON: objects[0].attributes.panelsJSON, + refreshInterval: { + display: 'Off', + pause: false, + value: 0, + }, + timeFrom: 'Wed Sep 16 2015 22:52:17 GMT-0700', + timeRestore: true, + timeTo: 'Fri Sep 18 2015 12:24:38 GMT-0700', + title: 'Requests', + version: 1, + }, id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - }, - ], - excludeExportDetails: true, - }) - .expect(200) - .then((resp) => { - expect(resp.header['content-disposition']).to.eql( - 'attachment; filename="export.ndjson"' - ); - expect(resp.header['content-type']).to.eql('application/ndjson'); - const objects = ndjsonToObject(resp.text); + migrationVersion: objects[0].migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + references: [ + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + name: '1:panel_1', + type: 'visualization', + }, + ], + type: 'dashboard', + updated_at: '2017-09-21T18:57:40.826Z', + version: objects[0].version, + }); + expect(objects[0].migrationVersion).to.be.ok(); + expect(() => + JSON.parse(objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON) + ).not.to.throwError(); + expect(() => JSON.parse(objects[0].attributes.optionsJSON)).not.to.throwError(); + expect(() => JSON.parse(objects[0].attributes.panelsJSON)).not.to.throwError(); + }); + }); - // Sort values aren't deterministic so we need to exclude them - const { sort, ...obj } = objects[0]; - expect(obj).to.eql({ - attributes: { - description: '', - hits: 0, - kibanaSavedObjectMeta: { - searchSourceJSON: objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON, - }, - optionsJSON: objects[0].attributes.optionsJSON, - panelsJSON: objects[0].attributes.panelsJSON, - refreshInterval: { - display: 'Off', - pause: false, - value: 0, - }, - timeFrom: 'Wed Sep 16 2015 22:52:17 GMT-0700', - timeRestore: true, - timeTo: 'Fri Sep 18 2015 12:24:38 GMT-0700', - title: 'Requests', - version: 1, - }, - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', - migrationVersion: objects[0].migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - references: [ + it('should return 400 when exporting by type and objects', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: 'dashboard', + objects: [ { - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - name: '1:panel_1', - type: 'visualization', + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', }, ], - type: 'dashboard', - updated_at: objects[0].updated_at, - version: objects[0].version, + excludeExportDetails: true, + }) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: `Can't specify both "types" and "objects" properties when exporting`, + }); }); - expect(objects[0].migrationVersion).to.be.ok(); - expect(() => - JSON.parse(objects[0].attributes.kibanaSavedObjectMeta.searchSourceJSON) - ).not.to.throwError(); - expect(() => JSON.parse(objects[0].attributes.optionsJSON)).not.to.throwError(); - expect(() => JSON.parse(objects[0].attributes.panelsJSON)).not.to.throwError(); - }); + }); }); - it('should return 400 when exporting by type and objects', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: 'dashboard', - objects: [ - { - type: 'dashboard', - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + describe('10,001 objects', () => { + let customVisId: string; + before(async () => { + await esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/10k'); + await supertest + .post('/api/saved_objects/visualization') + .send({ + attributes: { + title: 'My favorite vis', }, - ], - excludeExportDetails: true, - }) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: `Can't specify both "types" and "objects" properties when exporting`, + }) + .expect(200) + .then((resp) => { + customVisId = resp.body.id; }); - }); - }); + }); + after(async () => { + await supertest.delete(`/api/saved_objects/visualization/${customVisId}`).expect(200); + await esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/10k'); + }); - it('should allow exporting more than 10,000 objects if permitted by maxImportExportSize', async () => { - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) - .send({ - type: ['dashboard', 'visualization', 'search', 'index-pattern'], - excludeExportDetails: true, - }) - .expect(200) - .then((resp) => { - expect(resp.header['content-disposition']).to.eql( - 'attachment; filename="export.ndjson"' - ); - expect(resp.header['content-type']).to.eql('application/ndjson'); - const objects = ndjsonToObject(resp.text); - expect(objects.length).to.eql(10001); - }); + it('should allow exporting more than 10,000 objects if permitted by maxImportExportSize', async () => { + await supertest + .post('/api/saved_objects/_export') + .send({ + type: ['dashboard', 'visualization', 'search', 'index-pattern'], + excludeExportDetails: true, + }) + .expect(200) + .then((resp) => { + expect(resp.header['content-disposition']).to.eql( + 'attachment; filename="export.ndjson"' + ); + expect(resp.header['content-type']).to.eql('application/ndjson'); + const objects = ndjsonToObject(resp.text); + expect(objects.length).to.eql(10001); + }); + }); + + it('should return 400 when exporting more than allowed by maxImportExportSize', async () => { + let anotherCustomVisId: string; + await supertest + .post('/api/saved_objects/visualization') + .send({ + attributes: { + title: 'My other favorite vis', + }, + }) + .expect(200) + .then((resp) => { + anotherCustomVisId = resp.body.id; + }); + await supertest + .post('/api/saved_objects/_export') + .send({ + type: ['dashboard', 'visualization', 'search', 'index-pattern'], + excludeExportDetails: true, + }) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: `Can't export more than 10001 objects. If your server has enough memory, this limit can be increased by adjusting the \"savedObjects.maxImportExportSize\" setting.`, + }); + }); + await supertest + // @ts-expect-error TS complains about using `anotherCustomVisId` before it is assigned + .delete(`/api/saved_objects/visualization/${anotherCustomVisId}`) + .expect(200); + }); }); + }); - it('should return 400 when exporting more than allowed by maxImportExportSize', async () => { - let anotherCustomVisId: string; - await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/visualization`) - .send({ - attributes: { - title: 'My other favorite vis', - }, - }) - .expect(200) - .then((resp) => { - anotherCustomVisId = resp.body.id; - }); + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return empty response', async () => { await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_export`) + .post('/api/saved_objects/_export') .send({ - type: ['dashboard', 'visualization', 'search', 'index-pattern'], + type: ['index-pattern', 'search', 'visualization', 'dashboard'], excludeExportDetails: true, }) - .expect(400) + .expect(200) .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: `Can't export more than 10001 objects. If your server has enough memory, this limit can be increased by adjusting the \"savedObjects.maxImportExportSize\" setting.`, - }); + expect(resp.text).to.eql(''); }); - await supertest - // @ts-expect-error TS complains about using `anotherCustomVisId` before it is assigned - .delete(`/s/${SPACE_ID}/api/saved_objects/visualization/${anotherCustomVisId}`) - .expect(200); }); }); }); diff --git a/test/api_integration/apis/saved_objects/find.ts b/test/api_integration/apis/saved_objects/find.ts index a38043c7c9352..5f4c6e696b6cf 100644 --- a/test/api_integration/apis/saved_objects/find.ts +++ b/test/api_integration/apis/saved_objects/find.ts @@ -12,343 +12,315 @@ import { SavedObject } from '../../../../src/core/server'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); - const SPACE_ID = 'ftr-so-find'; + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('find', () => { - before(async () => { - await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', - { space: SPACE_ID } + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - - await kibanaServer.spaces.create({ id: `${SPACE_ID}-foo`, name: `${SPACE_ID}-foo` }); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic/foo-ns.json', - { - space: `${SPACE_ID}-foo`, - } + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - - after(async () => { - await kibanaServer.spaces.delete(SPACE_ID); - await kibanaServer.spaces.delete(`${SPACE_ID}-foo`); - }); - it('should return 200 with individual responses', async () => - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&fields=title`) - .expect(200) - .then((resp) => { - expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([ - 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - ]); - expect(resp.body.saved_objects[0].migrationVersion).to.be.ok(); - })); - - describe('unknown type', () => { - it('should return 200 with empty response', async () => + it('should return 200 with individual responses', async () => await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=wigwags`) + .get('/api/saved_objects/_find?type=visualization&fields=title') .expect(200) .then((resp) => { - expect(resp.body).to.eql({ - page: 1, - per_page: 20, - total: 0, - saved_objects: [], - }); + expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([ + 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + ]); + expect(resp.body.saved_objects[0].migrationVersion).to.be.ok(); })); - }); - // FLAKY: https://github.com/elastic/kibana/issues/85911 - describe.skip('page beyond total', () => { - it('should return 200 with empty response', async () => - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&page=100&per_page=100`) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - page: 100, - per_page: 100, - total: 1, - saved_objects: [], - }); - })); - }); + describe('unknown type', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=wigwags') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + }); - describe('unknown search field', () => { - it('should return 200 with empty response', async () => - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=url&search_fields=a`) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - page: 1, - per_page: 20, - total: 0, - saved_objects: [], - }); - })); - }); + // FLAKY: https://github.com/elastic/kibana/issues/85911 + describe.skip('page beyond total', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=visualization&page=100&per_page=100') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 100, + per_page: 100, + total: 1, + saved_objects: [], + }); + })); + }); - describe('unknown namespace', () => { - it('should return 200 with empty response', async () => - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&namespaces=foo`) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - page: 1, - per_page: 20, - total: 0, - saved_objects: [], - }); - })); - }); + describe('unknown search field', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=url&search_fields=a') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + }); - describe('known namespace', () => { - it('should return 200 with individual responses', async () => - await supertest - .get(`/api/saved_objects/_find?type=visualization&fields=title&namespaces=${SPACE_ID}`) - .expect(200) - .then((resp) => { - expect( - resp.body.saved_objects.map((so: { id: string; namespaces: string[] }) => ({ - id: so.id, - namespaces: so.namespaces, - })) - ).to.eql([{ id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: [SPACE_ID] }]); - expect(resp.body.saved_objects[0].migrationVersion).to.be.ok(); - })); - }); + describe('unknown namespace', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=visualization&namespaces=foo') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + }); - describe('wildcard namespace', () => { - it('should return 200 with individual responses from the all namespaces', async () => - await supertest - .get(`/api/saved_objects/_find?type=visualization&fields=title&namespaces=*`) - .expect(200) - .then((resp) => { - const knownDocuments = resp.body.saved_objects.filter((so: { namespaces: string[] }) => - so.namespaces.some((ns) => [SPACE_ID, `${SPACE_ID}-foo`].includes(ns)) - ); + describe('known namespace', () => { + it('should return 200 with individual responses', async () => + await supertest + .get('/api/saved_objects/_find?type=visualization&fields=title&namespaces=default') + .expect(200) + .then((resp) => { + expect( + resp.body.saved_objects.map((so: { id: string; namespaces: string[] }) => ({ + id: so.id, + namespaces: so.namespaces, + })) + ).to.eql([{ id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: ['default'] }]); + expect(resp.body.saved_objects[0].migrationVersion).to.be.ok(); + })); + }); - expect( - knownDocuments.map((so: { id: string; namespaces: string[] }) => ({ - id: so.id, - namespaces: so.namespaces, - })) - ).to.eql([ - { id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: [SPACE_ID] }, - { id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: [`${SPACE_ID}-foo`] }, - ]); - })); - }); + describe('wildcard namespace', () => { + it('should return 200 with individual responses from the all namespaces', async () => + await supertest + .get('/api/saved_objects/_find?type=visualization&fields=title&namespaces=*') + .expect(200) + .then((resp) => { + expect( + resp.body.saved_objects.map((so: { id: string; namespaces: string[] }) => ({ + id: so.id, + namespaces: so.namespaces, + })) + ).to.eql([ + { id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: ['default'] }, + { id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: ['foo-ns'] }, + ]); + })); + }); - describe('with a filter', () => { - it('should return 200 with a valid response', async () => - await supertest - .get( - `/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&filter=visualization.attributes.title:"Count of requests"` - ) - .expect(200) - .then((resp) => { - expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([ - 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - ]); - })); + describe('with a filter', () => { + it('should return 200 with a valid response', async () => + await supertest + .get( + '/api/saved_objects/_find?type=visualization&filter=visualization.attributes.title:"Count of requests"' + ) + .expect(200) + .then((resp) => { + expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([ + 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + ]); + })); - it('wrong type should return 400 with Bad Request', async () => - await supertest - .get( - `/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&filter=dashboard.attributes.title:foo` - ) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - error: 'Bad Request', - message: 'This type dashboard is not allowed: Bad Request', - statusCode: 400, - }); - })); + it('wrong type should return 400 with Bad Request', async () => + await supertest + .get( + '/api/saved_objects/_find?type=visualization&filter=dashboard.attributes.title:foo' + ) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: 'This type dashboard is not allowed: Bad Request', + statusCode: 400, + }); + })); - it('KQL syntax error should return 400 with Bad Request', async () => - await supertest - .get( - `/s/${SPACE_ID}/api/saved_objects/_find?type=dashboard&filter=dashboard.attributes.title:foo { - expect(resp.body).to.eql({ - error: 'Bad Request', - message: - 'KQLSyntaxError: Expected AND, OR, end of input but "<" found.\ndashboard.' + - 'attributes.title:foo + await supertest + .get( + '/api/saved_objects/_find?type=dashboard&filter=dashboard.attributes.title:foo { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: + 'KQLSyntaxError: Expected AND, OR, end of input but "<" found.\ndashboard.' + + 'attributes.title:foo { - it('should return 200 with valid response for a valid aggregation', async () => - await supertest - .get( - `/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&per_page=0&aggs=${encodeURIComponent( - JSON.stringify({ - type_count: { max: { field: 'visualization.attributes.version' } }, - }) - )}` - ) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - aggregations: { - type_count: { - value: 1, + describe('using aggregations', () => { + it('should return 200 with valid response for a valid aggregation', async () => + await supertest + .get( + `/api/saved_objects/_find?type=visualization&per_page=0&aggs=${encodeURIComponent( + JSON.stringify({ + type_count: { max: { field: 'visualization.attributes.version' } }, + }) + )}` + ) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + aggregations: { + type_count: { + value: 1, + }, }, - }, - page: 1, - per_page: 0, - saved_objects: [], - total: 1, - }); - })); + page: 1, + per_page: 0, + saved_objects: [], + total: 1, + }); + })); - it('should return a 400 when referencing an invalid SO attribute', async () => - await supertest - .get( - `/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&per_page=0&aggs=${encodeURIComponent( - JSON.stringify({ - type_count: { max: { field: 'dashboard.attributes.version' } }, - }) - )}` - ) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - error: 'Bad Request', - message: - 'Invalid aggregation: [type_count.max.field] Invalid attribute path: dashboard.attributes.version: Bad Request', - statusCode: 400, - }); - })); + it('should return a 400 when referencing an invalid SO attribute', async () => + await supertest + .get( + `/api/saved_objects/_find?type=visualization&per_page=0&aggs=${encodeURIComponent( + JSON.stringify({ + type_count: { max: { field: 'dashboard.attributes.version' } }, + }) + )}` + ) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: + 'Invalid aggregation: [type_count.max.field] Invalid attribute path: dashboard.attributes.version: Bad Request', + statusCode: 400, + }); + })); - it('should return a 400 when using a forbidden aggregation option', async () => - await supertest - .get( - `/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&per_page=0&aggs=${encodeURIComponent( - JSON.stringify({ - type_count: { - max: { - field: 'visualization.attributes.version', - script: 'Bad script is bad', + it('should return a 400 when using a forbidden aggregation option', async () => + await supertest + .get( + `/api/saved_objects/_find?type=visualization&per_page=0&aggs=${encodeURIComponent( + JSON.stringify({ + type_count: { + max: { + field: 'visualization.attributes.version', + script: 'Bad script is bad', + }, }, - }, - }) - )}` - ) - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - error: 'Bad Request', - message: - 'Invalid aggregation: [type_count.max.script]: definition for this key is missing: Bad Request', - statusCode: 400, - }); - })); - }); + }) + )}` + ) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: + 'Invalid aggregation: [type_count.max.script]: definition for this key is missing: Bad Request', + statusCode: 400, + }); + })); + }); - describe('`has_reference` and `has_reference_operator` parameters', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json', - { space: SPACE_ID } + describe('`has_reference` and `has_reference_operator` parameters', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/references') ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json', - { space: SPACE_ID } + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/references') ); - }); - it('search for a reference', async () => { - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) - .query({ - type: 'visualization', - has_reference: JSON.stringify({ type: 'ref-type', id: 'ref-1' }), - }) - .expect(200) - .then((resp) => { - const objects = resp.body.saved_objects; - expect(objects.map((obj: SavedObject) => obj.id)).to.eql([ - 'only-ref-1', - 'ref-1-and-ref-2', - ]); - }); - }); + it('search for a reference', async () => { + await supertest + .get('/api/saved_objects/_find') + .query({ + type: 'visualization', + has_reference: JSON.stringify({ type: 'ref-type', id: 'ref-1' }), + }) + .expect(200) + .then((resp) => { + const objects = resp.body.saved_objects; + expect(objects.map((obj: SavedObject) => obj.id)).to.eql([ + 'only-ref-1', + 'ref-1-and-ref-2', + ]); + }); + }); - it('search for multiple references with OR operator', async () => { - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) - .query({ - type: 'visualization', - has_reference: JSON.stringify([ - { type: 'ref-type', id: 'ref-1' }, - { type: 'ref-type', id: 'ref-2' }, - ]), - has_reference_operator: 'OR', - }) - .expect(200) - .then((resp) => { - const objects = resp.body.saved_objects; - expect(objects.map((obj: SavedObject) => obj.id)).to.eql([ - 'only-ref-1', - 'only-ref-2', - 'ref-1-and-ref-2', - ]); - }); - }); + it('search for multiple references with OR operator', async () => { + await supertest + .get('/api/saved_objects/_find') + .query({ + type: 'visualization', + has_reference: JSON.stringify([ + { type: 'ref-type', id: 'ref-1' }, + { type: 'ref-type', id: 'ref-2' }, + ]), + has_reference_operator: 'OR', + }) + .expect(200) + .then((resp) => { + const objects = resp.body.saved_objects; + expect(objects.map((obj: SavedObject) => obj.id)).to.eql([ + 'only-ref-1', + 'ref-1-and-ref-2', + 'only-ref-2', + ]); + }); + }); - it('search for multiple references with AND operator', async () => { - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) - .query({ - type: 'visualization', - has_reference: JSON.stringify([ - { type: 'ref-type', id: 'ref-1' }, - { type: 'ref-type', id: 'ref-2' }, - ]), - has_reference_operator: 'AND', - }) - .expect(200) - .then((resp) => { - const objects = resp.body.saved_objects; - expect(objects.map((obj: SavedObject) => obj.id)).to.eql(['ref-1-and-ref-2']); - }); + it('search for multiple references with AND operator', async () => { + await supertest + .get('/api/saved_objects/_find') + .query({ + type: 'visualization', + has_reference: JSON.stringify([ + { type: 'ref-type', id: 'ref-1' }, + { type: 'ref-type', id: 'ref-2' }, + ]), + has_reference_operator: 'AND', + }) + .expect(200) + .then((resp) => { + const objects = resp.body.saved_objects; + expect(objects.map((obj: SavedObject) => obj.id)).to.eql(['ref-1-and-ref-2']); + }); + }); }); }); describe('searching for special characters', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json', - { space: SPACE_ID } - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json', - { space: SPACE_ID } - ); - }); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases') + ); it('can search for objects with dashes', async () => await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) + .get('/api/saved_objects/_find') .query({ type: 'visualization', search_fields: 'title', @@ -364,7 +336,7 @@ export default function ({ getService }: FtrProviderContext) { it('can search with the prefix search character just after a special one', async () => await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) + .get('/api/saved_objects/_find') .query({ type: 'visualization', search_fields: 'title', @@ -380,7 +352,7 @@ export default function ({ getService }: FtrProviderContext) { it('can search for objects with asterisk', async () => await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) + .get('/api/saved_objects/_find') .query({ type: 'visualization', search_fields: 'title', @@ -396,7 +368,7 @@ export default function ({ getService }: FtrProviderContext) { it('can still search tokens by prefix', async () => await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find`) + .get('/api/saved_objects/_find') .query({ type: 'visualization', search_fields: 'title', @@ -407,8 +379,120 @@ export default function ({ getService }: FtrProviderContext) { const savedObjects = resp.body.saved_objects; expect( savedObjects.map((so: SavedObject<{ title: string }>) => so.attributes.title) - ).to.eql(['some*visualization', 'my-visualization']); + ).to.eql(['my-visualization', 'some*visualization']); + })); + }); + + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=visualization') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); })); + + describe('unknown type', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=wigwags') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + }); + + describe('missing type', () => { + it('should return 400', async () => + await supertest + .get('/api/saved_objects/_find') + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: + '[request query.type]: expected at least one defined value but got [undefined]', + statusCode: 400, + }); + })); + }); + + describe('page beyond total', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=visualization&page=100&per_page=100') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 100, + per_page: 100, + total: 0, + saved_objects: [], + }); + })); + }); + + describe('unknown search field', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/saved_objects/_find?type=url&search_fields=a') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + }); + + describe('with a filter', () => { + it('should return 200 with an empty response', async () => + await supertest + .get( + '/api/saved_objects/_find?type=visualization&filter=visualization.attributes.title:"Count of requests"' + ) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + + it('wrong type should return 400 with Bad Request', async () => + await supertest + .get( + '/api/saved_objects/_find?type=visualization&filter=dashboard.attributes.title:foo' + ) + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: 'This type dashboard is not allowed: Bad Request', + statusCode: 400, + }); + })); + }); }); }); } diff --git a/test/api_integration/apis/saved_objects/get.ts b/test/api_integration/apis/saved_objects/get.ts index 8122308e44930..94cae01201a66 100644 --- a/test/api_integration/apis/saved_objects/get.ts +++ b/test/api_integration/apis/saved_objects/get.ts @@ -12,65 +12,88 @@ import { getKibanaVersion } from './lib/saved_objects_test_utils'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('get', () => { let KIBANA_VERSION: string; before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - it('should return 200', async () => - await supertest - .get(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - type: 'visualization', - updated_at: resp.body.updated_at, - version: resp.body.version, - migrationVersion: resp.body.migrationVersion, - coreMigrationVersion: KIBANA_VERSION, - attributes: { - title: 'Count of requests', - description: '', - version: 1, - // cheat for some of the more complex attributes - visState: resp.body.attributes.visState, - uiStateJSON: resp.body.attributes.uiStateJSON, - kibanaSavedObjectMeta: resp.body.attributes.kibanaSavedObjectMeta, - }, - references: [ - { - type: 'index-pattern', - name: 'kibanaSavedObjectMeta.searchSourceJSON.index', - id: '91200a00-9efd-11e7-acb3-3dab96693fab', + it('should return 200', async () => + await supertest + .get(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + type: 'visualization', + updated_at: '2017-09-21T18:51:23.794Z', + version: resp.body.version, + migrationVersion: resp.body.migrationVersion, + coreMigrationVersion: KIBANA_VERSION, + attributes: { + title: 'Count of requests', + description: '', + version: 1, + // cheat for some of the more complex attributes + visState: resp.body.attributes.visState, + uiStateJSON: resp.body.attributes.uiStateJSON, + kibanaSavedObjectMeta: resp.body.attributes.kibanaSavedObjectMeta, }, - ], - namespaces: ['default'], - }); - expect(resp.body.migrationVersion).to.be.ok(); - })); + references: [ + { + type: 'index-pattern', + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + id: '91200a00-9efd-11e7-acb3-3dab96693fab', + }, + ], + namespaces: ['default'], + }); + expect(resp.body.migrationVersion).to.be.ok(); + })); + + describe('doc does not exist', () => { + it('should return same generic error as when index does not exist', async () => + await supertest + .get(`/api/saved_objects/visualization/foobar`) + .expect(404) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Not Found', + message: 'Saved object [visualization/foobar] not found', + statusCode: 404, + }); + })); + }); + }); + + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); - describe('doc does not exist', () => { - it('should return same generic error as when index does not exist', async () => + it('should return basic 404 without mentioning index', async () => await supertest - .get(`/api/saved_objects/visualization/foobar`) + .get('/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab') .expect(404) .then((resp) => { expect(resp.body).to.eql({ error: 'Not Found', - message: 'Saved object [visualization/foobar] not found', + message: + 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] not found', statusCode: 404, }); })); diff --git a/test/api_integration/apis/saved_objects/import.ts b/test/api_integration/apis/saved_objects/import.ts index c899f082ec4d3..b9aad96c2469e 100644 --- a/test/api_integration/apis/saved_objects/import.ts +++ b/test/api_integration/apis/saved_objects/import.ts @@ -22,7 +22,7 @@ const createConflictError = ( export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); describe('import', () => { // mock success results including metadata @@ -42,205 +42,203 @@ export default function ({ getService }: FtrProviderContext) { meta: { title: 'Requests', icon: 'dashboardApp' }, }; - describe('with basic data existing', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + describe('with basic data existing', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - it('should return 415 when no file passed in', async () => { - await supertest - .post('/api/saved_objects/_import') - .expect(415) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 415, - error: 'Unsupported Media Type', - message: 'Unsupported Media Type', + it('should return 415 when no file passed in', async () => { + await supertest + .post('/api/saved_objects/_import') + .expect(415) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 415, + error: 'Unsupported Media Type', + message: 'Unsupported Media Type', + }); }); - }); - }); + }); - it('should return errors when conflicts exist', async () => { - await supertest - .post('/api/saved_objects/_import') - .attach('file', join(__dirname, '../../fixtures/import.ndjson')) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - success: false, - successCount: 0, - errors: [ - createConflictError(indexPattern), - createConflictError(visualization), - createConflictError(dashboard), - ], - warnings: [], + it('should return errors when conflicts exist', async () => { + await supertest + .post('/api/saved_objects/_import') + .attach('file', join(__dirname, '../../fixtures/import.ndjson')) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: false, + successCount: 0, + errors: [ + createConflictError(indexPattern), + createConflictError(visualization), + createConflictError(dashboard), + ], + warnings: [], + }); }); - }); - }); + }); - it('should return 200 when conflicts exist but overwrite is passed in', async () => { - await supertest - .post('/api/saved_objects/_import') - .query({ overwrite: true }) - .attach('file', join(__dirname, '../../fixtures/import.ndjson')) - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - success: true, - successCount: 3, - successResults: [ - { ...indexPattern, overwrite: true }, - { ...visualization, overwrite: true }, - { ...dashboard, overwrite: true }, - ], - warnings: [], + it('should return 200 when conflicts exist but overwrite is passed in', async () => { + await supertest + .post('/api/saved_objects/_import') + .query({ overwrite: true }) + .attach('file', join(__dirname, '../../fixtures/import.ndjson')) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: true, + successCount: 3, + successResults: [ + { ...indexPattern, overwrite: true }, + { ...visualization, overwrite: true }, + { ...dashboard, overwrite: true }, + ], + warnings: [], + }); }); - }); - }); + }); - it('should return 200 when trying to import unsupported types', async () => { - const fileBuffer = Buffer.from( - '{"id":"1","type":"wigwags","attributes":{"title":"my title"},"references":[]}', - 'utf8' - ); - await supertest - .post('/api/saved_objects/_import') - .attach('file', fileBuffer, 'export.ndjson') - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - success: false, - successCount: 0, - errors: [ - { - id: '1', - type: 'wigwags', - title: 'my title', - meta: { title: 'my title' }, - error: { type: 'unsupported_type' }, - }, - ], - warnings: [], + it('should return 200 when trying to import unsupported types', async () => { + const fileBuffer = Buffer.from( + '{"id":"1","type":"wigwags","attributes":{"title":"my title"},"references":[]}', + 'utf8' + ); + await supertest + .post('/api/saved_objects/_import') + .attach('file', fileBuffer, 'export.ndjson') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: false, + successCount: 0, + errors: [ + { + id: '1', + type: 'wigwags', + title: 'my title', + meta: { title: 'my title' }, + error: { type: 'unsupported_type' }, + }, + ], + warnings: [], + }); }); - }); - }); - - it('should return 200 when importing SO with circular refs', async () => { - const fileBuffer = Buffer.from( - dedent` - {"attributes":{"title":"dashboard-b"},"id":"dashboard-b","references":[{"id":"dashboard-a","name":"circular-dashboard-ref","type":"dashboard"}],"type":"dashboard"} - {"attributes":{"title":"dashboard-a"},"id":"dashboard-a","references":[{"id":"dashboard-b","name":"circular-dashboard-ref","type":"dashboard"}],"type":"dashboard"} - `, - 'utf8' - ); - const resp = await supertest - .post('/api/saved_objects/_import') - .attach('file', fileBuffer, 'export.ndjson') - .expect(200); - - expect(resp.body).to.eql({ - success: true, - successCount: 2, - successResults: [ - { - id: 'dashboard-b', - meta: { - icon: 'dashboardApp', - title: 'dashboard-b', - }, - type: 'dashboard', - }, - { - id: 'dashboard-a', - meta: { - icon: 'dashboardApp', - title: 'dashboard-a', - }, - type: 'dashboard', - }, - ], - warnings: [], }); - }); - it('should return 400 when trying to import more than 10,000 objects', async () => { - const fileChunks = []; - for (let i = 0; i <= 10001; i++) { - fileChunks.push(`{"type":"visualization","id":"${i}","attributes":{},"references":[]}`); - } - await supertest - .post('/api/saved_objects/_import') - .attach('file', Buffer.from(fileChunks.join('\n'), 'utf8'), 'export.ndjson') - .expect(400) - .then((resp) => { - expect(resp.body).to.eql({ - statusCode: 400, - error: 'Bad Request', - message: "Can't import more than 10001 objects", - }); - }); - }); + it('should return 200 when importing SO with circular refs', async () => { + const fileBuffer = Buffer.from( + dedent` + {"attributes":{"title":"dashboard-b"},"id":"dashboard-b","references":[{"id":"dashboard-a","name":"circular-dashboard-ref","type":"dashboard"}],"type":"dashboard"} + {"attributes":{"title":"dashboard-a"},"id":"dashboard-a","references":[{"id":"dashboard-b","name":"circular-dashboard-ref","type":"dashboard"}],"type":"dashboard"} + `, + 'utf8' + ); + const resp = await supertest + .post('/api/saved_objects/_import') + .attach('file', fileBuffer, 'export.ndjson') + .expect(200); - it('should return errors when index patterns or search are missing', async () => { - const objectsToImport = [ - JSON.stringify({ - type: 'visualization', - id: '1', - attributes: { title: 'My visualization' }, - references: [ + expect(resp.body).to.eql({ + success: true, + successCount: 2, + successResults: [ { - name: 'ref_0', - type: 'index-pattern', - id: 'non-existing', + id: 'dashboard-b', + meta: { + icon: 'dashboardApp', + title: 'dashboard-b', + }, + type: 'dashboard', }, { - name: 'ref_1', - type: 'search', - id: 'non-existing-search', + id: 'dashboard-a', + meta: { + icon: 'dashboardApp', + title: 'dashboard-a', + }, + type: 'dashboard', }, ], - }), - ]; - await supertest - .post('/api/saved_objects/_import') - .attach('file', Buffer.from(objectsToImport.join('\n'), 'utf8'), 'export.ndjson') - .expect(200) - .then((resp) => { - expect(resp.body).to.eql({ - success: false, - successCount: 0, - errors: [ + warnings: [], + }); + }); + + it('should return 400 when trying to import more than 10,000 objects', async () => { + const fileChunks = []; + for (let i = 0; i <= 10001; i++) { + fileChunks.push(`{"type":"visualization","id":"${i}","attributes":{},"references":[]}`); + } + await supertest + .post('/api/saved_objects/_import') + .attach('file', Buffer.from(fileChunks.join('\n'), 'utf8'), 'export.ndjson') + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: "Can't import more than 10001 objects", + }); + }); + }); + + it('should return errors when index patterns or search are missing', async () => { + const objectsToImport = [ + JSON.stringify({ + type: 'visualization', + id: '1', + attributes: { title: 'My visualization' }, + references: [ { - type: 'visualization', - id: '1', - title: 'My visualization', - meta: { title: 'My visualization', icon: 'visualizeApp' }, - error: { - type: 'missing_references', - references: [ - { - type: 'index-pattern', - id: 'non-existing', - }, - { - type: 'search', - id: 'non-existing-search', - }, - ], - }, + name: 'ref_0', + type: 'index-pattern', + id: 'non-existing', + }, + { + name: 'ref_1', + type: 'search', + id: 'non-existing-search', }, ], - warnings: [], + }), + ]; + await supertest + .post('/api/saved_objects/_import') + .attach('file', Buffer.from(objectsToImport.join('\n'), 'utf8'), 'export.ndjson') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: false, + successCount: 0, + errors: [ + { + type: 'visualization', + id: '1', + title: 'My visualization', + meta: { title: 'My visualization', icon: 'visualizeApp' }, + error: { + type: 'missing_references', + references: [ + { + type: 'index-pattern', + id: 'non-existing', + }, + { + type: 'search', + id: 'non-existing-search', + }, + ], + }, + }, + ], + warnings: [], + }); }); - }); + }); }); }); }); diff --git a/test/api_integration/apis/saved_objects/resolve.ts b/test/api_integration/apis/saved_objects/resolve.ts index a00a44f98223d..a462151cd7779 100644 --- a/test/api_integration/apis/saved_objects/resolve.ts +++ b/test/api_integration/apis/saved_objects/resolve.ts @@ -12,7 +12,8 @@ import { getKibanaVersion } from './lib/saved_objects_test_utils'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('resolve', () => { let KIBANA_VERSION: string; @@ -22,29 +23,23 @@ export default function ({ getService }: FtrProviderContext) { }); describe('with kibana index', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); it('should return 200', async () => await supertest .get(`/api/saved_objects/resolve/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) .expect(200) .then((resp) => { - resp.body.saved_object.updated_at = '2015-01-01T00:00:00.000Z'; - expect(resp.body).to.eql({ saved_object: { id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', type: 'visualization', - updated_at: '2015-01-01T00:00:00.000Z', + updated_at: '2017-09-21T18:51:23.794Z', version: resp.body.saved_object.version, migrationVersion: resp.body.saved_object.migrationVersion, coreMigrationVersion: KIBANA_VERSION, @@ -85,5 +80,26 @@ export default function ({ getService }: FtrProviderContext) { })); }); }); + + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana') + ); + + it('should return basic 404 without mentioning index', async () => + await supertest + .get('/api/saved_objects/resolve/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab') + .expect(404) + .then((resp) => { + expect(resp.body).to.eql({ + error: 'Not Found', + message: + 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] not found', + statusCode: 404, + }); + })); + }); }); } diff --git a/test/api_integration/apis/saved_objects/resolve_import_errors.ts b/test/api_integration/apis/saved_objects/resolve_import_errors.ts index 7ca61a26a11c1..4914eb5c7b29f 100644 --- a/test/api_integration/apis/saved_objects/resolve_import_errors.ts +++ b/test/api_integration/apis/saved_objects/resolve_import_errors.ts @@ -12,7 +12,8 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('resolve_import_errors', () => { // mock success results including metadata @@ -31,48 +32,49 @@ export default function ({ getService }: FtrProviderContext) { id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', meta: { title: 'Requests', icon: 'dashboardApp' }, }; - const SPACE_ID = 'ftr-so-resolve_import_errors'; - describe('with basic data existing', () => { - before(async () => { - await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', - { space: SPACE_ID } - ); - }); - after(() => kibanaServer.spaces.delete(SPACE_ID)); + describe('without kibana index', () => { + // Cleanup data that got created in import + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); - it('should return 200 when skipping all the records', async () => { + it('should return 200 and import nothing when empty parameters are passed in', async () => { await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_resolve_import_errors`) + .post('/api/saved_objects/_resolve_import_errors') .field('retries', '[]') .attach('file', join(__dirname, '../../fixtures/import.ndjson')) .expect(200) .then((resp) => { - expect(resp.body).to.eql({ success: true, successCount: 0, warnings: [] }); + expect(resp.body).to.eql({ + success: true, + successCount: 0, + warnings: [], + }); }); }); - it('should return 200 when manually overwriting each object', async () => { + it('should return 200 with internal server errors', async () => { await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_resolve_import_errors`) + .post('/api/saved_objects/_resolve_import_errors') .field( 'retries', JSON.stringify([ { - id: '91200a00-9efd-11e7-acb3-3dab96693fab', type: 'index-pattern', + id: '91200a00-9efd-11e7-acb3-3dab96693fab', overwrite: true, }, { - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', overwrite: true, }, { - id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', overwrite: true, }, ]) @@ -81,44 +83,110 @@ export default function ({ getService }: FtrProviderContext) { .expect(200) .then((resp) => { expect(resp.body).to.eql({ - success: true, - successCount: 3, - successResults: [ - { ...indexPattern, overwrite: true }, - { ...visualization, overwrite: true }, - { ...dashboard, overwrite: true }, + successCount: 0, + success: false, + errors: [ + { + ...indexPattern, + ...{ title: indexPattern.meta.title }, + overwrite: true, + error: { + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred', + type: 'unknown', + }, + }, + { + ...visualization, + ...{ title: visualization.meta.title }, + overwrite: true, + error: { + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred', + type: 'unknown', + }, + }, + { + ...dashboard, + ...{ title: dashboard.meta.title }, + overwrite: true, + error: { + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred', + type: 'unknown', + }, + }, ], warnings: [], }); }); }); - it('should return 200 with only one record when overwriting 1 and skipping 1', async () => { + it('should return 400 when no file passed in', async () => { await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_resolve_import_errors`) - .field( - 'retries', - JSON.stringify([ - { - id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', - type: 'visualization', - overwrite: true, - }, - ]) - ) - .attach('file', join(__dirname, '../../fixtures/import.ndjson')) + .post('/api/saved_objects/_resolve_import_errors') + .field('retries', '[]') + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: '[request body.file]: expected value of type [Stream] but got [undefined]', + }); + }); + }); + + it('should return 200 when retrying unsupported types', async () => { + const fileBuffer = Buffer.from( + '{"id":"1","type":"wigwags","attributes":{"title":"my title"},"references":[]}', + 'utf8' + ); + await supertest + .post('/api/saved_objects/_resolve_import_errors') + .field('retries', JSON.stringify([{ type: 'wigwags', id: '1' }])) + .attach('file', fileBuffer, 'export.ndjson') .expect(200) .then((resp) => { expect(resp.body).to.eql({ - success: true, - successCount: 1, - successResults: [{ ...visualization, overwrite: true }], + success: false, + successCount: 0, + errors: [ + { + id: '1', + type: 'wigwags', + title: 'my title', + meta: { title: 'my title' }, + error: { type: 'unsupported_type' }, + }, + ], warnings: [], }); }); }); - it('should return 200 when replacing references', async () => { + it('should return 400 when resolving conflicts with a file containing more than 10,001 objects', async () => { + const fileChunks = []; + for (let i = 0; i <= 10001; i++) { + fileChunks.push(`{"type":"visualization","id":"${i}","attributes":{},"references":[]}`); + } + await supertest + .post('/api/saved_objects/_resolve_import_errors') + .field('retries', '[]') + .attach('file', Buffer.from(fileChunks.join('\n'), 'utf8'), 'export.ndjson') + .expect(400) + .then((resp) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: "Can't import more than 10001 objects", + }); + }); + }); + + it('should return 200 with errors when missing references', async () => { const objToInsert = { id: '1', type: 'visualization', @@ -135,20 +203,13 @@ export default function ({ getService }: FtrProviderContext) { ], }; await supertest - .post(`/s/${SPACE_ID}/api/saved_objects/_resolve_import_errors`) + .post('/api/saved_objects/_resolve_import_errors') .field( 'retries', JSON.stringify([ { type: 'visualization', id: '1', - replaceReferences: [ - { - type: 'index-pattern', - from: '2', - to: '91200a00-9efd-11e7-acb3-3dab96693fab', - }, - ], }, ]) ) @@ -156,30 +217,178 @@ export default function ({ getService }: FtrProviderContext) { .expect(200) .then((resp) => { expect(resp.body).to.eql({ - success: true, - successCount: 1, - successResults: [ + success: false, + successCount: 0, + errors: [ { - type: 'visualization', id: '1', + type: 'visualization', + title: 'My favorite vis', meta: { title: 'My favorite vis', icon: 'visualizeApp' }, + error: { + type: 'missing_references', + references: [ + { + type: 'index-pattern', + id: '2', + }, + ], + }, }, ], warnings: [], }); }); - await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/visualization/1`) - .expect(200) - .then((resp) => { - expect(resp.body.references).to.eql([ + }); + }); + + describe('with kibana index', () => { + describe('with basic data existing', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + + it('should return 200 when skipping all the records', async () => { + await supertest + .post('/api/saved_objects/_resolve_import_errors') + .field('retries', '[]') + .attach('file', join(__dirname, '../../fixtures/import.ndjson')) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ success: true, successCount: 0, warnings: [] }); + }); + }); + + it('should return 200 when manually overwriting each object', async () => { + await supertest + .post('/api/saved_objects/_resolve_import_errors') + .field( + 'retries', + JSON.stringify([ + { + id: '91200a00-9efd-11e7-acb3-3dab96693fab', + type: 'index-pattern', + overwrite: true, + }, + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + type: 'visualization', + overwrite: true, + }, + { + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + type: 'dashboard', + overwrite: true, + }, + ]) + ) + .attach('file', join(__dirname, '../../fixtures/import.ndjson')) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: true, + successCount: 3, + successResults: [ + { ...indexPattern, overwrite: true }, + { ...visualization, overwrite: true }, + { ...dashboard, overwrite: true }, + ], + warnings: [], + }); + }); + }); + + it('should return 200 with only one record when overwriting 1 and skipping 1', async () => { + await supertest + .post('/api/saved_objects/_resolve_import_errors') + .field( + 'retries', + JSON.stringify([ + { + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + type: 'visualization', + overwrite: true, + }, + ]) + ) + .attach('file', join(__dirname, '../../fixtures/import.ndjson')) + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: true, + successCount: 1, + successResults: [{ ...visualization, overwrite: true }], + warnings: [], + }); + }); + }); + + it('should return 200 when replacing references', async () => { + const objToInsert = { + id: '1', + type: 'visualization', + attributes: { + title: 'My favorite vis', + visState: '{}', + }, + references: [ { name: 'ref_0', type: 'index-pattern', - id: '91200a00-9efd-11e7-acb3-3dab96693fab', + id: '2', }, - ]); - }); + ], + }; + await supertest + .post('/api/saved_objects/_resolve_import_errors') + .field( + 'retries', + JSON.stringify([ + { + type: 'visualization', + id: '1', + replaceReferences: [ + { + type: 'index-pattern', + from: '2', + to: '91200a00-9efd-11e7-acb3-3dab96693fab', + }, + ], + }, + ]) + ) + .attach('file', Buffer.from(JSON.stringify(objToInsert), 'utf8'), 'export.ndjson') + .expect(200) + .then((resp) => { + expect(resp.body).to.eql({ + success: true, + successCount: 1, + successResults: [ + { + type: 'visualization', + id: '1', + meta: { title: 'My favorite vis', icon: 'visualizeApp' }, + }, + ], + warnings: [], + }); + }); + await supertest + .get('/api/saved_objects/visualization/1') + .expect(200) + .then((resp) => { + expect(resp.body.references).to.eql([ + { + name: 'ref_0', + type: 'index-pattern', + id: '91200a00-9efd-11e7-acb3-3dab96693fab', + }, + ]); + }); + }); }); }); }); diff --git a/test/api_integration/apis/saved_objects/update.ts b/test/api_integration/apis/saved_objects/update.ts index 1c73d0788e51c..be4dd65d3e67d 100644 --- a/test/api_integration/apis/saved_objects/update.ts +++ b/test/api_integration/apis/saved_objects/update.ts @@ -11,161 +11,185 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + const esDeleteAllIndices = getService('esDeleteAllIndices'); describe('update', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - it('should return 200', async () => { - await supertest - .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) - .send({ - attributes: { - title: 'My second favorite vis', - }, - }) - .expect(200) - .then((resp) => { - // loose uuid validation - expect(resp.body) - .to.have.property('id') - .match(/^[0-9a-f-]{36}$/); - - // loose ISO8601 UTC time with milliseconds validation - expect(resp.body) - .to.have.property('updated_at') - .match(/^[\d-]{10}T[\d:\.]{12}Z$/); - - expect(resp.body).to.eql({ - id: resp.body.id, - type: 'visualization', - updated_at: resp.body.updated_at, - version: resp.body.version, + it('should return 200', async () => { + await supertest + .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) + .send({ attributes: { title: 'My second favorite vis', }, - namespaces: ['default'], + }) + .expect(200) + .then((resp) => { + // loose uuid validation + expect(resp.body) + .to.have.property('id') + .match(/^[0-9a-f-]{36}$/); + + // loose ISO8601 UTC time with milliseconds validation + expect(resp.body) + .to.have.property('updated_at') + .match(/^[\d-]{10}T[\d:\.]{12}Z$/); + + expect(resp.body).to.eql({ + id: resp.body.id, + type: 'visualization', + updated_at: resp.body.updated_at, + version: resp.body.version, + attributes: { + title: 'My second favorite vis', + }, + namespaces: ['default'], + }); }); - }); - }); + }); - it('does not pass references if omitted', async () => { - const resp = await supertest - .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) - .send({ - attributes: { - title: 'foo', - }, - }) - .expect(200); - - expect(resp.body).not.to.have.property('references'); - }); + it('does not pass references if omitted', async () => { + const resp = await supertest + .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) + .send({ + attributes: { + title: 'foo', + }, + }) + .expect(200); - it('passes references if they are provided', async () => { - const references = [{ id: 'foo', name: 'Foo', type: 'visualization' }]; - - const resp = await supertest - .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) - .send({ - attributes: { - title: 'foo', - }, - references, - }) - .expect(200); - - expect(resp.body).to.have.property('references'); - expect(resp.body.references).to.eql(references); - }); + expect(resp.body).not.to.have.property('references'); + }); - it('passes empty references array if empty references array is provided', async () => { - const resp = await supertest - .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) - .send({ - attributes: { - title: 'foo', - }, - references: [], - }) - .expect(200); - - expect(resp.body).to.have.property('references'); - expect(resp.body.references).to.eql([]); - }); + it('passes references if they are provided', async () => { + const references = [{ id: 'foo', name: 'Foo', type: 'visualization' }]; + + const resp = await supertest + .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) + .send({ + attributes: { + title: 'foo', + }, + references, + }) + .expect(200); - it('handles upsert', async () => { - await supertest - .put(`/api/saved_objects/visualization/upserted-viz`) - .send({ - attributes: { - title: 'foo', - }, - upsert: { - title: 'upserted title', - description: 'upserted description', - }, - }) - .expect(200); - - const { body: upserted } = await supertest - .get(`/api/saved_objects/visualization/upserted-viz`) - .expect(200); - - expect(upserted.attributes).to.eql({ - title: 'upserted title', - description: 'upserted description', + expect(resp.body).to.have.property('references'); + expect(resp.body.references).to.eql(references); }); - await supertest - .put(`/api/saved_objects/visualization/upserted-viz`) - .send({ - attributes: { - title: 'foobar', - }, - upsert: { - description: 'new upserted description', - version: 9000, - }, - }) - .expect(200); - - const { body: notUpserted } = await supertest - .get(`/api/saved_objects/visualization/upserted-viz`) - .expect(200); - - expect(notUpserted.attributes).to.eql({ - title: 'foobar', - description: 'upserted description', + it('passes empty references array if empty references array is provided', async () => { + const resp = await supertest + .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) + .send({ + attributes: { + title: 'foo', + }, + references: [], + }) + .expect(200); + + expect(resp.body).to.have.property('references'); + expect(resp.body.references).to.eql([]); + }); + + it('handles upsert', async () => { + await supertest + .put(`/api/saved_objects/visualization/upserted-viz`) + .send({ + attributes: { + title: 'foo', + }, + upsert: { + title: 'upserted title', + description: 'upserted description', + }, + }) + .expect(200); + + const { body: upserted } = await supertest + .get(`/api/saved_objects/visualization/upserted-viz`) + .expect(200); + + expect(upserted.attributes).to.eql({ + title: 'upserted title', + description: 'upserted description', + }); + + await supertest + .put(`/api/saved_objects/visualization/upserted-viz`) + .send({ + attributes: { + title: 'foobar', + }, + upsert: { + description: 'new upserted description', + version: 9000, + }, + }) + .expect(200); + + const { body: notUpserted } = await supertest + .get(`/api/saved_objects/visualization/upserted-viz`) + .expect(200); + + expect(notUpserted.attributes).to.eql({ + title: 'foobar', + description: 'upserted description', + }); + }); + + describe('unknown id', () => { + it('should return a generic 404', async () => { + await supertest + .put(`/api/saved_objects/visualization/not an id`) + .send({ + attributes: { + title: 'My second favorite vis', + }, + }) + .expect(404) + .then((resp) => { + expect(resp.body).eql({ + statusCode: 404, + error: 'Not Found', + message: 'Saved object [visualization/not an id] not found', + }); + }); + }); }); }); - describe('unknown id', () => { - it('should return a generic 404', async () => { + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 500', async () => await supertest - .put(`/api/saved_objects/visualization/not an id`) + .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) .send({ attributes: { title: 'My second favorite vis', }, }) - .expect(404) + .expect(500) .then((resp) => { expect(resp.body).eql({ - statusCode: 404, - error: 'Not Found', - message: 'Saved object [visualization/not an id] not found', + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred.', }); - }); - }); + })); }); }); } diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts index 6e36303cc1fe0..118f2fb1e91eb 100644 --- a/test/api_integration/apis/saved_objects_management/find.ts +++ b/test/api_integration/apis/saved_objects_management/find.ts @@ -11,6 +11,7 @@ import { Response } from 'supertest'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { + const esDeleteAllIndices = getService('esDeleteAllIndices'); const supertest = getService('supertest'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); @@ -25,16 +26,12 @@ export default function ({ getService }: FtrProviderContext) { }); describe('with kibana index', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); it('should return 200 with individual responses', async () => await supertest @@ -93,16 +90,12 @@ export default function ({ getService }: FtrProviderContext) { }); describe('`hasReference` and `hasReferenceOperator` parameters', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json' - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json' - ); - }); + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/references') + ); + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/references') + ); it('search for a reference', async () => { await supertest @@ -134,8 +127,8 @@ export default function ({ getService }: FtrProviderContext) { const objects = resp.body.saved_objects; expect(objects.map((obj: any) => obj.id)).to.eql([ 'only-ref-1', - 'only-ref-2', 'ref-1-and-ref-2', + 'only-ref-2', ]); }); }); @@ -160,6 +153,88 @@ export default function ({ getService }: FtrProviderContext) { }); }); + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 200 with empty response', async () => + await supertest + .get('/api/kibana/management/saved_objects/_find?type=visualization') + .expect(200) + .then((resp: Response) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + + describe('unknown type', () => { + it('should return 200 with empty response', async () => + await supertest + .get('/api/kibana/management/saved_objects/_find?type=wigwags') + .expect(200) + .then((resp: Response) => { + expect(resp.body).to.eql({ + page: 1, + per_page: 20, + total: 0, + saved_objects: [], + }); + })); + }); + + describe('missing type', () => { + it('should return 400', async () => + await supertest + .get('/api/kibana/management/saved_objects/_find') + .expect(400) + .then((resp: Response) => { + expect(resp.body).to.eql({ + error: 'Bad Request', + message: + '[request query.type]: expected at least one defined value but got [undefined]', + statusCode: 400, + }); + })); + }); + + describe('page beyond total', () => { + it('should return 200 with empty response', async () => + await supertest + .get( + '/api/kibana/management/saved_objects/_find?type=visualization&page=100&perPage=100' + ) + .expect(200) + .then((resp: Response) => { + expect(resp.body).to.eql({ + page: 100, + per_page: 100, + total: 0, + saved_objects: [], + }); + })); + }); + + describe('unknown search field', () => { + it('should return 400 when using searchFields', async () => + await supertest + .get('/api/kibana/management/saved_objects/_find?type=url&searchFields=a') + .expect(400) + .then((resp: Response) => { + expect(resp.body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: '[request query.searchFields]: definition for this key is missing', + }); + })); + }); + }); + describe('meta attributes injected properly', () => { before(() => esArchiver.load('test/api_integration/fixtures/es_archiver/management/saved_objects/search') diff --git a/test/api_integration/apis/saved_objects_management/get.ts b/test/api_integration/apis/saved_objects_management/get.ts index 3b49a28ca4022..5c6ea9d222d97 100644 --- a/test/api_integration/apis/saved_objects_management/get.ts +++ b/test/api_integration/apis/saved_objects_management/get.ts @@ -11,37 +11,49 @@ import { Response } from 'supertest'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { + const esDeleteAllIndices = getService('esDeleteAllIndices'); const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); describe('get', () => { const existingObject = 'visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab'; const nonexistentObject = 'wigwags/foo'; - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + describe('with kibana index', () => { + before(() => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + after(() => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') ); + + it('should return 200 for object that exists and inject metadata', async () => + await supertest + .get(`/api/kibana/management/saved_objects/${existingObject}`) + .expect(200) + .then((resp: Response) => { + const { body } = resp; + const { type, id, meta } = body; + expect(type).to.eql('visualization'); + expect(id).to.eql('dd7caf20-9efd-11e7-acb3-3dab96693fab'); + expect(meta).to.not.equal(undefined); + })); + + it('should return 404 for object that does not exist', async () => + await supertest + .get(`/api/kibana/management/saved_objects/${nonexistentObject}`) + .expect(404)); }); - it('should return 200 for object that exists and inject metadata', async () => - await supertest - .get(`/api/kibana/management/saved_objects/${existingObject}`) - .expect(200) - .then((resp: Response) => { - const { body } = resp; - const { type, id, meta } = body; - expect(type).to.eql('visualization'); - expect(id).to.eql('dd7caf20-9efd-11e7-acb3-3dab96693fab'); - expect(meta).to.not.equal(undefined); - })); - - it('should return 404 for object that does not exist', async () => - await supertest.get(`/api/kibana/management/saved_objects/${nonexistentObject}`).expect(404)); + describe('without kibana index', () => { + before( + async () => + // just in case the kibana server has recreated it + await esDeleteAllIndices('.kibana*') + ); + + it('should return 404 for object that no longer exists', async () => + await supertest.get(`/api/kibana/management/saved_objects/${existingObject}`).expect(404)); + }); }); } diff --git a/test/api_integration/apis/saved_objects_management/relationships.ts b/test/api_integration/apis/saved_objects_management/relationships.ts index aa488942edbeb..a9db49f40cf5b 100644 --- a/test/api_integration/apis/saved_objects_management/relationships.ts +++ b/test/api_integration/apis/saved_objects_management/relationships.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); const relationSchema = schema.object({ id: schema.string(), @@ -44,13 +44,13 @@ export default function ({ getService }: FtrProviderContext) { describe('relationships', () => { before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json' + await esArchiver.load( + 'test/api_integration/fixtures/es_archiver/management/saved_objects/relationships' ); }); after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json' + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/management/saved_objects/relationships' ); }); diff --git a/test/api_integration/apis/search/search.ts b/test/api_integration/apis/search/search.ts index 96e7f6ab7161b..afa1c063f9830 100644 --- a/test/api_integration/apis/search/search.ts +++ b/test/api_integration/apis/search/search.ts @@ -99,6 +99,26 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.body.message).to.contain('banana not found'); }); + it('should return 400 when index type is provided in OSS', async () => { + const resp = await supertest + .post(`/internal/search/es`) + .send({ + indexType: 'baad', + params: { + body: { + query: { + match_all: {}, + }, + }, + }, + }) + .expect(400); + + verifyErrorResponse(resp.body, 400); + + expect(resp.body.message).to.contain('Unsupported index pattern'); + }); + it('should return 400 with illegal ES argument', async () => { const resp = await supertest .post(`/internal/search/es`) diff --git a/test/api_integration/apis/shorten/index.js b/test/api_integration/apis/shorten/index.js index 86c39426205ad..5aa0fced78b40 100644 --- a/test/api_integration/apis/shorten/index.js +++ b/test/api_integration/apis/shorten/index.js @@ -9,20 +9,12 @@ import expect from '@kbn/expect'; export default function ({ getService }) { + const esArchiver = getService('esArchiver'); const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); describe('url shortener', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); + before(() => esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic')); + after(() => esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic')); it('generates shortened urls', async () => { const resp = await supertest diff --git a/test/api_integration/apis/stats/stats.js b/test/api_integration/apis/stats/stats.js index 61936a73da38d..a783e40ed5250 100644 --- a/test/api_integration/apis/stats/stats.js +++ b/test/api_integration/apis/stats/stats.js @@ -44,19 +44,15 @@ const assertStatsAndMetrics = (body) => { export default function ({ getService }) { const supertest = getService('supertest'); - const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); describe('kibana stats api', () => { - before(async () => { - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); - after(async () => { - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' - ); - }); + before('make sure there are some saved objects', () => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after('cleanup saved objects changes', () => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); describe('basic', () => { it('should return the stats without cluster_uuid with no query string params', () => { diff --git a/test/api_integration/apis/suggestions/suggestions.js b/test/api_integration/apis/suggestions/suggestions.js index 292e3f599d81a..d7affcbe72780 100644 --- a/test/api_integration/apis/suggestions/suggestions.js +++ b/test/api_integration/apis/suggestions/suggestions.js @@ -8,22 +8,21 @@ export default function ({ getService }) { const esArchiver = getService('esArchiver'); - const kibanaServer = getService('kibanaServer'); const supertest = getService('supertest'); describe('Suggestions API', function () { before(async () => { await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); - await kibanaServer.importExport.load( - 'test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json' + await esArchiver.load( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana' ); }); after(async () => { await esArchiver.unload( 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' ); - await kibanaServer.importExport.unload( - 'test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json' + await esArchiver.unload( + 'test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana' ); }); diff --git a/test/api_integration/apis/telemetry/index.js b/test/api_integration/apis/telemetry/index.js index 5394b54062d89..db95bf92cd44f 100644 --- a/test/api_integration/apis/telemetry/index.js +++ b/test/api_integration/apis/telemetry/index.js @@ -8,6 +8,7 @@ export default function ({ loadTestFile }) { describe('Telemetry', () => { + loadTestFile(require.resolve('./telemetry_local')); loadTestFile(require.resolve('./opt_in')); loadTestFile(require.resolve('./telemetry_optin_notice_seen')); }); diff --git a/test/api_integration/apis/telemetry/telemetry_local.ts b/test/api_integration/apis/telemetry/telemetry_local.ts new file mode 100644 index 0000000000000..7562a8b318f4d --- /dev/null +++ b/test/api_integration/apis/telemetry/telemetry_local.ts @@ -0,0 +1,339 @@ +/* + * 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 supertestAsPromised from 'supertest-as-promised'; +import { omit } from 'lodash'; +import { basicUiCounters } from './__fixtures__/ui_counters'; +import { basicUsageCounters } from './__fixtures__/usage_counters'; +import type { FtrProviderContext } from '../../ftr_provider_context'; +import type { SavedObject } from '../../../../src/core/server'; +import ossRootTelemetrySchema from '../../../../src/plugins/telemetry/schema/oss_root.json'; +import ossPluginsTelemetrySchema from '../../../../src/plugins/telemetry/schema/oss_plugins.json'; +import { assertTelemetryPayload, flatKeys } from './utils'; + +async function retrieveTelemetry( + supertest: supertestAsPromised.SuperTest +) { + const { body } = await supertest + .post('/api/telemetry/v2/clusters/_stats') + .set('kbn-xsrf', 'xxx') + .send({ unencrypted: true }) + .expect(200); + + expect(body.length).to.be(1); + return body[0]; +} + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const es = getService('es'); + const esArchiver = getService('esArchiver'); + + describe('/api/telemetry/v2/clusters/_stats', () => { + before('make sure there are some saved objects', () => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + after('cleanup saved objects changes', () => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic') + ); + + before('create some telemetry-data tracked indices', async () => { + await es.indices.create({ index: 'filebeat-telemetry_tests_logs' }); + }); + + after('cleanup telemetry-data tracked indices', async () => { + await es.indices.delete({ index: 'filebeat-telemetry_tests_logs' }); + }); + + describe('validate data types', () => { + let stats: Record; + + before('pull local stats', async () => { + stats = await retrieveTelemetry(supertest); + }); + + it('should pass the schema validation', () => { + try { + assertTelemetryPayload( + { root: ossRootTelemetrySchema, plugins: ossPluginsTelemetrySchema }, + stats + ); + } catch (err) { + err.message = `The telemetry schemas in 'src/plugins/telemetry/schema/' are out-of-date, please update it as required: ${err.message}`; + throw err; + } + }); + + it('should pass ad-hoc enforced validations', () => { + expect(stats.collection).to.be('local'); + expect(stats.collectionSource).to.be('local'); + expect(stats.license).to.be(undefined); // OSS cannot get the license + expect(stats.stack_stats.kibana.count).to.be.a('number'); + expect(stats.stack_stats.kibana.indices).to.be.a('number'); + expect(stats.stack_stats.kibana.os.platforms[0].platform).to.be.a('string'); + expect(stats.stack_stats.kibana.os.platforms[0].count).to.be(1); + expect(stats.stack_stats.kibana.os.platformReleases[0].platformRelease).to.be.a('string'); + expect(stats.stack_stats.kibana.os.platformReleases[0].count).to.be(1); + expect(stats.stack_stats.kibana.plugins.telemetry.opt_in_status).to.be(false); + expect(stats.stack_stats.kibana.plugins.telemetry.usage_fetcher).to.be.a('string'); + expect(stats.stack_stats.kibana.plugins.stack_management).to.be.an('object'); + expect(stats.stack_stats.kibana.plugins.ui_metric).to.be.an('object'); + expect(stats.stack_stats.kibana.plugins.ui_counters).to.be.an('object'); + expect(stats.stack_stats.kibana.plugins.application_usage).to.be.an('object'); + expect(stats.stack_stats.kibana.plugins.kql.defaultQueryLanguage).to.be.a('string'); + expect(stats.stack_stats.kibana.plugins.localization).to.be.an('object'); + expect(stats.stack_stats.kibana.plugins.csp.strict).to.be(false); + expect(stats.stack_stats.kibana.plugins.csp.warnLegacyBrowsers).to.be(true); + expect(stats.stack_stats.kibana.plugins.csp.rulesChangedFromDefault).to.be(false); + expect(stats.stack_stats.kibana.plugins.kibana_config_usage).to.be.an('object'); + // non-default kibana configs. Configs set at 'test/api_integration/config.js'. + expect(omit(stats.stack_stats.kibana.plugins.kibana_config_usage, 'server.port')).to.eql({ + 'elasticsearch.username': '[redacted]', + 'elasticsearch.password': '[redacted]', + 'elasticsearch.hosts': '[redacted]', + 'elasticsearch.healthCheck.delay': 3600000, + 'plugins.paths': '[redacted]', + 'logging.json': false, + 'server.xsrf.disableProtection': true, + 'server.compression.referrerWhitelist': '[redacted]', + 'server.maxPayload': 1679958, + 'status.allowAnonymous': true, + 'home.disableWelcomeScreen': true, + 'data.search.aggs.shardDelay.enabled': true, + 'security.showInsecureClusterWarning': false, + 'telemetry.banner': false, + 'telemetry.url': '[redacted]', + 'telemetry.optInStatusUrl': '[redacted]', + 'telemetry.optIn': false, + 'newsfeed.service.urlRoot': '[redacted]', + 'newsfeed.service.pathTemplate': '[redacted]', + 'savedObjects.maxImportPayloadBytes': 10485760, + 'savedObjects.maxImportExportSize': 10001, + 'usageCollection.usageCounters.bufferDuration': 0, + }); + expect(stats.stack_stats.kibana.plugins.kibana_config_usage['server.port']).to.be.a( + 'number' + ); + + // Testing stack_stats.data + expect(stats.stack_stats.data).to.be.an('object'); + expect(stats.stack_stats.data).to.be.an('array'); + expect(stats.stack_stats.data[0]).to.be.an('object'); + expect(stats.stack_stats.data[0].pattern_name).to.be('filebeat'); + expect(stats.stack_stats.data[0].shipper).to.be('filebeat'); + expect(stats.stack_stats.data[0].index_count).to.be(1); + expect(stats.stack_stats.data[0].doc_count).to.be(0); + expect(stats.stack_stats.data[0].ecs_index_count).to.be(0); + expect(stats.stack_stats.data[0].size_in_bytes).to.be.a('number'); + + expect(stats.stack_stats.kibana.plugins.saved_objects_counts).to.be.an('object'); + expect(stats.stack_stats.kibana.plugins.saved_objects_counts.by_type).to.be.an('array'); + expect(stats.stack_stats.kibana.plugins.saved_objects_counts.by_type).to.eql([ + { type: 'config', count: 2 }, + { type: 'dashboard', count: 2 }, + { type: 'index-pattern', count: 2 }, + { type: 'visualization', count: 2 }, + ]); + }); + + it('should validate mandatory fields exist', () => { + const actual = flatKeys(stats); + expect(actual).to.be.an('array'); + const expected = [ + 'cluster_name', + 'cluster_stats.cluster_uuid', + 'cluster_stats.indices.analysis', + 'cluster_stats.indices.completion', + 'cluster_stats.indices.count', + 'cluster_stats.indices.docs', + 'cluster_stats.indices.fielddata', + 'cluster_stats.indices.mappings', + 'cluster_stats.indices.query_cache', + 'cluster_stats.indices.segments', + 'cluster_stats.indices.shards', + 'cluster_stats.indices.store', + 'cluster_stats.nodes.count', + 'cluster_stats.nodes.discovery_types', + 'cluster_stats.nodes.fs', + 'cluster_stats.nodes.ingest', + 'cluster_stats.nodes.jvm', + 'cluster_stats.nodes.network_types', + 'cluster_stats.nodes.os', + 'cluster_stats.nodes.packaging_types', + 'cluster_stats.nodes.plugins', + 'cluster_stats.nodes.process', + 'cluster_stats.nodes.versions', + 'cluster_stats.nodes.usage', + 'cluster_stats.status', + 'cluster_stats.timestamp', + 'cluster_uuid', + 'collection', + 'collectionSource', + 'stack_stats.kibana.count', + 'stack_stats.kibana.indices', + 'stack_stats.kibana.os', + 'stack_stats.kibana.plugins', + 'stack_stats.kibana.versions', + 'timestamp', + 'version', + ]; + + expect(expected.every((m) => actual.includes(m))).to.be.ok(); + }); + }); + + describe('UI Counters telemetry', () => { + before('Add UI Counters saved objects', () => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/ui_counters') + ); + after('cleanup saved objects changes', () => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/ui_counters') + ); + it('returns ui counters aggregated by day', async () => { + const stats = await retrieveTelemetry(supertest); + expect(stats.stack_stats.kibana.plugins.ui_counters).to.eql(basicUiCounters); + }); + }); + + describe('Usage Counters telemetry', () => { + before('Add UI Counters saved objects', () => + esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/usage_counters') + ); + after('cleanup saved objects changes', () => + esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/usage_counters') + ); + + it('returns usage counters aggregated by day', async () => { + const stats = await retrieveTelemetry(supertest); + expect(stats.stack_stats.kibana.plugins.usage_counters).to.eql(basicUsageCounters); + }); + }); + + describe('application usage limits', () => { + function createSavedObject(viewId?: string) { + return supertest + .post('/api/saved_objects/application_usage_daily') + .send({ + attributes: { + appId: 'test-app', + viewId, + minutesOnScreen: 10.33, + numberOfClicks: 10, + timestamp: new Date().toISOString(), + }, + }) + .expect(200) + .then((resp) => resp.body.id); + } + + describe('basic behaviour', () => { + let savedObjectIds: string[] = []; + before('create application usage entries', async () => { + await esArchiver.emptyKibanaIndex(); + savedObjectIds = await Promise.all([ + createSavedObject(), + createSavedObject('appView1'), + createSavedObject(), + ]); + }); + after('cleanup', async () => { + await Promise.all( + savedObjectIds.map((savedObjectId) => { + return supertest + .delete(`/api/saved_objects/application_usage_daily/${savedObjectId}`) + .expect(200); + }) + ); + }); + + it('should return application_usage data', async () => { + const stats = await retrieveTelemetry(supertest); + expect(stats.stack_stats.kibana.plugins.application_usage).to.eql({ + 'test-app': { + appId: 'test-app', + viewId: 'main', + clicks_total: 20, + clicks_7_days: 20, + clicks_30_days: 20, + clicks_90_days: 20, + minutes_on_screen_total: 20.66, + minutes_on_screen_7_days: 20.66, + minutes_on_screen_30_days: 20.66, + minutes_on_screen_90_days: 20.66, + views: [ + { + appId: 'test-app', + viewId: 'appView1', + clicks_total: 10, + clicks_7_days: 10, + clicks_30_days: 10, + clicks_90_days: 10, + minutes_on_screen_total: 10.33, + minutes_on_screen_7_days: 10.33, + minutes_on_screen_30_days: 10.33, + minutes_on_screen_90_days: 10.33, + }, + ], + }, + }); + }); + }); + + describe('10k + 1', () => { + const savedObjectIds = []; + before('create 10k + 1 entries for application usage', async () => { + await supertest + .post('/api/saved_objects/_bulk_create') + .send( + new Array(10001).fill(0).map(() => ({ + type: 'application_usage_daily', + attributes: { + appId: 'test-app', + minutesOnScreen: 1, + numberOfClicks: 1, + timestamp: new Date().toISOString(), + }, + })) + ) + .expect(200) + .then((resp) => + resp.body.saved_objects.forEach(({ id }: SavedObject) => savedObjectIds.push(id)) + ); + }); + after('clean them all', async () => { + // The SavedObjects API does not allow bulk deleting, and deleting one by one takes ages and the tests timeout + await es.deleteByQuery({ + index: '.kibana', + body: { query: { term: { type: 'application_usage_daily' } } }, + conflicts: 'proceed', + }); + }); + + it("should only use the first 10k docs for the application_usage data (they'll be rolled up in a later process)", async () => { + const stats = await retrieveTelemetry(supertest); + expect(stats.stack_stats.kibana.plugins.application_usage).to.eql({ + 'test-app': { + appId: 'test-app', + viewId: 'main', + clicks_total: 10000, + clicks_7_days: 10000, + clicks_30_days: 10000, + clicks_90_days: 10000, + minutes_on_screen_total: 10000, + minutes_on_screen_7_days: 10000, + minutes_on_screen_30_days: 10000, + minutes_on_screen_90_days: 10000, + views: [], + }, + }); + }); + }); + }); + }); +} diff --git a/test/api_integration/config.js b/test/api_integration/config.js index 84fb0b7907c3b..7bbace4c60570 100644 --- a/test/api_integration/config.js +++ b/test/api_integration/config.js @@ -31,7 +31,6 @@ export default async function ({ readConfigFile }) { '--server.xsrf.disableProtection=true', '--server.compression.referrerWhitelist=["some-host.com"]', `--savedObjects.maxImportExportSize=10001`, - '--savedObjects.maxImportPayloadBytes=30000000', // for testing set buffer duration to 0 to immediately flush counters into saved objects. '--usageCollection.usageCounters.bufferDuration=0', ], diff --git a/test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana/data.json b/test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana/data.json new file mode 100644 index 0000000000000..54276b59dcc23 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana/data.json @@ -0,0 +1,15 @@ +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "index-pattern:91200a00-9efd-11e7-acb3-3dab96693fab", + "source": { + "type": "index-pattern", + "updated_at": "2017-09-21T18:49:16.270Z", + "index-pattern": { + "title": "basic_index", + "fields": "[{\"name\":\"bar\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"baz\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"baz.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"foo\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"nestedField.child\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"nested\":{\"path\":\"nestedField\"}}}]" + } + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana/mappings.json b/test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana/mappings.json new file mode 100644 index 0000000000000..99264d7ebbff8 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/index_patterns/basic_kibana/mappings.json @@ -0,0 +1,253 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "1" + } + }, + "mappings": { + "dynamic": "strict", + "properties": { + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "namespace": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/relationships/data.json b/test/api_integration/fixtures/es_archiver/management/saved_objects/relationships/data.json new file mode 100644 index 0000000000000..21d84c4b55e55 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/management/saved_objects/relationships/data.json @@ -0,0 +1,190 @@ +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "timelion-sheet:190f3e90-2ec3-11e8-ba48-69fc4e41e1f6", + "source": { + "type": "timelion-sheet", + "updated_at": "2018-03-23T17:53:30.872Z", + "timelion-sheet": { + "title": "New TimeLion Sheet", + "hits": 0, + "description": "", + "timelion_sheet": [ + ".es(*)" + ], + "timelion_interval": "auto", + "timelion_chart_height": 275, + "timelion_columns": 2, + "timelion_rows": 2, + "version": 1 + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "index-pattern:8963ca30-3224-11e8-a572-ffca06da1357", + "source": { + "type": "index-pattern", + "updated_at": "2018-03-28T01:08:34.290Z", + "index-pattern": { + "title": "saved_objects*", + "fields": "[{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]" + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "config:7.0.0-alpha1", + "source": { + "type": "config", + "updated_at": "2018-03-28T01:08:39.248Z", + "config": { + "buildNum": 8467, + "telemetry:optIn": false, + "defaultIndex": "8963ca30-3224-11e8-a572-ffca06da1357" + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "search:960372e0-3224-11e8-a572-ffca06da1357", + "source": { + "type": "search", + "updated_at": "2018-03-28T01:08:55.182Z", + "search": { + "title": "OneRecord", + "description": "", + "hits": 0, + "columns": [ + "_source" + ], + "sort": [ + "_score", + "desc" + ], + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"8963ca30-3224-11e8-a572-ffca06da1357\",\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"id:3\",\"language\":\"lucene\"},\"filter\":[]}" + } + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:a42c0580-3224-11e8-a572-ffca06da1357", + "source": { + "type": "visualization", + "updated_at": "2018-03-28T01:09:18.936Z", + "visualization": { + "title": "VisualizationFromSavedSearch", + "visState": "{\"title\":\"VisualizationFromSavedSearch\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}", + "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", + "description": "", + "savedSearchId": "960372e0-3224-11e8-a572-ffca06da1357", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:add810b0-3224-11e8-a572-ffca06da1357", + "source": { + "type": "visualization", + "updated_at": "2018-03-28T01:09:35.163Z", + "visualization": { + "title": "Visualization", + "visState": "{\"title\":\"Visualization\",\"type\":\"metric\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\",\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"8963ca30-3224-11e8-a572-ffca06da1357\",\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "dashboard:b70c7ae0-3224-11e8-a572-ffca06da1357", + "source": { + "type": "dashboard", + "updated_at": "2018-03-28T01:09:50.606Z", + "dashboard": { + "title": "Dashboard", + "hits": 0, + "description": "", + "panelsJSON": "[{\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"version\":\"7.0.0-alpha1\",\"panelIndex\":\"1\",\"type\":\"visualization\",\"id\":\"add810b0-3224-11e8-a572-ffca06da1357\",\"embeddableConfig\":{}},{\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"version\":\"7.0.0-alpha1\",\"panelIndex\":\"2\",\"type\":\"visualization\",\"id\":\"a42c0580-3224-11e8-a572-ffca06da1357\",\"embeddableConfig\":{}}]", + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "version": 1, + "timeRestore": false, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + } + } + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "dashboard:invalid-refs", + "source": { + "type": "dashboard", + "updated_at": "2018-03-28T01:09:50.606Z", + "dashboard": { + "title": "Dashboard", + "hits": 0, + "description": "", + "panelsJSON": "[]", + "optionsJSON": "{}", + "version": 1, + "timeRestore": false, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + } + }, + "references": [ + { + "type":"visualization", + "id": "add810b0-3224-11e8-a572-ffca06da1357", + "name": "valid-ref" + }, + { + "type":"visualization", + "id": "invalid-vis", + "name": "missing-ref" + } + ] + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/relationships/mappings.json b/test/api_integration/fixtures/es_archiver/management/saved_objects/relationships/mappings.json new file mode 100644 index 0000000000000..6dd4d198e0f67 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/management/saved_objects/relationships/mappings.json @@ -0,0 +1,297 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "auto_expand_replicas": "0-1", + "number_of_replicas": "0" + } + }, + "mappings": { + "dynamic": "strict", + "properties": { + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "telemetry:optIn": { + "type": "boolean" + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "graph-workspace": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "numLinks": { + "type": "integer" + }, + "numVertices": { + "type": "integer" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "wsState": { + "type": "text" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/10k/data.json.gz b/test/api_integration/fixtures/es_archiver/saved_objects/10k/data.json.gz new file mode 100644 index 0000000000000..b1a2b4301f4d8 Binary files /dev/null and b/test/api_integration/fixtures/es_archiver/saved_objects/10k/data.json.gz differ diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/10k/mappings.json b/test/api_integration/fixtures/es_archiver/saved_objects/10k/mappings.json new file mode 100644 index 0000000000000..99264d7ebbff8 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/saved_objects/10k/mappings.json @@ -0,0 +1,253 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "1" + } + }, + "mappings": { + "dynamic": "strict", + "properties": { + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "namespace": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/basic/data.json.gz b/test/api_integration/fixtures/es_archiver/saved_objects/basic/data.json.gz new file mode 100644 index 0000000000000..c72f46370fa12 Binary files /dev/null and b/test/api_integration/fixtures/es_archiver/saved_objects/basic/data.json.gz differ diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/basic/mappings.json b/test/api_integration/fixtures/es_archiver/saved_objects/basic/mappings.json new file mode 100644 index 0000000000000..e601c43431437 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/saved_objects/basic/mappings.json @@ -0,0 +1,267 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "1" + } + }, + "mappings": { + "dynamic": "strict", + "properties": { + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "namespace": { + "type": "keyword" + }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases/data.json b/test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases/data.json new file mode 100644 index 0000000000000..0c8b35fd3f499 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases/data.json @@ -0,0 +1,93 @@ +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:title-with-dash", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "my-visualization", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [] + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:title-with-asterisk", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "some*visualization", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [] + } + } +} + + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:noise-1", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "Just some noise in the dataset", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [] + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:noise-2", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "Just some noise in the dataset", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [] + } + } +} + diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases/mappings.json b/test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases/mappings.json new file mode 100644 index 0000000000000..e601c43431437 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/saved_objects/find_edgecases/mappings.json @@ -0,0 +1,267 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "1" + } + }, + "mappings": { + "dynamic": "strict", + "properties": { + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "namespace": { + "type": "keyword" + }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/references/data.json b/test/api_integration/fixtures/es_archiver/saved_objects/references/data.json new file mode 100644 index 0000000000000..8b2095972bd4d --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/saved_objects/references/data.json @@ -0,0 +1,120 @@ +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:only-ref-1", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "Vis with ref to ref-1", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [ + { + "type": "ref-type", + "id": "ref-1", + "name": "ref-1" + } + ] + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:ref-1-and-ref-2", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "Vis with ref to ref-1 and ref-2", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [ + { + "type": "ref-type", + "id": "ref-1", + "name": "ref-1" + }, + { + "type": "ref-type", + "id": "ref-2", + "name": "ref-2" + } + ] + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:only-ref-2", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "Vis with ref to ref-2", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [ + { + "type": "ref-type", + "id": "ref-2", + "name": "ref-2" + } + ] + } + } +} + +{ + "type": "doc", + "value": { + "index": ".kibana", + "id": "visualization:only-ref-3", + "source": { + "type": "visualization", + "updated_at": "2017-09-21T18:51:23.794Z", + "visualization": { + "title": "Vis with ref to ref-3", + "visState": "{}", + "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + } + }, + "references": [ + { + "type": "ref-type", + "id": "ref-3", + "name": "ref-3" + } + ] + } + } +} diff --git a/test/api_integration/fixtures/es_archiver/saved_objects/references/mappings.json b/test/api_integration/fixtures/es_archiver/saved_objects/references/mappings.json new file mode 100644 index 0000000000000..e601c43431437 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/saved_objects/references/mappings.json @@ -0,0 +1,267 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "1" + } + }, + "mappings": { + "dynamic": "strict", + "properties": { + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + }, + "defaultIndex": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "namespace": { + "type": "keyword" + }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + } +} diff --git a/test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json b/test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json deleted file mode 100644 index 2fff00dd22664..0000000000000 --- a/test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "attributes": { - "fields": "[{\"name\":\"bar\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"baz\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"baz.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"foo\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"nestedField.child\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"nested\":{\"path\":\"nestedField\"}}}]", - "title": "basic_index" - }, - "coreMigrationVersion": "7.14.0", - "id": "91200a00-9efd-11e7-acb3-3dab96693fab", - "migrationVersion": { - "index-pattern": "7.11.0" - }, - "references": [], - "type": "index-pattern", - "updated_at": "2017-09-21T18:49:16.270Z", - "version": "WzEsMl0=" -} \ No newline at end of file diff --git a/test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json b/test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json deleted file mode 100644 index da2241952ca37..0000000000000 --- a/test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json +++ /dev/null @@ -1,200 +0,0 @@ -{ - "attributes": { - "description": "", - "hits": 0, - "timelion_chart_height": 275, - "timelion_columns": 2, - "timelion_interval": "auto", - "timelion_rows": 2, - "timelion_sheet": [ - ".es(*)" - ], - "title": "New TimeLion Sheet", - "version": 1 - }, - "coreMigrationVersion": "8.0.0", - "id": "190f3e90-2ec3-11e8-ba48-69fc4e41e1f6", - "references": [], - "type": "timelion-sheet", - "updated_at": "2018-03-23T17:53:30.872Z", - "version": "WzgsMl0=" -} - -{ - "attributes": { - "fields": "[{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", - "title": "saved_objects*" - }, - "coreMigrationVersion": "8.0.0", - "id": "8963ca30-3224-11e8-a572-ffca06da1357", - "migrationVersion": { - "index-pattern": "7.11.0" - }, - "references": [], - "type": "index-pattern", - "updated_at": "2018-03-28T01:08:34.290Z", - "version": "WzksMl0=" -} - -{ - "attributes": { - "columns": [ - "_source" - ], - "description": "", - "hits": 0, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"id:3\",\"language\":\"lucene\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" - }, - "sort": [ - [ - "_score", - "desc" - ] - ], - "title": "OneRecord", - "version": 1 - }, - "coreMigrationVersion": "8.0.0", - "id": "960372e0-3224-11e8-a572-ffca06da1357", - "migrationVersion": { - "search": "7.9.3" - }, - "references": [ - { - "id": "8963ca30-3224-11e8-a572-ffca06da1357", - "name": "kibanaSavedObjectMeta.searchSourceJSON.index", - "type": "index-pattern" - } - ], - "type": "search", - "updated_at": "2018-03-28T01:08:55.182Z", - "version": "WzExLDJd" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "savedSearchRefName": "search_0", - "title": "VisualizationFromSavedSearch", - "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", - "version": 1, - "visState": "{\"title\":\"VisualizationFromSavedSearch\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\",\"showToolbar\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" - }, - "coreMigrationVersion": "8.0.0", - "id": "a42c0580-3224-11e8-a572-ffca06da1357", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "960372e0-3224-11e8-a572-ffca06da1357", - "name": "search_0", - "type": "search" - } - ], - "type": "visualization", - "updated_at": "2018-03-28T01:09:18.936Z", - "version": "WzEyLDJd" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" - }, - "title": "Visualization", - "uiStateJSON": "{}", - "version": 1, - "visState": "{\"title\":\"Visualization\",\"type\":\"metric\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\",\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" - }, - "coreMigrationVersion": "8.0.0", - "id": "add810b0-3224-11e8-a572-ffca06da1357", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "8963ca30-3224-11e8-a572-ffca06da1357", - "name": "kibanaSavedObjectMeta.searchSourceJSON.index", - "type": "index-pattern" - } - ], - "type": "visualization", - "updated_at": "2018-03-28T01:09:35.163Z", - "version": "WzEzLDJd" -} - -{ - "attributes": { - "description": "", - "hits": 0, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" - }, - "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", - "panelsJSON": "[{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_0\"},{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"}]", - "timeRestore": false, - "title": "Dashboard", - "version": 1 - }, - "coreMigrationVersion": "8.0.0", - "id": "b70c7ae0-3224-11e8-a572-ffca06da1357", - "migrationVersion": { - "dashboard": "7.11.0" - }, - "references": [ - { - "id": "add810b0-3224-11e8-a572-ffca06da1357", - "name": "panel_0", - "type": "visualization" - }, - { - "id": "a42c0580-3224-11e8-a572-ffca06da1357", - "name": "panel_1", - "type": "visualization" - } - ], - "type": "dashboard", - "updated_at": "2018-03-28T01:09:50.606Z", - "version": "WzE0LDJd" -} - -{ - "attributes": { - "description": "", - "hits": 0, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"kuery\"}}" - }, - "optionsJSON": "{}", - "panelsJSON": "[]", - "timeRestore": false, - "title": "Dashboard", - "version": 1 - }, - "coreMigrationVersion": "8.0.0", - "id": "invalid-refs", - "migrationVersion": { - "dashboard": "7.11.0" - }, - "references": [ - { - "id": "add810b0-3224-11e8-a572-ffca06da1357", - "name": "valid-ref", - "type": "visualization" - }, - { - "id": "invalid-vis", - "name": "missing-ref", - "type": "visualization" - } - ], - "type": "dashboard", - "updated_at": "2018-03-28T01:09:50.606Z", - "version": "WzE1LDJd" -} \ No newline at end of file diff --git a/test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json b/test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json deleted file mode 100644 index 4f343b81cd402..0000000000000 --- a/test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "attributes": { - "buildNum": 8467, - "defaultIndex": "91200a00-9efd-11e7-acb3-3dab96693fab" - }, - "coreMigrationVersion": "7.14.0", - "id": "7.0.0-alpha1", - "migrationVersion": { - "config": "7.13.0" - }, - "references": [], - "type": "config", - "updated_at": "2017-09-21T18:49:16.302Z", - "version": "WzksMl0=" -} - -{ - "attributes": { - "fields": "[{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@message.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@tags.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"extension.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"headings.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"request.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"response.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"spaces.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", - "timeFieldName": "@timestamp", - "title": "logstash-*" - }, - "coreMigrationVersion": "7.14.0", - "id": "91200a00-9efd-11e7-acb3-3dab96693fab", - "migrationVersion": { - "index-pattern": "7.11.0" - }, - "references": [], - "type": "index-pattern", - "updated_at": "2017-09-21T18:49:16.270Z", - "version": "WzgsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" - }, - "title": "Count of requests", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{\"title\":\"Count of requests\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100,\"filter\":true},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1,\"extended_bounds\":{}}}]}" - }, - "coreMigrationVersion": "7.14.0", - "id": "dd7caf20-9efd-11e7-acb3-3dab96693fab", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "91200a00-9efd-11e7-acb3-3dab96693fab", - "name": "kibanaSavedObjectMeta.searchSourceJSON.index", - "type": "index-pattern" - } - ], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzEwLDJd" -} - -{ - "attributes": { - "description": "", - "hits": 0, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" - }, - "optionsJSON": "{\"darkTheme\":false}", - "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":12,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"}]", - "refreshInterval": { - "display": "Off", - "pause": false, - "value": 0 - }, - "timeFrom": "Wed Sep 16 2015 22:52:17 GMT-0700", - "timeRestore": true, - "timeTo": "Fri Sep 18 2015 12:24:38 GMT-0700", - "title": "Requests", - "version": 1 - }, - "coreMigrationVersion": "7.14.0", - "id": "be3733a0-9efe-11e7-acb3-3dab96693fab", - "migrationVersion": { - "dashboard": "7.11.0" - }, - "references": [ - { - "id": "dd7caf20-9efd-11e7-acb3-3dab96693fab", - "name": "1:panel_1", - "type": "visualization" - } - ], - "type": "dashboard", - "updated_at": "2017-09-21T18:57:40.826Z", - "version": "WzExLDJd" -} \ No newline at end of file diff --git a/test/api_integration/fixtures/kbn_archiver/saved_objects/basic/foo-ns.json b/test/api_integration/fixtures/kbn_archiver/saved_objects/basic/foo-ns.json deleted file mode 100644 index 736abf331d314..0000000000000 --- a/test/api_integration/fixtures/kbn_archiver/saved_objects/basic/foo-ns.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "attributes": { - "buildNum": 8467, - "defaultIndex": "91200a00-9efd-11e7-acb3-3dab96693fab" - }, - "coreMigrationVersion": "7.14.0", - "id": "7.0.0-alpha1", - "migrationVersion": { - "config": "7.13.0" - }, - "references": [], - "type": "config", - "updated_at": "2017-09-21T18:49:16.302Z", - "version": "WzEzLDJd" -} - -{ - "attributes": { - "fields": "[{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@message.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@tags.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"extension.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"headings.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"request.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"response.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"spaces.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", - "timeFieldName": "@timestamp", - "title": "logstash-*" - }, - "coreMigrationVersion": "7.14.0", - "id": "91200a00-9efd-11e7-acb3-3dab96693fab", - "migrationVersion": { - "index-pattern": "7.11.0" - }, - "references": [], - "type": "index-pattern", - "updated_at": "2017-09-21T18:49:16.270Z", - "version": "WzEyLDJd" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" - }, - "title": "Count of requests", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{\"title\":\"Count of requests\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100,\"filter\":true},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1,\"extended_bounds\":{}}}]}" - }, - "coreMigrationVersion": "7.14.0", - "id": "dd7caf20-9efd-11e7-acb3-3dab96693fab", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "91200a00-9efd-11e7-acb3-3dab96693fab", - "name": "kibanaSavedObjectMeta.searchSourceJSON.index", - "type": "index-pattern" - } - ], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzE0LDJd" -} - -{ - "attributes": { - "description": "", - "hits": 0, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" - }, - "optionsJSON": "{\"darkTheme\":false}", - "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":12,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"}]", - "refreshInterval": { - "display": "Off", - "pause": false, - "value": 0 - }, - "timeFrom": "Wed Sep 16 2015 22:52:17 GMT-0700", - "timeRestore": true, - "timeTo": "Fri Sep 18 2015 12:24:38 GMT-0700", - "title": "Requests", - "version": 1 - }, - "coreMigrationVersion": "7.14.0", - "id": "be3733a0-9efe-11e7-acb3-3dab96693fab", - "migrationVersion": { - "dashboard": "7.11.0" - }, - "references": [ - { - "id": "dd7caf20-9efd-11e7-acb3-3dab96693fab", - "name": "1:panel_1", - "type": "visualization" - } - ], - "type": "dashboard", - "updated_at": "2017-09-21T18:57:40.826Z", - "version": "WzE1LDJd" -} \ No newline at end of file diff --git a/test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json b/test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json deleted file mode 100644 index 7b181e10b958f..0000000000000 --- a/test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "Just some noise in the dataset", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "noise-1", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzYsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "Just some noise in the dataset", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "noise-2", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzcsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "some*visualization", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "title-with-asterisk", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzUsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "my-visualization", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "title-with-dash", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzQsMl0=" -} \ No newline at end of file diff --git a/test/api_integration/fixtures/kbn_archiver/saved_objects/references.json b/test/api_integration/fixtures/kbn_archiver/saved_objects/references.json deleted file mode 100644 index 1da6ed3731e32..0000000000000 --- a/test/api_integration/fixtures/kbn_archiver/saved_objects/references.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "Vis with ref to ref-1", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "only-ref-1", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "ref-1", - "name": "ref-1", - "type": "ref-type" - } - ], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzQsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "Vis with ref to ref-2", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "only-ref-2", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "ref-2", - "name": "ref-2", - "type": "ref-type" - } - ], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzYsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "Vis with ref to ref-3", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "only-ref-3", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "ref-3", - "name": "ref-3", - "type": "ref-type" - } - ], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzcsMl0=" -} - -{ - "attributes": { - "description": "", - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" - }, - "title": "Vis with ref to ref-1 and ref-2", - "uiStateJSON": "{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}}", - "version": 1, - "visState": "{}" - }, - "coreMigrationVersion": "8.0.0", - "id": "ref-1-and-ref-2", - "migrationVersion": { - "visualization": "7.13.0" - }, - "references": [ - { - "id": "ref-1", - "name": "ref-1", - "type": "ref-type" - }, - { - "id": "ref-2", - "name": "ref-2", - "type": "ref-type" - } - ], - "type": "visualization", - "updated_at": "2017-09-21T18:51:23.794Z", - "version": "WzUsMl0=" -} \ No newline at end of file diff --git a/test/common/services/deployment.ts b/test/common/services/deployment.ts index b250d39ce65d6..4f7baf69d5d1e 100644 --- a/test/common/services/deployment.ts +++ b/test/common/services/deployment.ts @@ -29,6 +29,14 @@ export class DeploymentService extends FtrService { return getUrl.baseUrl(this.config.get('servers.elasticsearch')); } + /** + * Helper to detect an OSS licensed Kibana + * Useful for functional testing in cloud environment + */ + async isOss() { + return this.config.get('kbnTestServer.serverArgs').indexOf('--oss') > -1; + } + async isCloud(): Promise { const baseUrl = this.getHostPort(); const username = this.config.get('servers.kibana.username'); diff --git a/test/examples/expressions_explorer/expressions.ts b/test/examples/expressions_explorer/expressions.ts index 4c240653b5fdd..39afa177501d5 100644 --- a/test/examples/expressions_explorer/expressions.ts +++ b/test/examples/expressions_explorer/expressions.ts @@ -22,7 +22,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) { await retry.try(async () => { const text = await testSubjects.getVisibleText('expressionResult'); expect(text).to.be( - '{\n "type": "render",\n "as": "markdown",\n "value": {\n "content": "## expressions explorer",\n "font": {\n "type": "style",\n "spec": {\n "fontFamily": "\'Open Sans\', Helvetica, Arial, sans-serif",\n "fontWeight": "normal",\n "fontStyle": "normal",\n "textDecoration": "none",\n "textAlign": "left",\n "fontSize": "14px",\n "lineHeight": "1"\n },\n "css": "font-family:\'Open Sans\', Helvetica, Arial, sans-serif;font-weight:normal;font-style:normal;text-decoration:none;text-align:left;font-size:14px;line-height:1"\n },\n "openLinksInNewTab": false\n }\n}' + '{\n "type": "error",\n "error": {\n "message": "Function markdown could not be found.",\n "name": "fn not found"\n }\n}' ); }); }); @@ -30,7 +30,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) { it('renders expression', async () => { await retry.try(async () => { const text = await testSubjects.getVisibleText('expressionRender'); - expect(text).to.be('expressions explorer rendering'); + expect(text).to.be('Function markdown could not be found.'); }); }); diff --git a/test/functional/apps/home/_home.js b/test/functional/apps/home/_home.js index 24e672463964d..056f3ec6f993c 100644 --- a/test/functional/apps/home/_home.js +++ b/test/functional/apps/home/_home.js @@ -11,7 +11,6 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const browser = getService('browser'); const globalNav = getService('globalNav'); - const testSubjects = getService('testSubjects'); const PageObjects = getPageObjects(['common', 'header', 'home']); describe('Kibana takes you home', function describeIndexTests() { @@ -26,8 +25,7 @@ export default function ({ getService, getPageObjects }) { }); it('clicking on console on homepage should take you to console app', async () => { - await PageObjects.common.navigateToUrl('home'); - await testSubjects.click('homeDevTools'); + await PageObjects.home.clickSynopsis('console'); const url = await browser.getCurrentUrl(); expect(url.includes('/app/dev_tools#/console')).to.be(true); }); diff --git a/test/functional/apps/home/_newsfeed.ts b/test/functional/apps/home/_newsfeed.ts index 5b8b5a22cf439..449aeea013341 100644 --- a/test/functional/apps/home/_newsfeed.ts +++ b/test/functional/apps/home/_newsfeed.ts @@ -11,6 +11,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const globalNav = getService('globalNav'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['newsfeed']); describe('Newsfeed', () => { @@ -37,9 +38,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('shows all news from newsfeed', async () => { const objects = await PageObjects.newsfeed.getNewsfeedList(); - // can't shim the API in cloud so going to check that at least something is rendered - // to test that the API was called and returned something that could be rendered - expect(objects.length).to.be.above(0); + if (await deployment.isOss()) { + expect(objects).to.eql([ + '21 June 2019\nYou are functionally testing the newsfeed widget with fixtures!\nSee test/common/fixtures/plugins/newsfeed/newsfeed_simulation\nGeneric feed-viewer could go here', + '21 June 2019\nStaging too!\nHello world\nGeneric feed-viewer could go here', + ]); + } else { + // can't shim the API in cloud so going to check that at least something is rendered + // to test that the API was called and returned something that could be rendered + expect(objects.length).to.be.above(0); + } }); it('clicking on newsfeed icon should close opened newsfeed', async () => { diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 2ff9e55c59ebb..94a861c11fa01 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -27,6 +27,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); + const deployment = getService('deployment'); const log = getService('log'); const browser = getService('browser'); const retry = getService('retry'); @@ -186,14 +187,16 @@ export default function ({ getService, getPageObjects }) { }); it('should visualize scripted field in vertical bar chart', async function () { - await filterBar.removeAllFilters(); - await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName); - await PageObjects.header.waitUntilLoadingHasFinished(); - // verify Lens opens a visualization - expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( - '@timestamp', - 'Median of ram_Pain1' - ); + const isOss = await deployment.isOss(); + if (!isOss) { + await filterBar.removeAllFilters(); + await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName); + await PageObjects.header.waitUntilLoadingHasFinished(); + // verify Lens opens a visualization + expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( + 'Average of ram_Pain1' + ); + } }); }); @@ -274,12 +277,15 @@ export default function ({ getService, getPageObjects }) { }); it('should visualize scripted field in vertical bar chart', async function () { - await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); - await PageObjects.header.waitUntilLoadingHasFinished(); - // verify Lens opens a visualization - expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( - 'Top values of painString' - ); + const isOss = await deployment.isOss(); + if (!isOss) { + await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); + await PageObjects.header.waitUntilLoadingHasFinished(); + // verify Lens opens a visualization + expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( + 'Top values of painString' + ); + } }); }); @@ -361,12 +367,15 @@ export default function ({ getService, getPageObjects }) { }); it('should visualize scripted field in vertical bar chart', async function () { - await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); - await PageObjects.header.waitUntilLoadingHasFinished(); - // verify Lens opens a visualization - expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( - 'Top values of painBool' - ); + const isOss = await deployment.isOss(); + if (!isOss) { + await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); + await PageObjects.header.waitUntilLoadingHasFinished(); + // verify Lens opens a visualization + expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( + 'Top values of painBool' + ); + } }); }); @@ -451,10 +460,15 @@ export default function ({ getService, getPageObjects }) { }); it('should visualize scripted field in vertical bar chart', async function () { - await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); - await PageObjects.header.waitUntilLoadingHasFinished(); - // verify Lens opens a visualization - expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain('painDate'); + const isOss = await deployment.isOss(); + if (!isOss) { + await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); + await PageObjects.header.waitUntilLoadingHasFinished(); + // verify Lens opens a visualization + expect(await testSubjects.getVisibleTextAll('lns-dimensionTrigger')).to.contain( + 'painDate' + ); + } }); }); }); diff --git a/test/functional/apps/visualize/_chart_types.ts b/test/functional/apps/visualize/_chart_types.ts index f52d8f00c1e48..1afc372f75b0e 100644 --- a/test/functional/apps/visualize/_chart_types.ts +++ b/test/functional/apps/visualize/_chart_types.ts @@ -35,7 +35,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.visualize.clickAggBasedVisualizations(); const expectedChartTypes = [ 'Area', - 'Coordinate Map', 'Data table', 'Gauge', 'Goal', @@ -44,7 +43,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Line', 'Metric', 'Pie', - 'Region Map', 'Tag cloud', 'Timelion', 'Vertical bar', diff --git a/test/functional/apps/visualize/_tile_map.ts b/test/functional/apps/visualize/_tile_map.ts index 812b6a7d86802..28b8daec94223 100644 --- a/test/functional/apps/visualize/_tile_map.ts +++ b/test/functional/apps/visualize/_tile_map.ts @@ -126,26 +126,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('Fit data bounds should zoom to level 3', async function () { const expectedPrecision2DataTable = [ - ['-', 'dn', '1,429', { lat: 36, lon: -85 }], - ['-', 'dp', '1,418', { lat: 41, lon: -85 }], - ['-', '9y', '1,215', { lat: 36, lon: -96 }], - ['-', '9z', '1,099', { lat: 42, lon: -96 }], - ['-', 'dr', '1,076', { lat: 42, lon: -74 }], - ['-', 'dj', '982', { lat: 31, lon: -85 }], - ['-', '9v', '938', { lat: 31, lon: -96 }], - ['-', '9q', '722', { lat: 36, lon: -120 }], - ['-', '9w', '475', { lat: 36, lon: -107 }], - ['-', 'cb', '457', { lat: 46, lon: -96 }], - ['-', 'c2', '453', { lat: 47, lon: -120 }], - ['-', '9x', '420', { lat: 41, lon: -107 }], - ['-', 'dq', '399', { lat: 37, lon: -78 }], - ['-', '9r', '396', { lat: 41, lon: -120 }], - ['-', '9t', '274', { lat: 32, lon: -107 }], - ['-', 'c8', '271', { lat: 47, lon: -107 }], - ['-', 'dh', '214', { lat: 26, lon: -82 }], - ['-', 'b6', '207', { lat: 60, lon: -162 }], - ['-', 'bd', '206', { lat: 59, lon: -153 }], - ['-', 'b7', '167', { lat: 64, lon: -163 }], + ['-', 'dr4', '127', { lat: 40, lon: -76 }], + ['-', 'dr7', '92', { lat: 41, lon: -74 }], + ['-', '9q5', '91', { lat: 34, lon: -119 }], + ['-', '9qc', '89', { lat: 38, lon: -122 }], + ['-', 'drk', '87', { lat: 41, lon: -73 }], + ['-', 'dps', '82', { lat: 42, lon: -84 }], + ['-', 'dph', '82', { lat: 40, lon: -84 }], + ['-', 'dp3', '79', { lat: 41, lon: -88 }], + ['-', 'dpe', '78', { lat: 42, lon: -86 }], + ['-', 'dp8', '77', { lat: 43, lon: -90 }], + ['-', 'dp6', '74', { lat: 41, lon: -87 }], + ['-', 'djv', '74', { lat: 33, lon: -83 }], + ['-', '9qh', '74', { lat: 34, lon: -118 }], + ['-', 'dpq', '73', { lat: 41, lon: -81 }], + ['-', 'dpp', '73', { lat: 40, lon: -80 }], + ['-', '9y7', '73', { lat: 35, lon: -97 }], + ['-', '9vg', '73', { lat: 32, lon: -97 }], + ['-', 'drs', '71', { lat: 42, lon: -73 }], + ['-', '9ys', '71', { lat: 37, lon: -95 }], + ['-', '9yn', '71', { lat: 34, lon: -93 }], ]; await PageObjects.tileMap.clickMapFitDataBounds(); diff --git a/test/functional/apps/visualize/index.ts b/test/functional/apps/visualize/index.ts index cecd206abd1db..8f8396cc38c8e 100644 --- a/test/functional/apps/visualize/index.ts +++ b/test/functional/apps/visualize/index.ts @@ -13,6 +13,8 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); + const deployment = getService('deployment'); + let isOss = true; describe('visualize app', () => { before(async () => { @@ -22,6 +24,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); + isOss = await deployment.isOss(); }); // TODO: Remove when vislib is removed @@ -60,7 +63,11 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./_data_table')); loadTestFile(require.resolve('./_data_table_nontimeindex')); loadTestFile(require.resolve('./_data_table_notimeindex_filters')); - loadTestFile(require.resolve('./_chart_types')); + + // this check is not needed when the CI doesn't run anymore for the OSS + if (!isOss) { + loadTestFile(require.resolve('./_chart_types')); + } }); describe('visualize ciGroup10', function () { @@ -88,8 +95,11 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./_linked_saved_searches')); loadTestFile(require.resolve('./_visualize_listing')); loadTestFile(require.resolve('./_add_to_dashboard.ts')); - loadTestFile(require.resolve('./_tile_map')); - loadTestFile(require.resolve('./_region_map')); + + if (isOss) { + loadTestFile(require.resolve('./_tile_map')); + loadTestFile(require.resolve('./_region_map')); + } }); describe('visualize ciGroup12', function () { diff --git a/test/functional/config.js b/test/functional/config.js index 4a6791a3bc62f..1048bd72dc575 100644 --- a/test/functional/config.js +++ b/test/functional/config.js @@ -14,7 +14,6 @@ export default async function ({ readConfigFile }) { return { testFiles: [ - require.resolve('./apps/status_page'), require.resolve('./apps/bundles'), require.resolve('./apps/console'), require.resolve('./apps/context'), @@ -24,6 +23,7 @@ export default async function ({ readConfigFile }) { require.resolve('./apps/home'), require.resolve('./apps/management'), require.resolve('./apps/saved_objects_management'), + require.resolve('./apps/status_page'), require.resolve('./apps/timelion'), require.resolve('./apps/visualize'), ], @@ -36,15 +36,13 @@ export default async function ({ readConfigFile }) { ...commonConfig.get('esTestCluster'), serverArgs: ['xpack.security.enabled=false'], }, - kbnTestServer: { ...commonConfig.get('kbnTestServer'), serverArgs: [ ...commonConfig.get('kbnTestServer.serverArgs'), + '--oss', '--telemetry.optIn=false', - '--xpack.security.enabled=false', '--savedObjects.maxImportPayloadBytes=10485760', - '--xpack.maps.showMapVisualizationTypes=true', ], }, diff --git a/test/functional/page_objects/home_page.ts b/test/functional/page_objects/home_page.ts index 33de6a33c50f5..a0ae5367e7c5d 100644 --- a/test/functional/page_objects/home_page.ts +++ b/test/functional/page_objects/home_page.ts @@ -12,8 +12,11 @@ export class HomePageObject extends FtrService { private readonly testSubjects = this.ctx.getService('testSubjects'); private readonly retry = this.ctx.getService('retry'); private readonly find = this.ctx.getService('find'); + private readonly deployment = this.ctx.getService('deployment'); private readonly common = this.ctx.getPageObject('common'); + private isOss = true; + async clickSynopsis(title: string) { await this.testSubjects.click(`homeSynopsisLink${title}`); } @@ -69,7 +72,10 @@ export class HomePageObject extends FtrService { async launchSampleDashboard(id: string) { await this.launchSampleDataSet(id); - await this.find.clickByLinkText('Dashboard'); + this.isOss = await this.deployment.isOss(); + if (!this.isOss) { + await this.find.clickByLinkText('Dashboard'); + } } async launchSampleDataSet(id: string) { diff --git a/test/scripts/jenkins_build_kibana.sh b/test/scripts/jenkins_build_kibana.sh index b7004e85f0983..95c619423d313 100755 --- a/test/scripts/jenkins_build_kibana.sh +++ b/test/scripts/jenkins_build_kibana.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -cd "$KIBANA_DIR" source src/dev/ci_setup/setup_env.sh if [[ ! "$TASK_QUEUE_PROCESS_ID" ]]; then @@ -13,47 +12,13 @@ export KBN_NP_PLUGINS_BUILT=true echo " -> Ensuring all functional tests are in a ciGroup" node scripts/ensure_all_tests_in_ci_group; -echo " -> Ensuring all x-pack functional tests are in a ciGroup" -node x-pack/scripts/functional_tests --assert-none-excluded \ - --include-tag ciGroup1 \ - --include-tag ciGroup2 \ - --include-tag ciGroup3 \ - --include-tag ciGroup4 \ - --include-tag ciGroup5 \ - --include-tag ciGroup6 \ - --include-tag ciGroup7 \ - --include-tag ciGroup8 \ - --include-tag ciGroup9 \ - --include-tag ciGroup10 \ - --include-tag ciGroup11 \ - --include-tag ciGroup12 \ - --include-tag ciGroup13 \ - --include-tag ciGroupDocker - -echo " -> building and extracting default Kibana distributable for use in functional tests" -node scripts/build --debug --no-oss +echo " -> building and extracting OSS Kibana distributable for use in functional tests" +node scripts/build --debug --oss echo " -> shipping metrics from build to ci-stats" node scripts/ship_ci_stats \ --metrics target/optimizer_bundle_metrics.json \ --metrics packages/kbn-ui-shared-deps/target/metrics.json -linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" -installDir="$KIBANA_DIR/install/kibana" -mkdir -p "$installDir" -tar -xzf "$linuxBuild" -C "$installDir" --strip=1 -cp "$linuxBuild" "$WORKSPACE/kibana-default.tar.gz" - -mkdir -p "$WORKSPACE/kibana-build" -cp -pR install/kibana/. $WORKSPACE/kibana-build/ - -echo " -> Archive built plugins" -shopt -s globstar -tar -zcf \ - "$WORKSPACE/kibana-default-plugins.tar.gz" \ - x-pack/plugins/**/target/public \ - x-pack/test/**/target/public \ - examples/**/target/public \ - x-pack/examples/**/target/public \ - test/**/target/public -shopt -u globstar \ No newline at end of file +mkdir -p "$WORKSPACE/kibana-build-oss" +cp -pR build/oss/kibana-*-SNAPSHOT-linux-x86_64/. $WORKSPACE/kibana-build-oss/ diff --git a/test/scripts/jenkins_build_load_testing.sh b/test/scripts/jenkins_build_load_testing.sh index 5447b9e7c3092..659321f1d3975 100755 --- a/test/scripts/jenkins_build_load_testing.sh +++ b/test/scripts/jenkins_build_load_testing.sh @@ -26,8 +26,8 @@ installDir="$KIBANA_DIR/install/kibana" mkdir -p "$installDir" tar -xzf "$linuxBuild" -C "$installDir" --strip=1 -mkdir -p "$WORKSPACE/kibana-build" -cp -pR install/kibana/. $WORKSPACE/kibana-build/ +mkdir -p "$WORKSPACE/kibana-build-xpack" +cp -pR install/kibana/. $WORKSPACE/kibana-build-xpack/ echo " -> test setup" source test/scripts/jenkins_test_setup_xpack.sh diff --git a/test/scripts/jenkins_build_plugins.sh b/test/scripts/jenkins_build_plugins.sh index 7e102e67bb8e0..a3d77ed968169 100755 --- a/test/scripts/jenkins_build_plugins.sh +++ b/test/scripts/jenkins_build_plugins.sh @@ -4,18 +4,9 @@ source src/dev/ci_setup/setup_env.sh echo " -> building kibana platform plugins" node scripts/build_kibana_platform_plugins \ + --oss \ --scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \ --scan-dir "$KIBANA_DIR/test/interpreter_functional/plugins" \ --scan-dir "$KIBANA_DIR/examples" \ - --scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \ - --scan-dir "$KIBANA_DIR/test/common/fixtures/plugins" \ - --scan-dir "$XPACK_DIR/test/plugin_functional/plugins" \ - --scan-dir "$XPACK_DIR/test/functional_with_es_ssl/fixtures/plugins" \ - --scan-dir "$XPACK_DIR/test/alerting_api_integration/plugins" \ - --scan-dir "$XPACK_DIR/test/plugin_api_integration/plugins" \ - --scan-dir "$XPACK_DIR/test/plugin_api_perf/plugins" \ - --scan-dir "$XPACK_DIR/test/licensing_plugin/plugins" \ - --scan-dir "$XPACK_DIR/test/usage_collection/plugins" \ - --scan-dir "$XPACK_DIR/test/security_functional/fixtures/common" \ - --scan-dir "$XPACK_DIR/examples" \ - --workers 12 + --workers 6 \ + --verbose diff --git a/test/scripts/jenkins_test_setup_oss.sh b/test/scripts/jenkins_test_setup_oss.sh index 29d396667c465..53626ce89462a 100755 --- a/test/scripts/jenkins_test_setup_oss.sh +++ b/test/scripts/jenkins_test_setup_oss.sh @@ -3,11 +3,11 @@ source test/scripts/jenkins_test_setup.sh if [[ -z "$CODE_COVERAGE" ]]; then - destDir="$WORKSPACE/kibana-build-${TASK_QUEUE_PROCESS_ID:-$CI_PARALLEL_PROCESS_NUMBER}" + destDir="$WORKSPACE/kibana-build-oss-${TASK_QUEUE_PROCESS_ID:-$CI_PARALLEL_PROCESS_NUMBER}" if [[ ! -d $destDir ]]; then mkdir -p $destDir - cp -pR "$WORKSPACE/kibana-build/." $destDir/ + cp -pR "$WORKSPACE/kibana-build-oss/." $destDir/ fi export KIBANA_INSTALL_DIR="$destDir" diff --git a/test/scripts/jenkins_test_setup_xpack.sh b/test/scripts/jenkins_test_setup_xpack.sh index 31acc4f4865e2..b9227fd8ff416 100755 --- a/test/scripts/jenkins_test_setup_xpack.sh +++ b/test/scripts/jenkins_test_setup_xpack.sh @@ -3,11 +3,11 @@ source test/scripts/jenkins_test_setup.sh if [[ -z "$CODE_COVERAGE" ]]; then - destDir="$WORKSPACE/kibana-build-${TASK_QUEUE_PROCESS_ID:-$CI_PARALLEL_PROCESS_NUMBER}" + destDir="$WORKSPACE/kibana-build-xpack-${TASK_QUEUE_PROCESS_ID:-$CI_PARALLEL_PROCESS_NUMBER}" if [[ ! -d $destDir ]]; then mkdir -p $destDir - cp -pR "$WORKSPACE/kibana-build/." $destDir/ + cp -pR "$WORKSPACE/kibana-build-xpack/." $destDir/ fi export KIBANA_INSTALL_DIR="$(realpath $destDir)" diff --git a/test/scripts/jenkins_xpack_baseline.sh b/test/scripts/jenkins_xpack_baseline.sh index 93363687b39a9..2755a6e0a705d 100755 --- a/test/scripts/jenkins_xpack_baseline.sh +++ b/test/scripts/jenkins_xpack_baseline.sh @@ -17,8 +17,8 @@ installDir="$KIBANA_DIR/install/kibana" mkdir -p "$installDir" tar -xzf "$linuxBuild" -C "$installDir" --strip=1 -mkdir -p "$WORKSPACE/kibana-build" -cp -pR install/kibana/. $WORKSPACE/kibana-build/ +mkdir -p "$WORKSPACE/kibana-build-xpack" +cp -pR install/kibana/. $WORKSPACE/kibana-build-xpack/ cd "$KIBANA_DIR" source "test/scripts/jenkins_xpack_saved_objects_field_metrics.sh" diff --git a/test/scripts/jenkins_xpack_build_kibana.sh b/test/scripts/jenkins_xpack_build_kibana.sh new file mode 100755 index 0000000000000..8cdeb2a04a362 --- /dev/null +++ b/test/scripts/jenkins_xpack_build_kibana.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +cd "$KIBANA_DIR" +source src/dev/ci_setup/setup_env.sh + +if [[ ! "$TASK_QUEUE_PROCESS_ID" ]]; then + ./test/scripts/jenkins_xpack_build_plugins.sh +fi + +# doesn't persist, also set in kibanaPipeline.groovy +export KBN_NP_PLUGINS_BUILT=true + +echo " -> Ensuring all functional tests are in a ciGroup" +cd "$XPACK_DIR" +node scripts/functional_tests --assert-none-excluded \ + --include-tag ciGroup1 \ + --include-tag ciGroup2 \ + --include-tag ciGroup3 \ + --include-tag ciGroup4 \ + --include-tag ciGroup5 \ + --include-tag ciGroup6 \ + --include-tag ciGroup7 \ + --include-tag ciGroup8 \ + --include-tag ciGroup9 \ + --include-tag ciGroup10 \ + --include-tag ciGroup11 \ + --include-tag ciGroup12 \ + --include-tag ciGroup13 \ + --include-tag ciGroupDocker + +echo " -> building and extracting default Kibana distributable for use in functional tests" +cd "$KIBANA_DIR" +node scripts/build --debug --no-oss + +echo " -> shipping metrics from build to ci-stats" +node scripts/ship_ci_stats \ + --metrics target/optimizer_bundle_metrics.json \ + --metrics packages/kbn-ui-shared-deps/target/metrics.json + +linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" +installDir="$KIBANA_DIR/install/kibana" +mkdir -p "$installDir" +tar -xzf "$linuxBuild" -C "$installDir" --strip=1 + +mkdir -p "$WORKSPACE/kibana-build-xpack" +cp -pR install/kibana/. $WORKSPACE/kibana-build-xpack/ +cp "$linuxBuild" "$WORKSPACE/kibana-default.tar.gz" + +mkdir -p "$WORKSPACE/kibana-build-xpack" +cp -pR install/kibana/. $WORKSPACE/kibana-build-xpack/ + +echo " -> Archive built plugins" +shopt -s globstar +tar -zcf \ + "$WORKSPACE/kibana-default-plugins.tar.gz" \ + x-pack/plugins/**/target/public \ + x-pack/test/**/target/public \ + examples/**/target/public \ + x-pack/examples/**/target/public \ + test/**/target/public +shopt -u globstar diff --git a/test/server_integration/http/ssl_redirect/index.js b/test/server_integration/http/ssl_redirect/index.js index 8abe700e26149..bcd1b6f25ea51 100644 --- a/test/server_integration/http/ssl_redirect/index.js +++ b/test/server_integration/http/ssl_redirect/index.js @@ -17,7 +17,7 @@ export default function ({ getService }) { await supertest.get('/').expect('location', url).expect(302); - await supertest.get('/').redirects(1).expect('location', '/spaces/enter').expect(302); + await supertest.get('/').redirects(1).expect('location', '/app/home').expect(302); }); }); } diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index 4cd9308e810aa..65e2945ea4464 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -286,23 +286,33 @@ def doSetup() { } } +def buildOss(maxWorkers = '') { + notifyOnError { + withEnv(["KBN_OPTIMIZER_MAX_WORKERS=${maxWorkers}"]) { + runbld("./test/scripts/jenkins_build_kibana.sh", "Build OSS/Default Kibana") + } + } +} + def getBuildArtifactBucket() { def dir = env.ghprbPullId ? "pr-${env.ghprbPullId}" : buildState.get('checkoutInfo').branch.replace("/", "__") return "gs://ci-artifacts.kibana.dev/default-build/${dir}/${buildState.get('checkoutInfo').commit}" } -def buildKibana(maxWorkers = '') { +def buildXpack(maxWorkers = '', uploadArtifacts = false) { notifyOnError { withEnv(["KBN_OPTIMIZER_MAX_WORKERS=${maxWorkers}"]) { - runbld("./test/scripts/jenkins_build_kibana.sh", "Build Kibana") + runbld("./test/scripts/jenkins_xpack_build_kibana.sh", "Build X-Pack Kibana") } - withGcpServiceAccount.fromVaultSecret('secret/kibana-issues/dev/ci-artifacts-key', 'value') { - bash(""" - cd "${env.WORKSPACE}" - gsutil -q -m cp 'kibana-default.tar.gz' '${getBuildArtifactBucket()}/' - gsutil -q -m cp 'kibana-default-plugins.tar.gz' '${getBuildArtifactBucket()}/' - """, "Upload Default Build artifacts to GCS") + if (uploadArtifacts) { + withGcpServiceAccount.fromVaultSecret('secret/kibana-issues/dev/ci-artifacts-key', 'value') { + bash(""" + cd "${env.WORKSPACE}" + gsutil -q -m cp 'kibana-default.tar.gz' '${getBuildArtifactBucket()}/' + gsutil -q -m cp 'kibana-default-plugins.tar.gz' '${getBuildArtifactBucket()}/' + """, "Upload Default Build artifacts to GCS") + } } } } @@ -416,10 +426,14 @@ def withDocker(Closure closure) { ) } -def buildPlugins() { +def buildOssPlugins() { runbld('./test/scripts/jenkins_build_plugins.sh', 'Build OSS Plugins') } +def buildXpackPlugins() { + runbld('./test/scripts/jenkins_xpack_build_plugins.sh', 'Build X-Pack Plugins') +} + def withTasks(Map params = [:], Closure closure) { catchErrors { def config = [setupWork: {}, worker: [:], parallel: 24] + params @@ -435,7 +449,8 @@ def withTasks(Map params = [:], Closure closure) { }, // There are integration tests etc that require the plugins to be built first, so let's go ahead and build them before set up the parallel workspaces - plugins: { buildPlugins() }, + ossPlugins: { buildOssPlugins() }, + xpackPlugins: { buildXpackPlugins() }, ]) config.setupWork() @@ -455,11 +470,8 @@ def allCiTasks() { tasks.check() tasks.lint() tasks.test() - task { - buildKibana(16) - tasks.functionalOss() - tasks.functionalXpack() - } + tasks.functionalOss() + tasks.functionalXpack() tasks.storybooksCi() } }, diff --git a/vars/tasks.groovy b/vars/tasks.groovy index e6ab3eaf92afd..9a60512436c2d 100644 --- a/vars/tasks.groovy +++ b/vars/tasks.groovy @@ -54,8 +54,8 @@ def xpackCiGroupDocker() { kibanaPipeline.downloadDefaultBuildArtifacts() kibanaPipeline.bash(""" cd '${env.WORKSPACE}' - mkdir -p kibana-build - tar -xzf kibana-default.tar.gz -C kibana-build --strip=1 + mkdir -p kibana-build-xpack + tar -xzf kibana-default.tar.gz -C kibana-build-xpack --strip=1 tar -xzf kibana-default-plugins.tar.gz -C kibana """, "Extract Default Build artifacts") kibanaPipeline.xpackCiGroupProcess('Docker', true)() @@ -74,6 +74,8 @@ def functionalOss(Map params = [:]) { ] task { + kibanaPipeline.buildOss(6) + if (config.ciGroups) { ossCiGroups() } @@ -112,6 +114,8 @@ def functionalXpack(Map params = [:]) { ] task { + kibanaPipeline.buildXpack(10, true) + if (config.ciGroups) { xpackCiGroups() xpackCiGroupDocker() diff --git a/x-pack/test/api_integration/apis/kibana/kql_telemetry/kql_telemetry.js b/x-pack/test/api_integration/apis/kibana/kql_telemetry/kql_telemetry.js index 95a65de81e85b..d22018615c404 100644 --- a/x-pack/test/api_integration/apis/kibana/kql_telemetry/kql_telemetry.js +++ b/x-pack/test/api_integration/apis/kibana/kql_telemetry/kql_telemetry.js @@ -10,8 +10,12 @@ import expect from '@kbn/expect'; export default function ({ getService }) { const supertestNoAuth = getService('supertestWithoutAuth'); const supertest = getService('supertest'); + const esArchiver = getService('esArchiver'); describe('telemetry API', () => { + before(() => esArchiver.load('x-pack/test/functional/es_archives/empty_kibana')); + after(() => esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana')); + describe('no auth', () => { it('should return 401', async () => { return supertestNoAuth