Skip to content

Commit

Permalink
Condensed common delete index and updateConfigDoc into one method.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeDr committed Jun 6, 2016
1 parent c392174 commit 2462b49
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 91 deletions.
8 changes: 2 additions & 6 deletions test/functional/apps/dashboard/_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 2 additions & 8 deletions test/functional/apps/discover/_collapse_expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 2 additions & 8 deletions test/functional/apps/discover/_discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 2 additions & 8 deletions test/functional/apps/discover/_field_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 2 additions & 8 deletions test/functional/apps/discover/_shared_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
7 changes: 1 addition & 6 deletions test/functional/apps/settings/_advanced_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
7 changes: 1 addition & 6 deletions test/functional/apps/settings/_creation_form_changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
7 changes: 1 addition & 6 deletions test/functional/apps/settings/_index_pattern_popularity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
7 changes: 1 addition & 6 deletions test/functional/apps/settings/_index_pattern_results_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{
Expand Down
7 changes: 1 addition & 6 deletions test/functional/apps/settings/_initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
11 changes: 1 addition & 10 deletions test/functional/apps/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
8 changes: 2 additions & 6 deletions test/functional/apps/visualize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
29 changes: 28 additions & 1 deletion test/support/es_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;
Expand Down

0 comments on commit 2462b49

Please sign in to comment.