mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[functional testing] Add explicit index names to config, rename mapping to indexDefinition
This commit is contained in:
parent
db8f7cdf22
commit
7cef3240d8
5 changed files with 32 additions and 16 deletions
2
test/fixtures/__tests__/scenarioManager.js
vendored
2
test/fixtures/__tests__/scenarioManager.js
vendored
|
@ -8,6 +8,8 @@ describe('scenario manager', function () {
|
|||
var manager = new ScenarioManager('http://localhost:9200');
|
||||
|
||||
describe('loading and unloading', function () {
|
||||
this.timeout(60000);
|
||||
|
||||
var bulk;
|
||||
var create;
|
||||
var indicesDelete;
|
||||
|
|
20
test/fixtures/config.js
vendored
20
test/fixtures/config.js
vendored
|
@ -3,12 +3,22 @@ var rootDir = path.join(__dirname, 'scenarios');
|
|||
|
||||
module.exports = {
|
||||
makelogs: {
|
||||
base: path.join(rootDir, 'makelogs'),
|
||||
mapping: 'mapping',
|
||||
bulk: ['logstash-2015.09.17', 'logstash-2015.09.18']
|
||||
baseDir: path.join(rootDir, 'makelogs'),
|
||||
bulk: [{
|
||||
indexDefinition: 'makelogsIndexDefinition.js',
|
||||
indexName: 'logstash-2015.09.17',
|
||||
source: 'logstash-2015.09.17.js'
|
||||
}, {
|
||||
indexDefinition: 'makelogsIndexDefinition.js',
|
||||
indexName: 'logstash-2015.09.18',
|
||||
source: 'logstash-2015.09.18.js'
|
||||
}]
|
||||
},
|
||||
emptyKibana: {
|
||||
base: path.join(rootDir, 'emptyKibana'),
|
||||
bulk: ['.kibana']
|
||||
baseDir: path.join(rootDir, 'emptyKibana'),
|
||||
bulk: [{
|
||||
indexName: '.kibana',
|
||||
source: 'kibana.js'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
|
26
test/fixtures/scenarioManager.js
vendored
26
test/fixtures/scenarioManager.js
vendored
|
@ -20,21 +20,21 @@ ScenarioManager.prototype.load = function (id) {
|
|||
if (!scenario) throw new Error('No scenario found for ' + id);
|
||||
|
||||
var self = this;
|
||||
return Promise.all(scenario.bulk.map(function bulk(file) {
|
||||
var mapping;
|
||||
return Promise.all(scenario.bulk.map(function mapBulk(bulk) {
|
||||
var loadIndexDefinition;
|
||||
|
||||
if (scenario.mapping) {
|
||||
mapping = self.client.indices.create({
|
||||
index: file,
|
||||
body: require(path.join(scenario.base, scenario.mapping))
|
||||
if (bulk.indexDefinition) {
|
||||
loadIndexDefinition = self.client.indices.create({
|
||||
index: bulk.indexName,
|
||||
body: require(path.join(scenario.baseDir, bulk.indexDefinition))
|
||||
});
|
||||
} else {
|
||||
mapping = Promise.resolve();
|
||||
loadIndexDefinition = Promise.resolve();
|
||||
}
|
||||
|
||||
return mapping.then(function () {
|
||||
return loadIndexDefinition.then(function bulkRequest() {
|
||||
self.client.bulk({
|
||||
body: require(path.join(scenario.base, file)),
|
||||
body: require(path.join(scenario.baseDir, bulk.source)),
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -50,8 +50,12 @@ ScenarioManager.prototype.unload = function (id) {
|
|||
var scenario = config[id];
|
||||
if (!scenario) throw new Error('Expected index');
|
||||
|
||||
var indices = scenario.bulk.map(function mapBulk(bulk) {
|
||||
return bulk.indexName;
|
||||
});
|
||||
|
||||
return this.client.indices.delete({
|
||||
index: scenario.bulk
|
||||
index: indices
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -63,7 +67,7 @@ ScenarioManager.prototype.unload = function (id) {
|
|||
ScenarioManager.prototype.reload = function (id) {
|
||||
var self = this;
|
||||
|
||||
return this.unload(id).then(function () {
|
||||
return this.unload(id).then(function load() {
|
||||
return self.load(id);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue