mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
ScenarioManager load/unload always return promises
This commit is contained in:
parent
2d04ec4afa
commit
c9579d5da3
1 changed files with 8 additions and 5 deletions
13
test/fixtures/scenarioManager.js
vendored
13
test/fixtures/scenarioManager.js
vendored
|
@ -17,24 +17,27 @@ function ScenarioManager(server) {
|
|||
*/
|
||||
ScenarioManager.prototype.load = function (id) {
|
||||
var scenario = config[id];
|
||||
if (!scenario) throw new Error('No scenario found for ' + id);
|
||||
if (!scenario) return Promise.reject('No scenario found for ' + id);
|
||||
|
||||
var self = this;
|
||||
return Promise.all(scenario.bulk.map(function mapBulk(bulk) {
|
||||
var loadIndexDefinition;
|
||||
|
||||
if (bulk.indexDefinition) {
|
||||
var body = require(path.join(scenario.baseDir, bulk.indexDefinition));
|
||||
|
||||
loadIndexDefinition = self.client.indices.create({
|
||||
index: bulk.indexName,
|
||||
body: require(path.join(scenario.baseDir, bulk.indexDefinition))
|
||||
body: body
|
||||
});
|
||||
} else {
|
||||
loadIndexDefinition = Promise.resolve();
|
||||
}
|
||||
|
||||
return loadIndexDefinition.then(function bulkRequest() {
|
||||
var body = require(path.join(scenario.baseDir, bulk.source));
|
||||
|
||||
self.client.bulk({
|
||||
body: require(path.join(scenario.baseDir, bulk.source)),
|
||||
body: body
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
@ -47,7 +50,7 @@ ScenarioManager.prototype.load = function (id) {
|
|||
*/
|
||||
ScenarioManager.prototype.unload = function (id) {
|
||||
var scenario = config[id];
|
||||
if (!scenario) throw new Error('Expected index');
|
||||
if (!scenario) return Promise.reject('No scenario found for ' + id);
|
||||
|
||||
var indices = scenario.bulk.map(function mapBulk(bulk) {
|
||||
return bulk.indexName;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue