mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Only set timeout when larger 0 in timelion (#25461)
This commit is contained in:
parent
223e3dc6ee
commit
81dc79718e
3 changed files with 48 additions and 22 deletions
|
@ -173,7 +173,6 @@ describe(filename, () => {
|
|||
};
|
||||
});
|
||||
|
||||
|
||||
it('sets the index on the request', () => {
|
||||
config.index = 'beer';
|
||||
const request = fn(config, tlConfig, emptyScriptedFields);
|
||||
|
@ -181,13 +180,6 @@ 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);
|
||||
|
||||
|
@ -205,6 +197,34 @@ describe(filename, () => {
|
|||
expect(filters.bar.query_string.query).to.eql('bar');
|
||||
});
|
||||
|
||||
describe('timeouts', () => {
|
||||
|
||||
let sandbox;
|
||||
|
||||
beforeEach(() => {
|
||||
sandbox = sinon.createSandbox();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('sets the timeout on the request', () => {
|
||||
config.index = 'beer';
|
||||
const request = fn(config, tlConfig, emptyScriptedFields);
|
||||
|
||||
expect(request.timeout).to.equal('30000ms');
|
||||
});
|
||||
|
||||
it('sets no timeout if elasticsearch.shardTimeout is set to 0', () => {
|
||||
sandbox.stub(tlConfig.server.config(), 'get').withArgs('elasticsearch.shardTimeout').returns(0);
|
||||
config.index = 'beer';
|
||||
const request = fn(config, tlConfig, emptyScriptedFields);
|
||||
|
||||
expect(request).to.not.have.property('timeout');
|
||||
});
|
||||
});
|
||||
|
||||
describe('query body', () => {
|
||||
beforeEach(() => {
|
||||
tlConfig = _.merge(tlConfigFn(), {
|
||||
|
|
|
@ -24,6 +24,17 @@ import esResponse from './es_response';
|
|||
|
||||
export default function () {
|
||||
|
||||
const config = {
|
||||
get(key) {
|
||||
switch (key) {
|
||||
case 'elasticsearch.shardTimeout':
|
||||
return 30000;
|
||||
default:
|
||||
throw new Error(`unexpected config ${key}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const functions = require('../../../lib/load_functions')('series_functions');
|
||||
const server = {
|
||||
plugins: {
|
||||
|
@ -41,18 +52,7 @@ export default function () {
|
|||
})
|
||||
}
|
||||
},
|
||||
config: () => {
|
||||
return {
|
||||
get: (key) => {
|
||||
switch (key) {
|
||||
case 'elasticsearch.shardTimeout':
|
||||
return 30000;
|
||||
default:
|
||||
throw new Error(`unexpected config ${key}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
config: () => config,
|
||||
};
|
||||
|
||||
const tlConfig = require('../../../handlers/lib/tl_config.js')({
|
||||
|
|
|
@ -66,9 +66,8 @@ export default function buildRequest(config, tlConfig, scriptedFields) {
|
|||
|
||||
_.assign(aggCursor, createDateAgg(config, tlConfig, scriptedFields));
|
||||
|
||||
return {
|
||||
const request = {
|
||||
index: config.index,
|
||||
timeout: tlConfig.server.config().get('elasticsearch.shardTimeout') + 'ms',
|
||||
body: {
|
||||
query: {
|
||||
bool: bool
|
||||
|
@ -77,4 +76,11 @@ export default function buildRequest(config, tlConfig, scriptedFields) {
|
|||
size: 0
|
||||
}
|
||||
};
|
||||
|
||||
const timeout = tlConfig.server.config().get('elasticsearch.shardTimeout');
|
||||
if (timeout) {
|
||||
request.timeout = `${timeout}ms`;
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue