mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Beginning work on integration tests for new ingest simulate API
This commit is contained in:
parent
d2098090d6
commit
fb7804431d
5 changed files with 71 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
|||
import Joi from 'joi';
|
||||
|
||||
export default Joi.object({
|
||||
processorId: Joi.string().required(),
|
||||
typeId: Joi.string().required()
|
||||
}).unknown();
|
|
@ -0,0 +1,7 @@
|
|||
import Joi from 'joi';
|
||||
import ingestProcessorSchema from './resources/ingest_processor_schema';
|
||||
|
||||
export default Joi.object({
|
||||
processors: Joi.array().items(ingestProcessorSchema).required().min(1),
|
||||
input: Joi.object().required()
|
||||
});
|
|
@ -1,11 +1,17 @@
|
|||
const _ = require('lodash');
|
||||
import { buildRequest, processResponse } from '../../../lib/ingest_simulate';
|
||||
import processorTypes from '../../../../common/ingest_processor_types';
|
||||
import simulateRequestSchema from '../../../lib/schemas/simulate_request_schema';
|
||||
|
||||
module.exports = function registerSimulate(server) {
|
||||
server.route({
|
||||
path: '/api/kibana/ingest/simulate',
|
||||
method: 'POST',
|
||||
config: {
|
||||
validate: {
|
||||
payload: simulateRequestSchema
|
||||
}
|
||||
},
|
||||
handler: function (request, reply) {
|
||||
const client = server.plugins.elasticsearch.client;
|
||||
const pipeline = request.payload;
|
||||
|
|
50
test/unit/api/ingest/_simulate.js
Normal file
50
test/unit/api/ingest/_simulate.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
define(function (require) {
|
||||
var Promise = require('bluebird');
|
||||
var createTestData = require('intern/dojo/node!../../../unit/api/ingest/data');
|
||||
var _ = require('intern/dojo/node!lodash');
|
||||
var expect = require('intern/dojo/node!expect.js');
|
||||
|
||||
const testPipeline = {
|
||||
processors: [{
|
||||
processorId: 'processor1',
|
||||
typeId: 'set',
|
||||
targetField: 'foo',
|
||||
value: 'bar'
|
||||
}],
|
||||
input: {}
|
||||
};
|
||||
|
||||
return function (bdd, scenarioManager, request) {
|
||||
bdd.describe('simulate', function simulatePipeline() {
|
||||
|
||||
bdd.it('should return 400 for an invalid payload', function invalidPayload() {
|
||||
|
||||
return Promise.all([
|
||||
request.post('/kibana/ingest/simulate').expect(400),
|
||||
|
||||
request.post('/kibana/ingest/simulate')
|
||||
.send({})
|
||||
.expect(400),
|
||||
|
||||
// requires at least one processor
|
||||
request.post('/kibana/ingest/simulate')
|
||||
.send({input: {}, processors: []})
|
||||
.expect(400),
|
||||
|
||||
// All processors must have a processorId property and a typeId property
|
||||
request.post('/kibana/ingest/simulate')
|
||||
.send({input: {}, processors: [{}]})
|
||||
.expect(400)
|
||||
]);
|
||||
});
|
||||
|
||||
bdd.it('should return 200 for a successful run', function () {
|
||||
return request.post('/kibana/ingest/simulate')
|
||||
.send(testPipeline)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
// test for 400 when required fields for particular processor are missing, in separate files for each processor type
|
||||
});
|
||||
};
|
||||
});
|
|
@ -8,6 +8,7 @@ define(function (require) {
|
|||
var expect = require('intern/dojo/node!expect.js');
|
||||
var post = require('./_post');
|
||||
var del = require('./_del');
|
||||
var simulate = require('./_simulate');
|
||||
|
||||
bdd.describe('ingest API', function () {
|
||||
var scenarioManager = new ScenarioManager(url.format(serverConfig.servers.elasticsearch));
|
||||
|
@ -23,5 +24,6 @@ define(function (require) {
|
|||
|
||||
post(bdd, scenarioManager, request);
|
||||
del(bdd, scenarioManager, request);
|
||||
simulate(bdd, scenarioManager, request);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue