Skip to content

Commit e38d1d9

Browse files
authored
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
1 parent ec69a02 commit e38d1d9

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/core_plugins/timelion/server/series_functions/__tests__/es.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ describe(filename, () => {
181181
expect(request.index).to.equal('beer');
182182
});
183183

184+
it('sets the timeout on the request', () => {
185+
config.index = 'beer';
186+
const request = fn(config, tlConfig, emptyScriptedFields);
187+
188+
expect(request.timeout).to.equal('30000ms');
189+
});
190+
184191
it('always sets body.size to 0', () => {
185192
const request = fn(config, tlConfig, emptyScriptedFields);
186193

src/core_plugins/timelion/server/series_functions/__tests__/fixtures/tlConfig.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ export default function () {
4040
}
4141
})
4242
}
43+
},
44+
config: () => {
45+
return {
46+
get: (key) => {
47+
switch (key) {
48+
case 'elasticsearch.shardTimeout':
49+
return 30000;
50+
default:
51+
throw new Error(`unexpected config ${key}`);
52+
}
53+
}
54+
};
4355
}
4456
};
4557

src/core_plugins/timelion/server/series_functions/es/lib/build_request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ export default function buildRequest(config, tlConfig, scriptedFields) {
6666

6767
_.assign(aggCursor, createDateAgg(config, tlConfig, scriptedFields));
6868

69-
7069
return {
7170
index: config.index,
71+
timeout: tlConfig.server.config().get('elasticsearch.shardTimeout') + 'ms',
7272
body: {
7373
query: {
7474
bool: bool

0 commit comments

Comments
 (0)