mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Merge pull request #6478 from Bargs/ingest/pipelineApiTests
Adding some API tests for pipelines in the ingest API
This commit is contained in:
commit
9620319a90
4 changed files with 40 additions and 2 deletions
|
@ -4,5 +4,5 @@ const pipelineSchema = require('./pipeline_schema');
|
|||
|
||||
module.exports = Joi.object({
|
||||
index_pattern: indexPatternSchema.required(),
|
||||
pipeline: pipelineSchema.required()
|
||||
pipeline: pipelineSchema
|
||||
});
|
||||
|
|
|
@ -67,6 +67,7 @@ module.exports = function registerPost(server) {
|
|||
const indexPattern = keysToCamelCaseShallow(requestDocument.index_pattern);
|
||||
const indexPatternId = indexPattern.id;
|
||||
const ingestConfigName = patternToIngest(indexPatternId);
|
||||
const shouldCreatePipeline = !_.isEmpty(requestDocument.pipeline);
|
||||
delete indexPattern.id;
|
||||
|
||||
const mappings = createMappingsFromPatternFields(indexPattern.fields);
|
||||
|
@ -132,7 +133,11 @@ module.exports = function registerPost(server) {
|
|||
return boundCallWithRequest('indices.putTemplate', templateParams)
|
||||
.catch((templateError) => {return patternRollback(templateError, indexPatternId, boundCallWithRequest);});
|
||||
})
|
||||
.then(() => {
|
||||
.then((templateResponse) => {
|
||||
if (!shouldCreatePipeline) {
|
||||
return templateResponse;
|
||||
}
|
||||
|
||||
return boundCallWithRequest('transport.request', pipelineParams)
|
||||
.catch((pipelineError) => {return templateRollback(pipelineError, ingestConfigName, boundCallWithRequest);})
|
||||
.catch((templateRollbackError) => {return patternRollback(templateRollbackError, indexPatternId, boundCallWithRequest);});
|
||||
|
|
|
@ -41,6 +41,15 @@ define(function (require) {
|
|||
.catch(function (error) {
|
||||
expect(error.status).to.be(404);
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
return scenarioManager.client.transport.request({
|
||||
path: '_ingest/pipeline/kibana-logstash-*',
|
||||
method: 'GET'
|
||||
})
|
||||
.catch(function (error) {
|
||||
expect(error.status).to.be(404);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -113,6 +113,30 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
bdd.it('should create a pipeline if one is included in the request', function () {
|
||||
return request.post('/kibana/ingest')
|
||||
.send(createTestData())
|
||||
.expect(204)
|
||||
.then(function () {
|
||||
return scenarioManager.client.transport.request({
|
||||
path: '_ingest/pipeline/kibana-logstash-*',
|
||||
method: 'GET'
|
||||
})
|
||||
.then(function (body) {
|
||||
expect(body.pipelines[0].id).to.be('kibana-logstash-*');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('pipeline should be optional', function optionalPipeline() {
|
||||
const payload = createTestData();
|
||||
delete payload.pipeline;
|
||||
|
||||
return request.post('/kibana/ingest')
|
||||
.send(payload)
|
||||
.expect(204);
|
||||
});
|
||||
|
||||
bdd.it('should return 409 conflict when a pattern with the given ID already exists', function patternConflict() {
|
||||
return request.post('/kibana/ingest')
|
||||
.send(createTestData())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue