[add data] removed dirtyProcessor logic.

This commit is contained in:
Jim Unger 2016-04-06 16:43:20 -05:00
parent ea71928f72
commit 4317045ff4
9 changed files with 15 additions and 40 deletions

View file

@ -24,7 +24,7 @@ app.directive('processorUiGsub', function () {
}
function processorUiChanged() {
pipeline.setDirty(processor);
pipeline.setDirty();
}
$scope.$watch('processor.inputObject', consumeNewInputObject);

View file

@ -13,7 +13,7 @@ app.directive('processorUiSet', function () {
const pipeline = $scope.pipeline;
function processorUiChanged() {
pipeline.setDirty(processor);
pipeline.setDirty();
}
$scope.$watch('processor.targetField', processorUiChanged);

View file

@ -22,7 +22,7 @@ describe('processor pipeline', function () {
it('should only contain the clean data properties', function () {
const pipeline = new Pipeline();
const actual = pipeline.model;
const expectedKeys = [ 'input', 'processors', 'dirtyProcessorId' ];
const expectedKeys = [ 'input', 'processors' ];
expect(_.keys(actual)).to.eql(expectedKeys);
});
@ -36,25 +36,7 @@ describe('processor pipeline', function () {
const actual = pipeline.model;
const expected = {
input: pipeline.input,
processors: [ pipeline.processors[0].model ],
dirtyProcessorId: undefined
};
expect(actual).to.eql(expected);
});
it('should have the dirtyProcessorId set to whichever processor was modified last', function () {
const pipeline = new Pipeline();
pipeline.input = { foo: 'bar' };
pipeline.add(TestProcessor);
pipeline.setDirty(pipeline.processors[0]);
pipeline.processors[0].model = { bar: 'baz' };
const actual = pipeline.model;
const expected = {
input: pipeline.input,
processors: [ pipeline.processors[0].model ],
dirtyProcessorId: pipeline.processors[0].processorId
processors: [ pipeline.processors[0].model ]
};
expect(actual).to.eql(expected);

View file

@ -59,21 +59,18 @@ export default class Pipeline {
this.output = undefined;
this.dirty = false;
this.hasCompileError = false;
this.dirtyProcessor = undefined;
}
get model() {
const pipeline = {
input: this.input,
processors: _.map(this.processors, processor => processor.model),
dirtyProcessorId: _.get(this.dirtyProcessor, 'processorId')
processors: _.map(this.processors, processor => processor.model)
};
return pipeline;
}
setDirty(processor) {
setDirty() {
this.dirty = true;
this.dirtyProcessor = processor;
}
load(pipeline) {

View file

@ -5,13 +5,12 @@ import _ from 'lodash';
describe('processESIngestSimulateError', function () {
it('result will be returned for processor that threw the error', function () {
const dirtyProcessorId = 'processor1';
const error = _.set({}, 'body.error.reason', 'foobar');
const expected = [
{ processorId: 'processor1', error: { compile: true, message: 'foobar' } }
];
const actual = processESIngestSimulateError(dirtyProcessorId, error);
const actual = processESIngestSimulateError(error);
expect(_.isEqual(actual, expected)).to.be.ok();
});

View file

@ -1,9 +1,6 @@
const _ = require('lodash');
function buildError(error) {
const processorId = _.get(error, 'body.error.root_cause[0].header.processor_tag');
if (!processorId) throw error;
const errorMessage = _.get(error, 'body.error.root_cause[0].reason');
return {
compile: true,
@ -11,10 +8,13 @@ function buildError(error) {
};
}
export default function processESIngestSimulateError(dirtyProcessorId, error) {
export default function processESIngestSimulateError(error) {
const processorId = _.get(error, 'body.error.root_cause[0].header.processor_tag');
if (!processorId) throw error;
const results = [
{
processorId: dirtyProcessorId,
processorId: processorId,
error: buildError(error)
}
];

View file

@ -4,6 +4,5 @@ import _ from 'lodash';
export default Joi.object({
processors: Joi.array().items(_.values(ingestProcessorSchemas)).required().min(1),
input: Joi.object().required(),
dirty_processor_id: Joi.string()
input: Joi.object().required()
});

View file

@ -1,7 +1,7 @@
import _ from 'lodash';
import handleESError from '../../../lib/handle_es_error';
import handleResponse from '../../../lib/process_es_ingest_simulate_response';
import processESIngestSimulateError from '../../../lib/process_es_ingest_simulate_error';
import handleError from '../../../lib/process_es_ingest_simulate_error';
import simulateRequestSchema from '../../../lib/schemas/simulate_request_schema';
import ingestSimulateApiKibanaToEsConverter from '../../../lib/converters/ingest_simulate_api_kibana_to_es_converter';
import { keysToCamelCaseShallow, keysToSnakeCaseShallow } from '../../../../common/lib/case_conversion';
@ -19,7 +19,6 @@ export function registerSimulate(server) {
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, request);
const simulateApiDocument = request.payload;
const body = ingestSimulateApiKibanaToEsConverter(simulateApiDocument);
const handleError = _.partial(processESIngestSimulateError, simulateApiDocument.dirty_processor_id);
return boundCallWithRequest('transport.request', {
path: '_ingest/pipeline/_simulate',

View file

@ -75,8 +75,7 @@ define(function (require) {
target_field: 'bar',
value: 'baz'
}
],
dirty_processor_id: 'processor2'
]
};
bdd.it('should return a 200 for a compile error caused by a processor', function () {