mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Make readWithPit integration tests less sensitive to ES response size (#180261)
## Summary Stateless ES increased their `pit_id` length from 185 to 465 chars. Our tests were quite sensitive to response sizes so these started failing. This PR makes tests less sensitive to the exact response size because I don't think it matters that much, as long as we know that `batchSize: 1` is ✅ while a `batchSize: 1000` is 🔴 . ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
773626f677
commit
c912174637
2 changed files with 17 additions and 21 deletions
|
@ -1309,11 +1309,15 @@ describe('migration actions', () => {
|
|||
query: { match_all: {} },
|
||||
batchSize: 1, // small batch size so we don't exceed the maxResponseSize
|
||||
searchAfter: undefined,
|
||||
maxResponseSizeBytes: 500, // set a small size to force the error
|
||||
maxResponseSizeBytes: 1000, // set a small size to force the error
|
||||
});
|
||||
const rightResponse = (await readWithPitTask()) as Either.Right<ReadWithPit>;
|
||||
const rightResponse = await readWithPitTask();
|
||||
|
||||
await expect(Either.isRight(rightResponse)).toBe(true);
|
||||
if (Either.isLeft(rightResponse)) {
|
||||
throw new Error(
|
||||
`Expected a successful response but got ${JSON.stringify(rightResponse.left)}`
|
||||
);
|
||||
}
|
||||
|
||||
readWithPitTask = readWithPit({
|
||||
client,
|
||||
|
@ -1321,17 +1325,12 @@ describe('migration actions', () => {
|
|||
query: { match_all: {} },
|
||||
batchSize: 10, // a bigger batch will exceed the maxResponseSize
|
||||
searchAfter: undefined,
|
||||
maxResponseSizeBytes: 500, // set a small size to force the error
|
||||
maxResponseSizeBytes: 1000, // set a small size to force the error
|
||||
});
|
||||
const leftResponse = (await readWithPitTask()) as Either.Left<EsResponseTooLargeError>;
|
||||
|
||||
expect(leftResponse.left.type).toBe('es_response_too_large');
|
||||
// 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 () => {
|
||||
|
|
|
@ -1348,9 +1348,7 @@ export const runActionTestSuite = ({
|
|||
);
|
||||
});
|
||||
|
||||
// consistently breaking in CI:
|
||||
// https://github.com/elastic/kibana/issues/167288
|
||||
it.skip('returns a left es_response_too_large error when a read batch exceeds the maxResponseSize', async () => {
|
||||
it('returns a left es_response_too_large error when a read batch exceeds the maxResponseSize', async () => {
|
||||
const openPitTask = openPit({ client, index: 'existing_index_with_docs' });
|
||||
const pitResponse = (await openPitTask()) as Either.Right<OpenPitResponse>;
|
||||
|
||||
|
@ -1360,11 +1358,15 @@ export const runActionTestSuite = ({
|
|||
query: { match_all: {} },
|
||||
batchSize: 1, // small batch size so we don't exceed the maxResponseSize
|
||||
searchAfter: undefined,
|
||||
maxResponseSizeBytes: 500, // set a small size to force the error
|
||||
maxResponseSizeBytes: 1000, // set a small size to force the error
|
||||
});
|
||||
const rightResponse = (await readWithPitTask()) as Either.Right<ReadWithPit>;
|
||||
const rightResponse = await readWithPitTask();
|
||||
|
||||
await expect(Either.isRight(rightResponse)).toBe(true);
|
||||
if (Either.isLeft(rightResponse)) {
|
||||
throw new Error(
|
||||
`Expected a successful response but got ${JSON.stringify(rightResponse.left)}`
|
||||
);
|
||||
}
|
||||
|
||||
readWithPitTask = readWithPit({
|
||||
client,
|
||||
|
@ -1372,17 +1374,12 @@ export const runActionTestSuite = ({
|
|||
query: { match_all: {} },
|
||||
batchSize: 10, // a bigger batch will exceed the maxResponseSize
|
||||
searchAfter: undefined,
|
||||
maxResponseSizeBytes: 500, // set a small size to force the error
|
||||
maxResponseSizeBytes: 1000, // set a small size to force the error
|
||||
});
|
||||
const leftResponse = (await readWithPitTask()) as Either.Left<EsResponseTooLargeError>;
|
||||
|
||||
expect(leftResponse.left.type).toBe('es_response_too_large');
|
||||
// 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 () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue