[Migrations - v2] Allow for 1 byte size variation in es_response_too_large (#161626)

## Summary

Fixes https://github.com/elastic/kibana/issues/160994

There must be some randomness factor that causes the response payload
size to have a 1 byte size variation, as observed in the
`es_response_too_large` error.

This PR relaxes the constraint and accepts a `es_response_too_large`
error with either 3184 or 3185 bytes.
This commit is contained in:
Gerard Soldevila 2023-07-12 13:38:37 +02:00 committed by GitHub
parent 90b7b1a3c8
commit 5d5c10a320
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1117,8 +1117,7 @@ describe('migration actions', () => {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/160994
describe.skip('readWithPit', () => {
describe('readWithPit', () => {
it('requests documents from an index using given PIT', async () => {
const openPitTask = openPit({ client, index: 'existing_index_with_docs' });
const pitResponse = (await openPitTask()) as Either.Right<OpenPitResponse>;
@ -1297,7 +1296,12 @@ describe('migration actions', () => {
const leftResponse = (await readWithPitTask()) as Either.Left<EsResponseTooLargeError>;
expect(leftResponse.left.type).toBe('es_response_too_large');
expect(leftResponse.left.contentLength).toBe(3184);
// ES response contains a field that indicates how long it took ES to get the response, e.g.: "took": 7
// if ES takes more than 9ms, the payload will be 1 byte bigger.
// see https://github.com/elastic/kibana/issues/160994
// Thus, the statements below account for response times up to 99ms
expect(leftResponse.left.contentLength).toBeGreaterThanOrEqual(3184);
expect(leftResponse.left.contentLength).toBeLessThanOrEqual(3185);
});
it('rejects if PIT does not exist', async () => {