mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.12`: - [[ftr] abort retry on invalid webdriver session (#174092)](https://github.com/elastic/kibana/pull/174092) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2024-01-02T21:01:26Z","message":"[ftr] abort retry on invalid webdriver session (#174092)\n\n## Summary\r\n\r\nSince many our e2e tests use Retry service, we might have a situation\r\nwith retry running for some time (**20,30, 120 seconds** ) before\r\nreaching timeout while browser already crashed and Webdriver is not\r\nfunctioning properly.\r\n\r\nThis PR updates Retry service with checking error name before retry\r\nattempt: if it is the WebDriver critical error, retry is aborted and we\r\nfail test fast.\r\n\r\nIt should help with long useless logging messages as well:\r\n\r\nBefore:\r\n\r\n```\r\n │ debg --- retry.try error: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ debg Find.findByCssSelector('[data-test-subj=\"canvasExpressionInput\"]') with timeout=10000\r\n │ debg --- retry.try failed again with the same message...\r\n │ debg Find.findByCssSelector('[data-test-subj=\"canvasExpressionInput\"]') with timeout=10000\r\n │ debg --- retry.try failed again with the same message...\r\n ...\r\n │ERROR Browser is closed, no artifacts were captured for the failure\r\n └- ✖ fail: Canvas Canvas app expression editor shows autocomplete when typing\r\n │ retry.try timeout: NoSuchWindowError: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ at Object.throwDecodedError (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/error.js:524:15)\r\n │ at parseHttpResponse (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/http.js:601:13)\r\n │ at Executor.execute (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/http.js:529:28)\r\n │ at processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n │ at Task.exec (prevent_parallel_calls.ts:28:20)\r\n │ Error: retry.try timeout: NoSuchWindowError: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)\r\n │ at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)\r\n │ at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)\r\n │ at processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n │ at Task.exec (prevent_parallel_calls.ts:28:20)\r\n │ at onFailure (retry_for_success.ts:17:9)\r\n │ at retryForSuccess (retry_for_success.ts:59:13)\r\n │ at RetryService.try (retry.ts:31:12)\r\n │ at Proxy.clickByCssSelector (find.ts:417:5)\r\n │ at TestSubjects.click (test_subjects.ts:164:5)\r\n │ at Context.<anonymous> (expression.ts:92:7)\r\n │ at Object.apply (wrap_function.js:73:16)\r\n │\r\n │\r\n └-> \"after all\" hook for \"shows autocomplete when typing\"\r\n │ debg unloading docs from archive at /Users/dmle/github/kibana/x-pack/test/functional/fixtures/kbn_archiver/canvas/default.json\r\n │ info deleting 1 objects { space: undefined }\r\n │ succ 1 saved objects deleted\r\n └-> \"after all\" hook: afterTestSuite.trigger for \"shows autocomplete when typing\"\r\n │ERROR Browser window is already closed\r\n``` \r\n\r\nAfter:\r\n\r\n```\r\n │ debg --- retry.try error: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ERROR Browser is closed, no artifacts were captured for the failure\r\n └- ✖ fail: Canvas Canvas app expression editor shows autocomplete when typing\r\n │ Error: WebDriver session is invalid, retry was aborted\r\n │ at retryForSuccess (retry_for_success.ts:64:13)\r\n │ at RetryService.try (retry.ts:31:12)\r\n │ at MonacoEditorService.getCodeEditorValue (monaco_editor.ts:25:5)\r\n │ at Context.<anonymous> (expression.ts:83:34)\r\n │ at Object.apply (wrap_function.js:73:16)\r\n │\r\n │\r\n └-> \"after all\" hook for \"shows autocomplete when typing\"\r\n │ debg unloading docs from archive at /Users/dmle/github/kibana/x-pack/test/functional/fixtures/kbn_archiver/canvas/default.json\r\n │ info deleting 1 objects { space: undefined }\r\n │ succ 1 saved objects deleted\r\n └-> \"after all\" hook: afterTestSuite.trigger for \"shows autocomplete when typing\"\r\n │ERROR Browser window is already closed\r\n └-> \"after all\" hook in \"Canvas app\"\r\n │ debg set roles = superuser\r\n │ debg creating user test_user\r\n │ debg created user test_user\r\n └-> \"after all\" hook: afterTestSuite.trigger in \"Canvas app\"\r\n │ERROR Browser window is already closed\r\n └-> \"after all\" hook: afterTestSuite.trigger in \"Canvas\"\r\n │ERROR Browser window is already closed\r\n\r\n5 passing (17.0s)\r\n1 failing\r\n\r\n1) Canvas\r\n Canvas app\r\n expression editor\r\n shows autocomplete when typing:\r\n\r\n Error: WebDriver session is invalid, retry was aborted\r\n at retryForSuccess (retry_for_success.ts:64:13)\r\n at RetryService.try (retry.ts:31:12)\r\n at MonacoEditorService.getCodeEditorValue (monaco_editor.ts:25:5)\r\n at Context.<anonymous> (expression.ts:83:34)\r\n at Object.apply (wrap_function.js:73:16)\r\n\r\n\r\n```","sha":"f9a4962b4802a520bd7ab3788138cd1c75e7de3a","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.12.1","v8.13.0"],"title":"[ftr] abort retry on invalid webdriver session","number":174092,"url":"https://github.com/elastic/kibana/pull/174092","mergeCommit":{"message":"[ftr] abort retry on invalid webdriver session (#174092)\n\n## Summary\r\n\r\nSince many our e2e tests use Retry service, we might have a situation\r\nwith retry running for some time (**20,30, 120 seconds** ) before\r\nreaching timeout while browser already crashed and Webdriver is not\r\nfunctioning properly.\r\n\r\nThis PR updates Retry service with checking error name before retry\r\nattempt: if it is the WebDriver critical error, retry is aborted and we\r\nfail test fast.\r\n\r\nIt should help with long useless logging messages as well:\r\n\r\nBefore:\r\n\r\n```\r\n │ debg --- retry.try error: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ debg Find.findByCssSelector('[data-test-subj=\"canvasExpressionInput\"]') with timeout=10000\r\n │ debg --- retry.try failed again with the same message...\r\n │ debg Find.findByCssSelector('[data-test-subj=\"canvasExpressionInput\"]') with timeout=10000\r\n │ debg --- retry.try failed again with the same message...\r\n ...\r\n │ERROR Browser is closed, no artifacts were captured for the failure\r\n └- ✖ fail: Canvas Canvas app expression editor shows autocomplete when typing\r\n │ retry.try timeout: NoSuchWindowError: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ at Object.throwDecodedError (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/error.js:524:15)\r\n │ at parseHttpResponse (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/http.js:601:13)\r\n │ at Executor.execute (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/http.js:529:28)\r\n │ at processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n │ at Task.exec (prevent_parallel_calls.ts:28:20)\r\n │ Error: retry.try timeout: NoSuchWindowError: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)\r\n │ at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)\r\n │ at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)\r\n │ at processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n │ at Task.exec (prevent_parallel_calls.ts:28:20)\r\n │ at onFailure (retry_for_success.ts:17:9)\r\n │ at retryForSuccess (retry_for_success.ts:59:13)\r\n │ at RetryService.try (retry.ts:31:12)\r\n │ at Proxy.clickByCssSelector (find.ts:417:5)\r\n │ at TestSubjects.click (test_subjects.ts:164:5)\r\n │ at Context.<anonymous> (expression.ts:92:7)\r\n │ at Object.apply (wrap_function.js:73:16)\r\n │\r\n │\r\n └-> \"after all\" hook for \"shows autocomplete when typing\"\r\n │ debg unloading docs from archive at /Users/dmle/github/kibana/x-pack/test/functional/fixtures/kbn_archiver/canvas/default.json\r\n │ info deleting 1 objects { space: undefined }\r\n │ succ 1 saved objects deleted\r\n └-> \"after all\" hook: afterTestSuite.trigger for \"shows autocomplete when typing\"\r\n │ERROR Browser window is already closed\r\n``` \r\n\r\nAfter:\r\n\r\n```\r\n │ debg --- retry.try error: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ERROR Browser is closed, no artifacts were captured for the failure\r\n └- ✖ fail: Canvas Canvas app expression editor shows autocomplete when typing\r\n │ Error: WebDriver session is invalid, retry was aborted\r\n │ at retryForSuccess (retry_for_success.ts:64:13)\r\n │ at RetryService.try (retry.ts:31:12)\r\n │ at MonacoEditorService.getCodeEditorValue (monaco_editor.ts:25:5)\r\n │ at Context.<anonymous> (expression.ts:83:34)\r\n │ at Object.apply (wrap_function.js:73:16)\r\n │\r\n │\r\n └-> \"after all\" hook for \"shows autocomplete when typing\"\r\n │ debg unloading docs from archive at /Users/dmle/github/kibana/x-pack/test/functional/fixtures/kbn_archiver/canvas/default.json\r\n │ info deleting 1 objects { space: undefined }\r\n │ succ 1 saved objects deleted\r\n └-> \"after all\" hook: afterTestSuite.trigger for \"shows autocomplete when typing\"\r\n │ERROR Browser window is already closed\r\n └-> \"after all\" hook in \"Canvas app\"\r\n │ debg set roles = superuser\r\n │ debg creating user test_user\r\n │ debg created user test_user\r\n └-> \"after all\" hook: afterTestSuite.trigger in \"Canvas app\"\r\n │ERROR Browser window is already closed\r\n └-> \"after all\" hook: afterTestSuite.trigger in \"Canvas\"\r\n │ERROR Browser window is already closed\r\n\r\n5 passing (17.0s)\r\n1 failing\r\n\r\n1) Canvas\r\n Canvas app\r\n expression editor\r\n shows autocomplete when typing:\r\n\r\n Error: WebDriver session is invalid, retry was aborted\r\n at retryForSuccess (retry_for_success.ts:64:13)\r\n at RetryService.try (retry.ts:31:12)\r\n at MonacoEditorService.getCodeEditorValue (monaco_editor.ts:25:5)\r\n at Context.<anonymous> (expression.ts:83:34)\r\n at Object.apply (wrap_function.js:73:16)\r\n\r\n\r\n```","sha":"f9a4962b4802a520bd7ab3788138cd1c75e7de3a"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/174092","number":174092,"mergeCommit":{"message":"[ftr] abort retry on invalid webdriver session (#174092)\n\n## Summary\r\n\r\nSince many our e2e tests use Retry service, we might have a situation\r\nwith retry running for some time (**20,30, 120 seconds** ) before\r\nreaching timeout while browser already crashed and Webdriver is not\r\nfunctioning properly.\r\n\r\nThis PR updates Retry service with checking error name before retry\r\nattempt: if it is the WebDriver critical error, retry is aborted and we\r\nfail test fast.\r\n\r\nIt should help with long useless logging messages as well:\r\n\r\nBefore:\r\n\r\n```\r\n │ debg --- retry.try error: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ debg Find.findByCssSelector('[data-test-subj=\"canvasExpressionInput\"]') with timeout=10000\r\n │ debg --- retry.try failed again with the same message...\r\n │ debg Find.findByCssSelector('[data-test-subj=\"canvasExpressionInput\"]') with timeout=10000\r\n │ debg --- retry.try failed again with the same message...\r\n ...\r\n │ERROR Browser is closed, no artifacts were captured for the failure\r\n └- ✖ fail: Canvas Canvas app expression editor shows autocomplete when typing\r\n │ retry.try timeout: NoSuchWindowError: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ at Object.throwDecodedError (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/error.js:524:15)\r\n │ at parseHttpResponse (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/http.js:601:13)\r\n │ at Executor.execute (/Users/dmle/github/kibana/node_modules/selenium-webdriver/lib/http.js:529:28)\r\n │ at processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n │ at Task.exec (prevent_parallel_calls.ts:28:20)\r\n │ Error: retry.try timeout: NoSuchWindowError: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)\r\n │ at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)\r\n │ at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)\r\n │ at processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n │ at Task.exec (prevent_parallel_calls.ts:28:20)\r\n │ at onFailure (retry_for_success.ts:17:9)\r\n │ at retryForSuccess (retry_for_success.ts:59:13)\r\n │ at RetryService.try (retry.ts:31:12)\r\n │ at Proxy.clickByCssSelector (find.ts:417:5)\r\n │ at TestSubjects.click (test_subjects.ts:164:5)\r\n │ at Context.<anonymous> (expression.ts:92:7)\r\n │ at Object.apply (wrap_function.js:73:16)\r\n │\r\n │\r\n └-> \"after all\" hook for \"shows autocomplete when typing\"\r\n │ debg unloading docs from archive at /Users/dmle/github/kibana/x-pack/test/functional/fixtures/kbn_archiver/canvas/default.json\r\n │ info deleting 1 objects { space: undefined }\r\n │ succ 1 saved objects deleted\r\n └-> \"after all\" hook: afterTestSuite.trigger for \"shows autocomplete when typing\"\r\n │ERROR Browser window is already closed\r\n``` \r\n\r\nAfter:\r\n\r\n```\r\n │ debg --- retry.try error: no such window: target window already closed\r\n │ from unknown error: web view not found\r\n │ (Session info: chrome=120.0.6099.129)\r\n │ERROR Browser is closed, no artifacts were captured for the failure\r\n └- ✖ fail: Canvas Canvas app expression editor shows autocomplete when typing\r\n │ Error: WebDriver session is invalid, retry was aborted\r\n │ at retryForSuccess (retry_for_success.ts:64:13)\r\n │ at RetryService.try (retry.ts:31:12)\r\n │ at MonacoEditorService.getCodeEditorValue (monaco_editor.ts:25:5)\r\n │ at Context.<anonymous> (expression.ts:83:34)\r\n │ at Object.apply (wrap_function.js:73:16)\r\n │\r\n │\r\n └-> \"after all\" hook for \"shows autocomplete when typing\"\r\n │ debg unloading docs from archive at /Users/dmle/github/kibana/x-pack/test/functional/fixtures/kbn_archiver/canvas/default.json\r\n │ info deleting 1 objects { space: undefined }\r\n │ succ 1 saved objects deleted\r\n └-> \"after all\" hook: afterTestSuite.trigger for \"shows autocomplete when typing\"\r\n │ERROR Browser window is already closed\r\n └-> \"after all\" hook in \"Canvas app\"\r\n │ debg set roles = superuser\r\n │ debg creating user test_user\r\n │ debg created user test_user\r\n └-> \"after all\" hook: afterTestSuite.trigger in \"Canvas app\"\r\n │ERROR Browser window is already closed\r\n └-> \"after all\" hook: afterTestSuite.trigger in \"Canvas\"\r\n │ERROR Browser window is already closed\r\n\r\n5 passing (17.0s)\r\n1 failing\r\n\r\n1) Canvas\r\n Canvas app\r\n expression editor\r\n shows autocomplete when typing:\r\n\r\n Error: WebDriver session is invalid, retry was aborted\r\n at retryForSuccess (retry_for_success.ts:64:13)\r\n at RetryService.try (retry.ts:31:12)\r\n at MonacoEditorService.getCodeEditorValue (monaco_editor.ts:25:5)\r\n at Context.<anonymous> (expression.ts:83:34)\r\n at Object.apply (wrap_function.js:73:16)\r\n\r\n\r\n```","sha":"f9a4962b4802a520bd7ab3788138cd1c75e7de3a"}}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
This commit is contained in:
parent
a8ae9fc2bf
commit
d43970c154
3 changed files with 13 additions and 2 deletions
|
@ -52,12 +52,16 @@ export async function retryForSuccess<T>(log: ToolingLog, options: Options<T>) {
|
|||
|
||||
const start = Date.now();
|
||||
const retryDelay = 502;
|
||||
const criticalWebDriverErrors = ['NoSuchSessionError', 'NoSuchWindowError'];
|
||||
let lastError;
|
||||
|
||||
while (true) {
|
||||
if (Date.now() - start > timeout) {
|
||||
await onFailure(lastError);
|
||||
throw new Error('expected onFailure() option to throw an error');
|
||||
} else if (lastError && criticalWebDriverErrors.includes(lastError.name)) {
|
||||
// Aborting retry since WebDriver session is invalid or browser window is closed
|
||||
throw new Error('WebDriver session is invalid, retry was aborted');
|
||||
} else if (lastError && onFailureBlock) {
|
||||
const before = await runAttempt(onFailureBlock);
|
||||
if ('error' in before) {
|
||||
|
|
|
@ -61,7 +61,10 @@ export class TestUser extends FtrService {
|
|||
});
|
||||
|
||||
if (this.browser && this.testSubjects && !options?.skipBrowserRefresh) {
|
||||
if (await this.testSubjects.exists('kibanaChrome', { allowHidden: true })) {
|
||||
if (
|
||||
(await this.browser.hasOpenWindow()) &&
|
||||
(await this.testSubjects.exists('kibanaChrome', { allowHidden: true }))
|
||||
) {
|
||||
await this.browser.refresh();
|
||||
// accept alert if it pops up
|
||||
const alert = await this.browser.getAlert();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { NoSuchSessionError } from 'selenium-webdriver/lib/error';
|
||||
import { NoSuchSessionError, NoSuchWindowError } from 'selenium-webdriver/lib/error';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import { initWebDriver, BrowserConfig } from './webdriver';
|
||||
import { Browsers } from './browsers';
|
||||
|
@ -37,6 +37,10 @@ export async function RemoteProvider({ getService }: FtrProviderContext) {
|
|||
// Avoid duplicating NoSuchSessionError error output on each hook
|
||||
// https://developer.mozilla.org/en-US/docs/Web/WebDriver/Errors/InvalidSessionID
|
||||
log.error('WebDriver session is no longer valid');
|
||||
} else if (error instanceof NoSuchWindowError) {
|
||||
// Avoid duplicating NoSuchWindowError error output on each hook
|
||||
// https://developer.mozilla.org/en-US/docs/Web/WebDriver/Errors
|
||||
log.error('Browser window is already closed');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue