forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kbn-ftr-common-functional-services] extend retry service (elastic#17…
…8660) ## Summary I took the retry wrapper created by [jpdjere](https://github.com/jpdjere) in elastic#173998 and extended `retryForSuccess<T>` with required capabilities to provide the same functionality. This PR: 1) extends retry service with new function `tryWithRetries<T> => : Promise<T>` to retry block `options.retryCount` times within `options.timeout` period and return block result ```ts const response = await retry.tryWithRetries<SearchResponse>( 'search request', async () => { const response = await supertest .post(`/internal/search/es`) .set(ELASTIC_HTTP_VERSION_HEADER, '1') .send({ params: { body: { query: { match_all: {}, }, }, }, }) .expect(200); return response.body as SearchResponse; }, { retryCount: 4, retryDelay: 100, // optional timeout: 30000, // optional } ``` 2) removes `utils/retry.ts` wrapper and migrate tests to FTR Retry service 3) Adds descriptions to Retry service functions explaining the default use case How the failures look like: - when reached timeout before retry count limit ``` Error: retry.tryWithRetries reached timeout 11000 ms waiting for 'run console request' Error: expected '# Click the Variables button, above, to create your own variables.\nGET ${exampleVariable1} // _search\n{\n "query": {\n "${exampleVariable2}": {} // match_all\n }\n}' to sort of equal '5' at Assertion.assert (expect.js:100:11) at Assertion.eql (expect.js:244:8) at _console.ts:47:41 at processTicksAndRejections (node:internal/process/task_queues:95:5) at runAttempt (retry_with_retries.ts:29:15) at retryWithRetries (retry_with_retries.ts:97:21) at RetryService.tryForTime (retry.ts:38:12) at Context.<anonymous> (_console.ts:44:7) at Object.apply (wrap_function.js:73:16) ``` - when reached retry count limit before timeout ``` Error: retry.tryWithRetries reached the limit of attempts waiting for 'run console request': 2 out of 2 Error: expected '# Click the Variables button, above, to create your own variables.\nGET ${exampleVariable1} // _search\n{\n "query": {\n "${exampleVariable2}": {} // match_all\n }\n}' to sort of equal '5' at Assertion.assert (expect.js:100:11) at Assertion.eql (expect.js:244:8) at _console.ts:47:41 at processTicksAndRejections (node:internal/process/task_queues:95:5) at runAttempt (retry_for_success.ts:29:15) at retryForSuccess (retry_for_success.ts:97:21) at RetryService.tryWithRetries (retry.ts:115:12) at Context.<anonymous> (_console.ts:44:7) at Object.apply (wrap_function.js:73:16) ```
- Loading branch information
1 parent
9ba0dc1
commit 277b3fb
Showing
10 changed files
with
114 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/retry.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.