mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Quick smoke test of chromium on startup for diagnosing (#28001)
This commit is contained in:
parent
9d0d0fdd48
commit
4d013c1cd0
8 changed files with 85 additions and 9 deletions
|
@ -311,7 +311,7 @@
|
|||
"@types/opn": "^5.1.0",
|
||||
"@types/podium": "^1.0.0",
|
||||
"@types/prop-types": "^15.5.3",
|
||||
"@types/puppeteer": "^1.6.2",
|
||||
"@types/puppeteer-core": "^1.9.0",
|
||||
"@types/react": "16.3.14",
|
||||
"@types/react-dom": "^16.0.5",
|
||||
"@types/react-redux": "^6.0.6",
|
||||
|
@ -319,6 +319,7 @@
|
|||
"@types/react-virtualized": "^9.18.7",
|
||||
"@types/redux": "^3.6.31",
|
||||
"@types/redux-actions": "^2.2.1",
|
||||
"@types/rimraf": "^2.0.2",
|
||||
"@types/semver": "^5.5.0",
|
||||
"@types/sinon": "^5.0.1",
|
||||
"@types/strip-ansi": "^3.0.0",
|
||||
|
|
|
@ -16,6 +16,7 @@ import { config as appConfig } from './server/config/config';
|
|||
import { checkLicenseFactory } from './server/lib/check_license';
|
||||
import { validateConfig } from './server/lib/validate_config';
|
||||
import { validateMaxContentLength } from './server/lib/validate_max_content_length';
|
||||
import { validateBrowser } from './server/lib/validate_browser';
|
||||
import { exportTypesRegistryFactory } from './server/lib/export_types_registry';
|
||||
import { PHANTOM, createBrowserDriverFactory, getDefaultBrowser, getDefaultChromiumSandboxDisabled } from './server/browsers';
|
||||
import { logConfiguration } from './log_configuration';
|
||||
|
@ -146,6 +147,7 @@ export const reporting = (kibana) => {
|
|||
|
||||
init: async function (server) {
|
||||
const exportTypesRegistry = await exportTypesRegistryFactory(server);
|
||||
const browserFactory = await createBrowserDriverFactory(server);
|
||||
server.expose('exportTypesRegistry', exportTypesRegistry);
|
||||
|
||||
const config = server.config();
|
||||
|
@ -153,6 +155,7 @@ export const reporting = (kibana) => {
|
|||
|
||||
validateConfig(config, logWarning);
|
||||
validateMaxContentLength(server, logWarning);
|
||||
validateBrowser(browserFactory, logWarning);
|
||||
logConfiguration(config, message => server.log(['reporting', 'debug'], message));
|
||||
|
||||
const { xpack_main: xpackMainPlugin } = server.plugins;
|
||||
|
@ -168,7 +171,7 @@ export const reporting = (kibana) => {
|
|||
// Register a function with server to manage the collection of usage stats
|
||||
server.usage.collectorSet.register(getReportingUsageCollector(server));
|
||||
|
||||
server.expose('browserDriverFactory', await createBrowserDriverFactory(server));
|
||||
server.expose('browserDriverFactory', browserFactory);
|
||||
server.expose('queue', createQueueFactory(server));
|
||||
|
||||
// Reporting routes
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
*/
|
||||
|
||||
export const PHANTOM = 'phantom';
|
||||
export const CHROMIUM = 'chromium';
|
||||
export const CHROMIUM = 'chromium';
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import * as Chrome from 'puppeteer';
|
||||
import * as Chrome from 'puppeteer-core';
|
||||
import { parse as parseUrl } from 'url';
|
||||
import {
|
||||
ConditionalHeaders,
|
||||
|
|
|
@ -13,6 +13,7 @@ import { map, share, mergeMap, filter, partition } from 'rxjs/operators';
|
|||
import { HeadlessChromiumDriver } from '../driver';
|
||||
import { args } from './args';
|
||||
import { safeChildProcess } from '../../safe_child_process';
|
||||
import { getChromeLogLocation } from '../paths';
|
||||
|
||||
const compactWhitespace = (str) => {
|
||||
return str.replace(/\s+/, ' ');
|
||||
|
@ -27,6 +28,33 @@ export class HeadlessChromiumDriverFactory {
|
|||
|
||||
type = 'chromium';
|
||||
|
||||
test({ viewport, browserTimezone }, log) {
|
||||
const userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'chromium-'));
|
||||
const chromiumArgs = args({
|
||||
userDataDir,
|
||||
viewport,
|
||||
verboseLogging: true,
|
||||
disableSandbox: this.browserConfig.disableSandbox,
|
||||
proxyConfig: this.browserConfig.proxy,
|
||||
});
|
||||
|
||||
return puppeteer
|
||||
.launch({
|
||||
userDataDir,
|
||||
executablePath: this.binaryPath,
|
||||
ignoreHTTPSErrors: true,
|
||||
args: chromiumArgs,
|
||||
env: {
|
||||
TZ: browserTimezone,
|
||||
},
|
||||
})
|
||||
.catch((error) => {
|
||||
log(`The Reporting plugin encountered issues launching Chromium in a self-test. You may have trouble generating reports: ${error}`);
|
||||
log(`See Chromium's log output at "${getChromeLogLocation(this.binaryPath)}"`);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
create({ viewport, browserTimezone }) {
|
||||
return Rx.Observable.create(async observer => {
|
||||
const userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'chromium-'));
|
||||
|
|
|
@ -29,3 +29,6 @@ export const paths = {
|
|||
binaryRelativePath: 'headless_shell-windows\\headless_shell.exe'
|
||||
}]
|
||||
};
|
||||
|
||||
export const getChromeLogLocation = (binaryPath) =>
|
||||
path.join(binaryPath, '..', 'chrome_debug.log');
|
||||
|
|
27
x-pack/plugins/reporting/server/lib/validate_browser.ts
Normal file
27
x-pack/plugins/reporting/server/lib/validate_browser.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import * as puppeteer from 'puppeteer-core';
|
||||
import { CHROMIUM } from '../browsers/browser_types';
|
||||
|
||||
export const validateBrowser = async (browserFactory: any, log: (message: string) => any) => {
|
||||
if (browserFactory.type === CHROMIUM) {
|
||||
return browserFactory
|
||||
.test(
|
||||
{
|
||||
viewport: {
|
||||
width: 800,
|
||||
height: 600,
|
||||
},
|
||||
},
|
||||
log
|
||||
)
|
||||
.then((browser: puppeteer.Browser | null) => {
|
||||
if (browser && browser.close) {
|
||||
browser.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
24
yarn.lock
24
yarn.lock
|
@ -1665,12 +1665,18 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.3.tgz#bef071852dca2a2dbb65fecdb7bfb30cedae2de2"
|
||||
integrity sha512-sfjHrNF4zWRv3fJUGyZW46wVxhYJ/GeWIPdKxbnLIhY3bWR0Ncl2kIhZI7rpjY9KtUQAkDP8jWEmaGQGFFvruA==
|
||||
|
||||
"@types/puppeteer@^1.6.2":
|
||||
version "1.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/puppeteer/-/puppeteer-1.6.2.tgz#9b4ba40a67abad3c729a021ffd259d929d00c5e0"
|
||||
integrity sha512-7dDV8LiOFwnvDnWhBA7KFmd/BWwP8c8ac3X7/OXst9Q5JXg0qGpmNkEKh24XOxUbtWtVUvma9ZCb6ZmVjvioJA==
|
||||
"@types/puppeteer-core@^1.9.0":
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/puppeteer-core/-/puppeteer-core-1.9.0.tgz#5ceb397e3ff769081fb07d71289b5009392d24d3"
|
||||
integrity sha512-YJwGTq0a8xZxN7/QDeW59XMdKTRNzDTc8ZVBPDB6J13GgXn1+QzgMA8pAq1/bj2FD0R7xj3nYoZra10b0HLzFw==
|
||||
dependencies:
|
||||
"@types/puppeteer" "*"
|
||||
|
||||
"@types/puppeteer@*":
|
||||
version "1.11.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/puppeteer/-/puppeteer-1.11.1.tgz#f2fe2e08917af2b4dc4b03bd2b838c05cb9d8410"
|
||||
integrity sha512-IvrvZfWjITUH7q4WrM25ul9xlIeLM3Oh+hV2FL7xQQSroVf8mX3lMZaN7XEsw6Bdfp99Qm7I4GcD+ak5+wIEfA==
|
||||
dependencies:
|
||||
"@types/events" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/react-datepicker@^1.1.5":
|
||||
|
@ -1764,6 +1770,14 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.10.2.tgz#bd1740c4ad51966609b058803ee6874577848b37"
|
||||
integrity sha512-LqJkY4VQ7S09XhI7kA3ON71AxauROhSv74639VsNXC9ish4IWHnIi98if+nP1MxQV3RMPqXSCYgpPsDHjlg9UQ==
|
||||
|
||||
"@types/rimraf@^2.0.2":
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.2.tgz#7f0fc3cf0ff0ad2a99bb723ae1764f30acaf8b6e"
|
||||
integrity sha512-Hm/bnWq0TCy7jmjeN5bKYij9vw5GrDFWME4IuxV08278NtU/VdGbzsBohcCUJ7+QMqmUq5hpRKB39HeQWJjztQ==
|
||||
dependencies:
|
||||
"@types/glob" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/semver@^5.5.0":
|
||||
version "5.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue