set timeout for timelion search requests (#19711)

* set timeout for timelion search requests

* stub out server.config for mocha testing

* test timeout set

* arrow functions
This commit is contained in:
Nathan Reese 2018-06-11 18:10:00 -06:00 committed by GitHub
parent ec69a02d7e
commit e38d1d92be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -181,6 +181,13 @@ describe(filename, () => {
expect(request.index).to.equal('beer');
});
it('sets the timeout on the request', () => {
config.index = 'beer';
const request = fn(config, tlConfig, emptyScriptedFields);
expect(request.timeout).to.equal('30000ms');
});
it('always sets body.size to 0', () => {
const request = fn(config, tlConfig, emptyScriptedFields);

View file

@ -40,6 +40,18 @@ export default function () {
}
})
}
},
config: () => {
return {
get: (key) => {
switch (key) {
case 'elasticsearch.shardTimeout':
return 30000;
default:
throw new Error(`unexpected config ${key}`);
}
}
};
}
};

View file

@ -66,9 +66,9 @@ export default function buildRequest(config, tlConfig, scriptedFields) {
_.assign(aggCursor, createDateAgg(config, tlConfig, scriptedFields));
return {
index: config.index,
timeout: tlConfig.server.config().get('elasticsearch.shardTimeout') + 'ms',
body: {
query: {
bool: bool