From c39217480b78767a0a780e95790399d2ca0cef44 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Fri, 3 Jun 2016 13:49:00 -0500 Subject: [PATCH 1/2] Switch Discover and Settings tests to use esClient to wipe ,kibana --- .../apps/discover/_collapse_expand.js | 24 ++++++++------ test/functional/apps/discover/_discover.js | 24 ++++++++------ test/functional/apps/discover/_field_data.js | 26 ++++++++------- .../functional/apps/discover/_shared_links.js | 33 ++++++++++++------- .../apps/settings/_advanced_settings.js | 13 ++++++-- .../apps/settings/_creation_form_changes.js | 9 ++++- .../settings/_index_pattern_create_delete.js | 11 +++++-- .../settings/_index_pattern_popularity.js | 11 +++++-- .../settings/_index_pattern_results_sort.js | 9 ++++- .../apps/settings/_initial_state.js | 11 +++++-- test/functional/apps/settings/index.js | 12 +++++-- test/support/es_client.js | 31 +++++++++++------ 12 files changed, 148 insertions(+), 66 deletions(-) diff --git a/test/functional/apps/discover/_collapse_expand.js b/test/functional/apps/discover/_collapse_expand.js index 9630f924467d8..45ca7b51d7903 100644 --- a/test/functional/apps/discover/_collapse_expand.js +++ b/test/functional/apps/discover/_collapse_expand.js @@ -5,6 +5,8 @@ import { headerPage, scenarioManager, settingsPage, + esClient, + elasticDump } from '../../../support'; (function () { @@ -18,20 +20,22 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // start each test with an empty kibana index - return scenarioManager.reload('emptyKibana') + // delete .kibana index + return esClient.delete('.kibana') + .then(function () { + // wait for Kibana to re-create it and add UTC and defaultIndex + return common.try(function () { + return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + }); + }) + .then(function loadkibanaIndexPattern() { + common.debug('load kibana index with default index pattern'); + return elasticDump.elasticLoad('visualize','.kibana'); + }) // and load a set of makelogs data .then(function loadIfEmptyMakelogs() { return scenarioManager.loadIfEmpty('logstashFunctional'); }) - .then(function () { - common.debug('navigateTo'); - return settingsPage.navigateTo(); - }) - .then(function () { - common.debug('createIndexPattern'); - return settingsPage.createIndexPattern(); - }) .then(function () { common.debug('discover'); return common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index ec7986257ee1b..52adc928b74b3 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -5,6 +5,8 @@ import { discoverPage, settingsPage, headerPage, + esClient, + elasticDump } from '../../../support'; (function () { @@ -16,20 +18,22 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // start each test with an empty kibana index - return scenarioManager.reload('emptyKibana') + // delete .kibana index + return esClient.delete('.kibana') + .then(function () { + // wait for Kibana to re-create it and add UTC and defaultIndex + return common.try(function () { + return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + }); + }) + .then(function loadkibanaIndexPattern() { + common.debug('load kibana index with default index pattern'); + return elasticDump.elasticLoad('visualize','.kibana'); + }) // and load a set of makelogs data .then(function loadIfEmptyMakelogs() { return scenarioManager.loadIfEmpty('logstashFunctional'); }) - .then(function (navigateTo) { - common.debug('navigateTo'); - return settingsPage.navigateTo(); - }) - .then(function () { - common.debug('createIndexPattern'); - return settingsPage.createIndexPattern(); - }) .then(function () { common.debug('discover'); return common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js index 2fe40577106f1..91ccffafd1e65 100644 --- a/test/functional/apps/discover/_field_data.js +++ b/test/functional/apps/discover/_field_data.js @@ -4,7 +4,9 @@ import { discoverPage, headerPage, scenarioManager, - settingsPage + settingsPage, + esClient, + elasticDump } from '../../../support'; (function () { @@ -16,20 +18,22 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // start each test with an empty kibana index - return scenarioManager.reload('emptyKibana') + // delete .kibana index + return esClient.delete('.kibana') + .then(function () { + // wait for Kibana to re-create it and add UTC and defaultIndex + return common.try(function () { + return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + }); + }) + .then(function loadkibanaIndexPattern() { + common.debug('load kibana index with default index pattern'); + return elasticDump.elasticLoad('visualize','.kibana'); + }) // and load a set of makelogs data .then(function loadIfEmptyMakelogs() { return scenarioManager.loadIfEmpty('logstashFunctional'); }) - .then(function (navigateTo) { - common.debug('navigateTo'); - return settingsPage.navigateTo(); - }) - .then(function () { - common.debug('createIndexPattern'); - return settingsPage.createIndexPattern(); - }) .then(function () { common.debug('discover'); return common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_shared_links.js b/test/functional/apps/discover/_shared_links.js index b9f73003f042c..93839ad747da9 100644 --- a/test/functional/apps/discover/_shared_links.js +++ b/test/functional/apps/discover/_shared_links.js @@ -1,4 +1,13 @@ -import { bdd, common, discoverPage, headerPage, settingsPage, scenarioManager } from '../../../support'; +import { + bdd, + common, + discoverPage, + headerPage, + settingsPage, + scenarioManager, + esClient, + elasticDump +} from '../../../support'; (function () { var expect = require('expect.js'); @@ -18,20 +27,22 @@ import { bdd, common, discoverPage, headerPage, settingsPage, scenarioManager } var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // start each test with an empty kibana index - return scenarioManager.reload('emptyKibana') + // delete .kibana index + return esClient.delete('.kibana') + .then(function () { + // wait for Kibana to re-create it and add UTC and defaultIndex + return common.try(function () { + return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + }); + }) + .then(function loadkibanaIndexPattern() { + common.debug('load kibana index with default index pattern'); + return elasticDump.elasticLoad('visualize','.kibana'); + }) // and load a set of makelogs data .then(function loadIfEmptyMakelogs() { return scenarioManager.loadIfEmpty('logstashFunctional'); }) - .then(function (navigateTo) { - common.debug('navigateTo'); - return settingsPage.navigateTo(); - }) - .then(function () { - common.debug('createIndexPattern'); - return settingsPage.createIndexPattern(); - }) .then(function () { common.debug('discover'); return common.navigateToApp('discover'); diff --git a/test/functional/apps/settings/_advanced_settings.js b/test/functional/apps/settings/_advanced_settings.js index e04b9f4f5f360..c7f6e7ab78b00 100644 --- a/test/functional/apps/settings/_advanced_settings.js +++ b/test/functional/apps/settings/_advanced_settings.js @@ -2,7 +2,8 @@ import { bdd, common, settingsPage, - scenarioManager + scenarioManager, + esClient } from '../../../support'; (function () { @@ -11,7 +12,13 @@ import { (function () { bdd.describe('creating and deleting default index', function describeIndexTests() { bdd.before(function () { - return scenarioManager.reload('emptyKibana') + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }) .then(function () { return settingsPage.navigateTo(); }); @@ -25,7 +32,7 @@ import { bdd.it('should allow setting advanced settings', function () { return settingsPage.clickAdvancedTab() .then(function TestCallSetAdvancedSettingsForTimezone() { - common.log('calling setAdvancedSetting'); + common.debug('calling setAdvancedSetting'); return settingsPage.setAdvancedSettings('dateFormat:tz', 'America/Phoenix'); }) .then(function GetAdvancedSetting() { diff --git a/test/functional/apps/settings/_creation_form_changes.js b/test/functional/apps/settings/_creation_form_changes.js index c7cb2c939b8a6..ccabec60805d1 100644 --- a/test/functional/apps/settings/_creation_form_changes.js +++ b/test/functional/apps/settings/_creation_form_changes.js @@ -3,6 +3,7 @@ import { common, settingsPage, scenarioManager, + esClient } from '../../../support'; (function () { @@ -11,7 +12,13 @@ import { (function () { bdd.describe('user input reactions', function () { bdd.beforeEach(function () { - return scenarioManager.reload('emptyKibana') + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }) .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_index_pattern_create_delete.js b/test/functional/apps/settings/_index_pattern_create_delete.js index 3c18fd37222f2..21c39771a2539 100644 --- a/test/functional/apps/settings/_index_pattern_create_delete.js +++ b/test/functional/apps/settings/_index_pattern_create_delete.js @@ -3,7 +3,8 @@ import { common, remote, scenarioManager, - settingsPage + settingsPage, + esClient } from '../../../support'; (function () { @@ -12,7 +13,13 @@ import { (function () { bdd.describe('creating and deleting default index', function describeIndexTests() { bdd.before(function () { - return scenarioManager.reload('emptyKibana') + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }) .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_index_pattern_popularity.js b/test/functional/apps/settings/_index_pattern_popularity.js index 2d26a5641e309..b0e6479520b8e 100644 --- a/test/functional/apps/settings/_index_pattern_popularity.js +++ b/test/functional/apps/settings/_index_pattern_popularity.js @@ -2,7 +2,8 @@ import { bdd, common, scenarioManager, - settingsPage + settingsPage, + esClient } from '../../../support'; (function () { @@ -11,7 +12,13 @@ import { (function () { bdd.describe('index result popularity', function describeIndexTests() { bdd.before(function () { - return scenarioManager.reload('emptyKibana') + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }) .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_index_pattern_results_sort.js b/test/functional/apps/settings/_index_pattern_results_sort.js index 7c75ca8bfd9ba..0a7fee10f2e8b 100644 --- a/test/functional/apps/settings/_index_pattern_results_sort.js +++ b/test/functional/apps/settings/_index_pattern_results_sort.js @@ -4,6 +4,7 @@ import { defaultTimeout, settingsPage, scenarioManager, + esClient } from '../../../support'; (function () { @@ -12,7 +13,13 @@ import { (function () { bdd.describe('index result field sort', function describeIndexTests() { bdd.before(function () { - return scenarioManager.reload('emptyKibana'); + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }); }); var columns = [{ diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js index 2456ca9f87a43..99935715f1c10 100644 --- a/test/functional/apps/settings/_initial_state.js +++ b/test/functional/apps/settings/_initial_state.js @@ -2,7 +2,8 @@ import { bdd, common, scenarioManager, - settingsPage + settingsPage, + esClient } from '../../../support'; (function () { @@ -11,7 +12,13 @@ import { (function () { bdd.describe('initial state', function () { bdd.before(function () { - return scenarioManager.reload('emptyKibana') + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }) .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/index.js b/test/functional/apps/settings/index.js index c8b0c8c2ca77b..6ee725d8f5670 100644 --- a/test/functional/apps/settings/index.js +++ b/test/functional/apps/settings/index.js @@ -1,4 +1,4 @@ -import { bdd, defaultTimeout, scenarioManager } from '../../../support'; +import { bdd, defaultTimeout, scenarioManager, esClient, common } from '../../../support'; (function () { bdd.describe('settings app', function () { @@ -7,7 +7,13 @@ import { bdd, defaultTimeout, scenarioManager } from '../../../support'; // on setup, we create an settingsPage instance // that we will use for all the tests bdd.before(function () { - return scenarioManager.reload('emptyKibana') + // delete .kibana index and then wait for Kibana to re-create it + return esClient.delete('.kibana') + .then(function () { + return common.try(function () { + return esClient.getConfigId(); + }); + }) .then(function () { return scenarioManager.loadIfEmpty('makelogs'); }); @@ -16,7 +22,7 @@ import { bdd, defaultTimeout, scenarioManager } from '../../../support'; bdd.after(function () { return scenarioManager.unload('makelogs') .then(function () { - scenarioManager.unload('emptyKibana'); + return esClient.delete('.kibana'); }); }); diff --git a/test/support/es_client.js b/test/support/es_client.js index 76f486b468437..42217a72c239b 100644 --- a/test/support/es_client.js +++ b/test/support/es_client.js @@ -42,16 +42,12 @@ export default (function () { }); }, - - /** - * Add fields to the config doc (like setting timezone and defaultIndex) - * @return {Promise} A promise that is resolved when elasticsearch has a response + /* + ** Gets configId which is needed when we're going to update the config doc. + ** Also used after deleting .kibana index to know Kibana has recreated it. */ - updateConfigDoc: function (docMap) { - // first we need to get the config doc's id so we can use it in our _update call - var self = this; + getConfigId: function () { var configId; - var docMapString = JSON.stringify(docMap); return this.client.search({ index: '.kibana', @@ -70,11 +66,26 @@ export default (function () { } else { configId = response.hits.hits[0]._id; common.debug('config._id =' + configId); + return configId; } - }) + }); + }, + + + /** + * Add fields to the config doc (like setting timezone and defaultIndex) + * @return {Promise} A promise that is resolved when elasticsearch has a response + */ + updateConfigDoc: function (docMap) { + // first we need to get the config doc's id so we can use it in our _update call + var self = this; + var configId; + var docMapString = JSON.stringify(docMap); + + return this.getConfigId() // now that we have the id, we can update // return scenarioManager.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - .then(function (response) { + .then(function (configId) { common.debug('updating config with ' + docMapString); return self.client.update({ index: '.kibana', From 2462b49df1bf6981a3e1f9d520bf2b0b1a594a4f Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 6 Jun 2016 14:08:33 -0500 Subject: [PATCH 2/2] Condensed common delete index and updateConfigDoc into one method. --- test/functional/apps/dashboard/_dashboard.js | 8 ++--- .../apps/discover/_collapse_expand.js | 10 ++----- test/functional/apps/discover/_discover.js | 10 ++----- test/functional/apps/discover/_field_data.js | 10 ++----- .../functional/apps/discover/_shared_links.js | 10 ++----- .../apps/settings/_advanced_settings.js | 7 +---- .../apps/settings/_creation_form_changes.js | 7 +---- .../settings/_index_pattern_create_delete.js | 7 +---- .../settings/_index_pattern_popularity.js | 7 +---- .../settings/_index_pattern_results_sort.js | 7 +---- .../apps/settings/_initial_state.js | 7 +---- test/functional/apps/settings/index.js | 11 +------ test/functional/apps/visualize/index.js | 8 ++--- test/support/es_client.js | 29 ++++++++++++++++++- 14 files changed, 47 insertions(+), 91 deletions(-) diff --git a/test/functional/apps/dashboard/_dashboard.js b/test/functional/apps/dashboard/_dashboard.js index 8eda2713370c5..b2bf2b1466440 100644 --- a/test/functional/apps/dashboard/_dashboard.js +++ b/test/functional/apps/dashboard/_dashboard.js @@ -18,12 +18,8 @@ import { common.debug('Starting dashboard before method'); var logstash = scenarioManager.loadIfEmpty('logstashFunctional'); - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - }); - }) + // delete .kibana index and update configDoc + return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}) // and load a set of makelogs data .then(function loadkibanaVisualizations() { common.debug('load kibana index with visualizations'); diff --git a/test/functional/apps/discover/_collapse_expand.js b/test/functional/apps/discover/_collapse_expand.js index 45ca7b51d7903..864b308cddeeb 100644 --- a/test/functional/apps/discover/_collapse_expand.js +++ b/test/functional/apps/discover/_collapse_expand.js @@ -20,14 +20,8 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // delete .kibana index - return esClient.delete('.kibana') - .then(function () { - // wait for Kibana to re-create it and add UTC and defaultIndex - return common.try(function () { - return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - }); - }) + // delete .kibana index and update configDoc + return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}) .then(function loadkibanaIndexPattern() { common.debug('load kibana index with default index pattern'); return elasticDump.elasticLoad('visualize','.kibana'); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 52adc928b74b3..9227e04142148 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -18,14 +18,8 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // delete .kibana index - return esClient.delete('.kibana') - .then(function () { - // wait for Kibana to re-create it and add UTC and defaultIndex - return common.try(function () { - return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - }); - }) + // delete .kibana index and update configDoc + return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}) .then(function loadkibanaIndexPattern() { common.debug('load kibana index with default index pattern'); return elasticDump.elasticLoad('visualize','.kibana'); diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js index 91ccffafd1e65..9dd8993d6daa4 100644 --- a/test/functional/apps/discover/_field_data.js +++ b/test/functional/apps/discover/_field_data.js @@ -18,14 +18,8 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // delete .kibana index - return esClient.delete('.kibana') - .then(function () { - // wait for Kibana to re-create it and add UTC and defaultIndex - return common.try(function () { - return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - }); - }) + // delete .kibana index and update configDoc + return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}) .then(function loadkibanaIndexPattern() { common.debug('load kibana index with default index pattern'); return elasticDump.elasticLoad('visualize','.kibana'); diff --git a/test/functional/apps/discover/_shared_links.js b/test/functional/apps/discover/_shared_links.js index 93839ad747da9..5607253511943 100644 --- a/test/functional/apps/discover/_shared_links.js +++ b/test/functional/apps/discover/_shared_links.js @@ -27,14 +27,8 @@ import { var fromTime = '2015-09-19 06:31:44.000'; var toTime = '2015-09-23 18:31:44.000'; - // delete .kibana index - return esClient.delete('.kibana') - .then(function () { - // wait for Kibana to re-create it and add UTC and defaultIndex - return common.try(function () { - return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - }); - }) + // delete .kibana index and update configDoc + return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}) .then(function loadkibanaIndexPattern() { common.debug('load kibana index with default index pattern'); return elasticDump.elasticLoad('visualize','.kibana'); diff --git a/test/functional/apps/settings/_advanced_settings.js b/test/functional/apps/settings/_advanced_settings.js index c7f6e7ab78b00..3cef8d61b37e1 100644 --- a/test/functional/apps/settings/_advanced_settings.js +++ b/test/functional/apps/settings/_advanced_settings.js @@ -13,12 +13,7 @@ import { bdd.describe('creating and deleting default index', function describeIndexTests() { bdd.before(function () { // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }) + return esClient.deleteAndUpdateConfigDoc() .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_creation_form_changes.js b/test/functional/apps/settings/_creation_form_changes.js index ccabec60805d1..ffbe9db41472b 100644 --- a/test/functional/apps/settings/_creation_form_changes.js +++ b/test/functional/apps/settings/_creation_form_changes.js @@ -13,12 +13,7 @@ import { bdd.describe('user input reactions', function () { bdd.beforeEach(function () { // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }) + return esClient.deleteAndUpdateConfigDoc() .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_index_pattern_create_delete.js b/test/functional/apps/settings/_index_pattern_create_delete.js index 21c39771a2539..d6050fea15f62 100644 --- a/test/functional/apps/settings/_index_pattern_create_delete.js +++ b/test/functional/apps/settings/_index_pattern_create_delete.js @@ -14,12 +14,7 @@ import { bdd.describe('creating and deleting default index', function describeIndexTests() { bdd.before(function () { // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }) + return esClient.deleteAndUpdateConfigDoc() .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_index_pattern_popularity.js b/test/functional/apps/settings/_index_pattern_popularity.js index b0e6479520b8e..3da9830c8a5e2 100644 --- a/test/functional/apps/settings/_index_pattern_popularity.js +++ b/test/functional/apps/settings/_index_pattern_popularity.js @@ -13,12 +13,7 @@ import { bdd.describe('index result popularity', function describeIndexTests() { bdd.before(function () { // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }) + return esClient.deleteAndUpdateConfigDoc() .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/_index_pattern_results_sort.js b/test/functional/apps/settings/_index_pattern_results_sort.js index 0a7fee10f2e8b..bd69ffa0a44f8 100644 --- a/test/functional/apps/settings/_index_pattern_results_sort.js +++ b/test/functional/apps/settings/_index_pattern_results_sort.js @@ -14,12 +14,7 @@ import { bdd.describe('index result field sort', function describeIndexTests() { bdd.before(function () { // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }); + return esClient.deleteAndUpdateConfigDoc(); }); var columns = [{ diff --git a/test/functional/apps/settings/_initial_state.js b/test/functional/apps/settings/_initial_state.js index 99935715f1c10..674bf60813b92 100644 --- a/test/functional/apps/settings/_initial_state.js +++ b/test/functional/apps/settings/_initial_state.js @@ -13,12 +13,7 @@ import { bdd.describe('initial state', function () { bdd.before(function () { // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }) + return esClient.deleteAndUpdateConfigDoc() .then(function () { return settingsPage.navigateTo(); }); diff --git a/test/functional/apps/settings/index.js b/test/functional/apps/settings/index.js index 6ee725d8f5670..ad2a22785cbc3 100644 --- a/test/functional/apps/settings/index.js +++ b/test/functional/apps/settings/index.js @@ -7,16 +7,7 @@ import { bdd, defaultTimeout, scenarioManager, esClient, common } from '../../.. // on setup, we create an settingsPage instance // that we will use for all the tests bdd.before(function () { - // delete .kibana index and then wait for Kibana to re-create it - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.getConfigId(); - }); - }) - .then(function () { - return scenarioManager.loadIfEmpty('makelogs'); - }); + return scenarioManager.loadIfEmpty('makelogs'); }); bdd.after(function () { diff --git a/test/functional/apps/visualize/index.js b/test/functional/apps/visualize/index.js index e652161b8b13c..e02ce4c51f01d 100644 --- a/test/functional/apps/visualize/index.js +++ b/test/functional/apps/visualize/index.js @@ -18,12 +18,8 @@ import { common.debug('Starting visualize before method'); var logstash = scenarioManager.loadIfEmpty('logstashFunctional'); - return esClient.delete('.kibana') - .then(function () { - return common.try(function () { - return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); - }); - }) + // delete .kibana index and update configDoc + return esClient.deleteAndUpdateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}) .then(function loadkibanaIndexPattern() { common.debug('load kibana index with default index pattern'); return elasticDump.elasticLoad('visualize','.kibana'); diff --git a/test/support/es_client.js b/test/support/es_client.js index 42217a72c239b..8a3761c8e3ebc 100644 --- a/test/support/es_client.js +++ b/test/support/es_client.js @@ -84,7 +84,6 @@ export default (function () { return this.getConfigId() // now that we have the id, we can update - // return scenarioManager.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); .then(function (configId) { common.debug('updating config with ' + docMapString); return self.client.update({ @@ -100,7 +99,35 @@ export default (function () { .catch(function (err) { throw err; }); + }, + + /** + * Wrap the common 'delete index', 'updateConfigDoc' into one. + * [docMap] is optional. + * @return {Promise} A promise that is resolved when elasticsearch has a response + */ + deleteAndUpdateConfigDoc: function (docMap) { + var self = this; + var configId; + + return this.delete('.kibana') + .then(function () { + if (!docMap) { + return common.try(function () { + return self.getConfigId(); + }); + } else { + var docMapString = JSON.stringify(docMap); + return common.try(function () { + return self.updateConfigDoc(docMap); + }); + } + }) + .catch(function (err) { + throw err; + }); } + }; return EsClient;