[Reporting] fix too_long_frame_exception by passing scroll_id in the request body (#102972)

* pass scroll_id in the request body not a param

* update test to match

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tim Sullivan 2021-06-30 12:20:33 -07:00 committed by GitHub
parent 0673aab33d
commit 50c755df0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View file

@ -324,6 +324,23 @@ it('uses the scrollId to page all the data', async () => {
const csvResult = await generateCsv.generateData();
expect(csvResult.warnings).toEqual([]);
expect(csvResult.content).toMatchSnapshot();
expect(mockDataClient.search).toHaveBeenCalledTimes(1);
expect(mockDataClient.search).toBeCalledWith(
{ params: { scroll: '30s', size: 500 } },
{ strategy: 'es' }
);
// `scroll` and `clearScroll` must be called with scroll ID in the post body!
expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledTimes(9);
expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledWith({
body: { scroll: '30s', scroll_id: 'awesome-scroll-hero' },
});
expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledTimes(1);
expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledWith({
body: { scroll_id: ['awesome-scroll-hero'] },
});
});
describe('fields from job.searchSource.getFields() (7.12 generated)', () => {

View file

@ -102,8 +102,10 @@ export class CsvGenerator {
this.logger.debug(`executing scroll request`);
const results = (
await this.clients.es.asCurrentUser.scroll({
scroll: scrollSettings.duration,
scroll_id: scrollId,
body: {
scroll: scrollSettings.duration,
scroll_id: scrollId,
},
})
).body as SearchResponse<unknown>;
return results;
@ -387,7 +389,7 @@ export class CsvGenerator {
if (scrollId) {
this.logger.debug(`executing clearScroll request`);
try {
await this.clients.es.asCurrentUser.clearScroll({ scroll_id: [scrollId] });
await this.clients.es.asCurrentUser.clearScroll({ body: { scroll_id: [scrollId] } });
} catch (err) {
this.logger.error(err);
}