[ftr/remote] delay chrome restarts, limit attempts (#118945) (#118979)

Co-authored-by: Spencer <email@spalger.com>
This commit is contained in:
Kibana Machine 2021-11-17 21:09:01 -05:00 committed by GitHub
parent d7546941ee
commit 3d8906ad58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,7 @@ import { resolve } from 'path';
import Fs from 'fs';
import * as Rx from 'rxjs';
import { mergeMap, map, takeUntil, catchError } from 'rxjs/operators';
import { mergeMap, map, takeUntil, catchError, ignoreElements } from 'rxjs/operators';
import { Lifecycle } from '@kbn/test';
import { ToolingLog } from '@kbn/dev-utils';
import chromeDriver from 'chromedriver';
@ -53,6 +53,8 @@ const chromiumUserPrefs = {
},
};
const sleep$ = (ms: number) => Rx.timer(ms).pipe(ignoreElements());
/**
* Best we can tell WebDriver locks up sometimes when we send too many
* commands at once, sometimes... It causes random lockups where we never
@ -331,6 +333,7 @@ export async function initWebDriver(
edgePaths = await installDriver();
}
let attempt = 1;
return await Rx.race(
Rx.timer(2 * MINUTE).pipe(
map(() => {
@ -355,8 +358,14 @@ export async function initWebDriver(
catchError((error, resubscribe) => {
log.warning('Failure while creating webdriver instance');
log.warning(error);
log.warning('...retrying...');
return resubscribe;
if (attempt > 5) {
throw new Error('out of retry attempts');
}
attempt += 1;
log.warning('...retrying in 15 seconds...');
return Rx.concat(sleep$(15000), resubscribe);
})
)
).toPromise();