From b80083be0ef00321e781521bba8a0011e503bfb9 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Mon, 30 Aug 2021 10:36:53 +0100 Subject: [PATCH 1/8] [Archive Migration][Partial] discover apps-management Comes from https://github.com/elastic/kibana/pull/102827 Helps with https://github.com/elastic/kibana/pull/108503 Only include the changes under the test/functional/apps/management folder. --- .../apps/management/_field_formatter.ts | 3 ++- .../apps/management/_handle_version_conflict.js | 8 ++++++-- .../management/_mgmt_import_saved_objects.js | 16 +++++++++------- .../apps/management/_runtime_fields.js | 4 ++-- .../apps/management/_scripted_fields.js | 9 +++------ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/test/functional/apps/management/_field_formatter.ts b/test/functional/apps/management/_field_formatter.ts index 65b1f4d324fb1..ecaa96ef18d70 100644 --- a/test/functional/apps/management/_field_formatter.ts +++ b/test/functional/apps/management/_field_formatter.ts @@ -32,11 +32,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test_field_formatters', 'test_logstash_reader', ]); - await esArchiver.load('test/functional/fixtures/es_archiver/discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace({}); }); after(async function afterAll() { + await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); await PageObjects.settings.navigateTo(); await esArchiver.emptyKibanaIndex(); }); diff --git a/test/functional/apps/management/_handle_version_conflict.js b/test/functional/apps/management/_handle_version_conflict.js index 82723ad7ce967..f73489a5185b5 100644 --- a/test/functional/apps/management/_handle_version_conflict.js +++ b/test/functional/apps/management/_handle_version_conflict.js @@ -19,7 +19,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const testSubjects = getService('testSubjects'); - const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); const es = getService('es'); const retry = getService('retry'); @@ -30,7 +30,11 @@ export default function ({ getService, getPageObjects }) { describe('index version conflict', function describeIndexTests() { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('test/functional/fixtures/es_archiver/discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); + }); + + after(async () => { + await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); }); it('Should be able to surface version conflict notification while creating scripted field', async function () { diff --git a/test/functional/apps/management/_mgmt_import_saved_objects.js b/test/functional/apps/management/_mgmt_import_saved_objects.js index b7bca79a25940..31cb7146d0ac2 100644 --- a/test/functional/apps/management/_mgmt_import_saved_objects.js +++ b/test/functional/apps/management/_mgmt_import_saved_objects.js @@ -10,21 +10,23 @@ import expect from '@kbn/expect'; import path from 'path'; export default function ({ getService, getPageObjects }) { - const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects']); //in 6.4.0 bug the Saved Search conflict would be resolved and get imported but the visualization //that referenced the saved search was not imported.( https://github.com/elastic/kibana/issues/22238) describe('mgmt saved objects', function describeIndexTests() { - beforeEach(async function () { - await esArchiver.emptyKibanaIndex(); - await esArchiver.load('test/functional/fixtures/es_archiver/discover'); - await PageObjects.settings.navigateTo(); + before(async () => { + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); + }); + + after(async () => { + await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); }); - afterEach(async function () { - await esArchiver.unload('test/functional/fixtures/es_archiver/discover'); + beforeEach(async function () { + await PageObjects.settings.navigateTo(); }); it('should import saved objects mgmt', async function () { diff --git a/test/functional/apps/management/_runtime_fields.js b/test/functional/apps/management/_runtime_fields.js index 745a3f9b079a4..14bd8f37d7551 100644 --- a/test/functional/apps/management/_runtime_fields.js +++ b/test/functional/apps/management/_runtime_fields.js @@ -9,7 +9,6 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const log = getService('log'); const browser = getService('browser'); @@ -23,13 +22,14 @@ export default function ({ getService, getPageObjects }) { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('test/functional/fixtures/es_archiver/discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({}); }); after(async function afterAll() { + await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); await PageObjects.settings.navigateTo(); await PageObjects.settings.clickKibanaIndexPatterns(); await PageObjects.settings.removeLogstashIndexPatternIfExist(); diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 2ff9e55c59ebb..61db1bc56a973 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -25,7 +25,6 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const log = getService('log'); const browser = getService('browser'); @@ -46,16 +45,14 @@ export default function ({ getService, getPageObjects }) { before(async function () { await browser.setWindowSize(1200, 800); - await esArchiver.load('test/functional/fixtures/es_archiver/discover'); - // delete .kibana index and then wait for Kibana to re-create it + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({ 'doc_table:legacy': true }); }); after(async function afterAll() { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.removeLogstashIndexPatternIfExist(); + await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); + await kibanaServer.uiSettings.replace({}); }); it('should not allow saving of invalid scripts', async function () { From 5557fce834466f42ee841149321a312933b801f6 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 8 Sep 2021 16:27:29 +0100 Subject: [PATCH 2/8] Remove the index pattern, that the test creates. Add a sleep to see if there's a race. --- test/functional/apps/management/_index_patterns_empty.ts | 1 + test/functional/apps/management/_scripted_fields.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/management/_index_patterns_empty.ts b/test/functional/apps/management/_index_patterns_empty.ts index 038039275b843..e086a6ca18213 100644 --- a/test/functional/apps/management/_index_patterns_empty.ts +++ b/test/functional/apps/management/_index_patterns_empty.ts @@ -32,6 +32,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { path: '/logstash-a', method: 'DELETE', }); + await kibanaServer.savedObjects.clean({ types: ['index-pattern'] }); }); // create index pattern and return to verify list diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 61db1bc56a973..7de5cc5fbded7 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -122,7 +122,7 @@ export default function ({ getService, getPageObjects }) { 'painless', 'number', null, - '1', + '100', script ); await retry.try(async function () { @@ -135,6 +135,7 @@ export default function ({ getService, getPageObjects }) { it('should see scripted field value in Discover', async function () { const fromTime = 'Sep 17, 2015 @ 06:31:44.000'; const toTime = 'Sep 18, 2015 @ 18:31:44.000'; + await PageObjects.common.sleep(1000 * 10); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); From dfbd0ba09037d9de725ce98f4ab11055af3238fb Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 10 Sep 2021 13:32:28 +0100 Subject: [PATCH 3/8] Drop beforeEach() in favor of before(), since there's only one test. Add so cleanup, per CR. --- .../apps/management/_mgmt_import_saved_objects.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/functional/apps/management/_mgmt_import_saved_objects.js b/test/functional/apps/management/_mgmt_import_saved_objects.js index 31cb7146d0ac2..cf30b6f4ccf0d 100644 --- a/test/functional/apps/management/_mgmt_import_saved_objects.js +++ b/test/functional/apps/management/_mgmt_import_saved_objects.js @@ -19,14 +19,12 @@ export default function ({ getService, getPageObjects }) { describe('mgmt saved objects', function describeIndexTests() { before(async () => { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); + await PageObjects.settings.navigateTo(); }); after(async () => { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); - }); - - beforeEach(async function () { - await PageObjects.settings.navigateTo(); + await kibanaServer.savedObjects.clean({ types: ['search', 'visualization'] }); }); it('should import saved objects mgmt', async function () { From d8c10ca516af1ac6b9a9050e6cabe6d1be798a4c Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 10 Sep 2021 13:36:35 +0100 Subject: [PATCH 4/8] Drop outdated comment, drop these three cleanup lines as the unload should handle it. --- test/functional/apps/management/_runtime_fields.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/functional/apps/management/_runtime_fields.js b/test/functional/apps/management/_runtime_fields.js index 14bd8f37d7551..63a98aff3d23d 100644 --- a/test/functional/apps/management/_runtime_fields.js +++ b/test/functional/apps/management/_runtime_fields.js @@ -23,16 +23,12 @@ export default function ({ getService, getPageObjects }) { before(async function () { await browser.setWindowSize(1200, 800); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); - // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({}); }); after(async function afterAll() { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.removeLogstashIndexPatternIfExist(); }); describe('create runtime field', function describeIndexTests() { From 0344a680fc2da1254c0560616223ddaf3c5ef824 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 10 Sep 2021 13:37:38 +0100 Subject: [PATCH 5/8] Drop sleep. --- test/functional/apps/management/_scripted_fields.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 7de5cc5fbded7..4aa06f4cd9ad7 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -135,7 +135,6 @@ export default function ({ getService, getPageObjects }) { it('should see scripted field value in Discover', async function () { const fromTime = 'Sep 17, 2015 @ 06:31:44.000'; const toTime = 'Sep 18, 2015 @ 18:31:44.000'; - await PageObjects.common.sleep(1000 * 10); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); From a93a5a3a3e2c9973038feec3e1abfe8dbae2452e Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 10 Sep 2021 13:41:13 +0100 Subject: [PATCH 6/8] Drop extra cleanup. Should not need this. --- test/functional/apps/management/_field_formatter.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/apps/management/_field_formatter.ts b/test/functional/apps/management/_field_formatter.ts index ecaa96ef18d70..79ad04e00b598 100644 --- a/test/functional/apps/management/_field_formatter.ts +++ b/test/functional/apps/management/_field_formatter.ts @@ -38,8 +38,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async function afterAll() { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); - await PageObjects.settings.navigateTo(); - await esArchiver.emptyKibanaIndex(); }); describe('set and change field formatter', function describeIndexTests() { From 562216445cc0a3c47efbfe9e64b5d51ca1eb8969 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 10 Sep 2021 14:01:01 +0100 Subject: [PATCH 7/8] Just keep one cleanup. --- test/functional/apps/management/_runtime_fields.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functional/apps/management/_runtime_fields.js b/test/functional/apps/management/_runtime_fields.js index 63a98aff3d23d..09fa924b0b870 100644 --- a/test/functional/apps/management/_runtime_fields.js +++ b/test/functional/apps/management/_runtime_fields.js @@ -24,7 +24,6 @@ export default function ({ getService, getPageObjects }) { await browser.setWindowSize(1200, 800); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace({}); - await kibanaServer.uiSettings.update({}); }); after(async function afterAll() { From 6e259025739ebc650c7163c5936964988d81f368 Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Fri, 10 Sep 2021 14:49:25 +0100 Subject: [PATCH 8/8] Drop unused symbol. --- test/functional/apps/management/_field_formatter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functional/apps/management/_field_formatter.ts b/test/functional/apps/management/_field_formatter.ts index 79ad04e00b598..e070b262af9ed 100644 --- a/test/functional/apps/management/_field_formatter.ts +++ b/test/functional/apps/management/_field_formatter.ts @@ -12,7 +12,6 @@ import { FIELD_FORMAT_IDS } from '../../../../src/plugins/field_formats/common'; import { WebElementWrapper } from '../../services/lib/web_element_wrapper'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); const PageObjects = getPageObjects(['settings', 'common']);