-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[add data] ability to disable processors #7065
Changes from 2 commits
a9048e7
b2f30f9
93ea5ed
f0e99c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import processESIngestProcessorsResponse from '../process_es_ingest_processors_response'; | ||
import expect from 'expect.js'; | ||
import _ from 'lodash'; | ||
|
||
describe('processESIngestSimulateResponse', function () { | ||
|
||
it('should return a list of strings indicating the enabled processors', function () { | ||
const response = { | ||
nodes: { | ||
node_foo: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' }, | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const expected = [ 'proc_foo', 'proc_bar' ]; | ||
const actual = processESIngestProcessorsResponse(response); | ||
|
||
expect(actual).to.eql(expected); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still prefer to always use lodash to get deep and strict equality checking |
||
}); | ||
|
||
it('should return a unique list of processors', function () { | ||
const response = { | ||
nodes: { | ||
node_foo: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' }, | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
}, | ||
node_bar: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' }, | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const expected = [ 'proc_foo', 'proc_bar' ]; | ||
const actual = processESIngestProcessorsResponse(response); | ||
|
||
expect(actual).to.eql(expected); | ||
}); | ||
|
||
it('should combine the available processors from all nodes', function () { | ||
const response = { | ||
nodes: { | ||
node_foo: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' } | ||
] | ||
} | ||
}, | ||
node_bar: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const expected = [ 'proc_foo', 'proc_bar' ]; | ||
const actual = processESIngestProcessorsResponse(response); | ||
|
||
expect(actual).to.eql(expected); | ||
}); | ||
|
||
it('should return an empty array for unexpected response', function () { | ||
expect(processESIngestProcessorsResponse({ nodes: {}})).to.eql([]); | ||
expect(processESIngestProcessorsResponse({})).to.eql([]); | ||
expect(processESIngestProcessorsResponse(undefined)).to.eql([]); | ||
expect(processESIngestProcessorsResponse(null)).to.eql([]); | ||
expect(processESIngestProcessorsResponse('')).to.eql([]); | ||
expect(processESIngestProcessorsResponse(1)).to.eql([]); | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const _ = require('lodash'); | ||
|
||
export default function processESIngestProcessorsResponse(response) { | ||
const nodes = _.get(response, 'nodes'); | ||
|
||
const results = _.chain(nodes) | ||
.map('ingest.processors') | ||
.reduce((result, processors) => { | ||
return result.concat(processors); | ||
}) | ||
.map('type') | ||
.unique() | ||
.value(); | ||
|
||
return results; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { registerPost } from './register_post'; | ||
import { registerDelete } from './register_delete'; | ||
import { registerProcessors } from './register_processors'; | ||
import { registerSimulate } from './register_simulate'; | ||
|
||
export default function (server) { | ||
registerPost(server); | ||
registerDelete(server); | ||
registerProcessors(server); | ||
registerSimulate(server); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import _ from 'lodash'; | ||
import handleESError from '../../../lib/handle_es_error'; | ||
import handleResponse from '../../../lib/process_es_ingest_processors_response'; | ||
import { keysToCamelCaseShallow, keysToSnakeCaseShallow } from '../../../../common/lib/case_conversion'; | ||
|
||
export function registerProcessors(server) { | ||
server.route({ | ||
path: '/api/kibana/ingest/processors', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're establishing a bad pattern here with simulate and now this. This url could conflict with the ingest config endpoints (which will eventually support GET) if the user creates an index called We either need to come up with different urls for this endpoint and simulate, or we should move the existing ingest API endpoints to something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per our discussion, I agree that we can resolve this potential conflict by putting those urls under the |
||
method: 'GET', | ||
handler: function (request, reply) { | ||
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, request); | ||
|
||
return boundCallWithRequest('transport.request', { | ||
path: '/_nodes/ingest', | ||
method: 'GET' | ||
}) | ||
.then(handleResponse) | ||
.then(reply) | ||
.catch((error) => { | ||
reply(handleESError(error)); | ||
}); | ||
} | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
define(function (require) { | ||
var Promise = require('bluebird'); | ||
var _ = require('intern/dojo/node!lodash'); | ||
var expect = require('intern/dojo/node!expect.js'); | ||
|
||
return function (bdd, scenarioManager, request) { | ||
bdd.describe('processors', () => { | ||
|
||
bdd.it('should return 200 for a successful run', function () { | ||
return request.get('/kibana/ingest/processors') | ||
.expect(200) | ||
.then((response) => { | ||
expect(_.isArray(response.body)).to.be(true); | ||
}); | ||
}); | ||
|
||
}); | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to catch errors here and display a notification if there's a problem, otherwise the user gets an empty processor list and no explanation why.