mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[Screenshotting/7.17] Server package for stateless code (#190950)
Corresponds with https://github.com/elastic/kibana/pull/188390, branched from https://github.com/elastic/kibana/pull/189326 <!-- ### 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: Timothy Sullivan <tsullivan@elastic.co> Co-authored-by: Tim Sullivan <tsullivan@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
901f9c85e0
commit
07cfc46eda
13 changed files with 136 additions and 12 deletions
|
@ -144,6 +144,7 @@
|
||||||
"@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl",
|
"@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl",
|
||||||
"@kbn/monaco": "link:bazel-bin/packages/kbn-monaco",
|
"@kbn/monaco": "link:bazel-bin/packages/kbn-monaco",
|
||||||
"@kbn/rule-data-utils": "link:bazel-bin/packages/kbn-rule-data-utils",
|
"@kbn/rule-data-utils": "link:bazel-bin/packages/kbn-rule-data-utils",
|
||||||
|
"@kbn/screenshotting-server": "link:bazel-bin/packages/kbn-screenshotting-server",
|
||||||
"@kbn/securitysolution-autocomplete": "link:bazel-bin/packages/kbn-securitysolution-autocomplete",
|
"@kbn/securitysolution-autocomplete": "link:bazel-bin/packages/kbn-securitysolution-autocomplete",
|
||||||
"@kbn/securitysolution-es-utils": "link:bazel-bin/packages/kbn-securitysolution-es-utils",
|
"@kbn/securitysolution-es-utils": "link:bazel-bin/packages/kbn-securitysolution-es-utils",
|
||||||
"@kbn/securitysolution-hook-utils": "link:bazel-bin/packages/kbn-securitysolution-hook-utils",
|
"@kbn/securitysolution-hook-utils": "link:bazel-bin/packages/kbn-securitysolution-hook-utils",
|
||||||
|
|
|
@ -39,6 +39,7 @@ filegroup(
|
||||||
"//packages/kbn-plugin-generator:build",
|
"//packages/kbn-plugin-generator:build",
|
||||||
"//packages/kbn-plugin-helpers:build",
|
"//packages/kbn-plugin-helpers:build",
|
||||||
"//packages/kbn-rule-data-utils:build",
|
"//packages/kbn-rule-data-utils:build",
|
||||||
|
"//packages/kbn-screenshotting-server:build",
|
||||||
"//packages/kbn-securitysolution-autocomplete:build",
|
"//packages/kbn-securitysolution-autocomplete:build",
|
||||||
"//packages/kbn-securitysolution-list-constants:build",
|
"//packages/kbn-securitysolution-list-constants:build",
|
||||||
"//packages/kbn-securitysolution-io-ts-types:build",
|
"//packages/kbn-securitysolution-io-ts-types:build",
|
||||||
|
|
80
packages/kbn-screenshotting-server/BUILD.bazel
Normal file
80
packages/kbn-screenshotting-server/BUILD.bazel
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
|
||||||
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
|
||||||
|
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
|
||||||
|
|
||||||
|
PKG_BASE_NAME = "kbn-screenshotting-server"
|
||||||
|
PKG_REQUIRE_NAME = "@kbn/screenshotting-server"
|
||||||
|
|
||||||
|
SOURCE_FILES = glob([
|
||||||
|
"src/**/*.ts"
|
||||||
|
])
|
||||||
|
|
||||||
|
SRCS = SOURCE_FILES
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "srcs",
|
||||||
|
srcs = SRCS,
|
||||||
|
)
|
||||||
|
|
||||||
|
NPM_MODULE_EXTRA_FILES = [
|
||||||
|
"package.json",
|
||||||
|
"README.md",
|
||||||
|
]
|
||||||
|
|
||||||
|
RUNTIME_DEPS = []
|
||||||
|
|
||||||
|
TYPES_DEPS = [
|
||||||
|
"@npm//@types/node",
|
||||||
|
]
|
||||||
|
|
||||||
|
jsts_transpiler(
|
||||||
|
name = "target_node",
|
||||||
|
srcs = SRCS,
|
||||||
|
build_pkg_name = package_name(),
|
||||||
|
)
|
||||||
|
|
||||||
|
ts_config(
|
||||||
|
name = "tsconfig",
|
||||||
|
src = "tsconfig.json",
|
||||||
|
deps = [
|
||||||
|
"//:tsconfig.base.json",
|
||||||
|
"//:tsconfig.bazel.json",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
ts_project(
|
||||||
|
name = "tsc_types",
|
||||||
|
args = ['--pretty'],
|
||||||
|
srcs = SRCS,
|
||||||
|
deps = TYPES_DEPS,
|
||||||
|
declaration = True,
|
||||||
|
declaration_map = True,
|
||||||
|
emit_declaration_only = True,
|
||||||
|
out_dir = "target_types",
|
||||||
|
source_map = True,
|
||||||
|
root_dir = "src",
|
||||||
|
tsconfig = ":tsconfig",
|
||||||
|
)
|
||||||
|
|
||||||
|
js_library(
|
||||||
|
name = PKG_BASE_NAME,
|
||||||
|
srcs = NPM_MODULE_EXTRA_FILES,
|
||||||
|
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
|
||||||
|
package_name = PKG_REQUIRE_NAME,
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
pkg_npm(
|
||||||
|
name = "npm_module",
|
||||||
|
deps = [
|
||||||
|
":%s" % PKG_BASE_NAME,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "build",
|
||||||
|
srcs = [
|
||||||
|
":npm_module",
|
||||||
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
3
packages/kbn-screenshotting-server/README.md
Normal file
3
packages/kbn-screenshotting-server/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# @kbn/screenshotting-server
|
||||||
|
|
||||||
|
Stateless code pertaining to the capture of screenshots for Kibana Reporting
|
8
packages/kbn-screenshotting-server/package.json
Normal file
8
packages/kbn-screenshotting-server/package.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "@kbn/screenshotting-server",
|
||||||
|
"main": "./target_node/index.js",
|
||||||
|
"types": "./target_types/index.d.ts",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "SSPL-1.0 OR Elastic License 2.0",
|
||||||
|
"private": true
|
||||||
|
}
|
9
packages/kbn-screenshotting-server/src/index.ts
Normal file
9
packages/kbn-screenshotting-server/src/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||||
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||||
|
* Side Public License, v 1.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export { ChromiumArchivePaths, type PackageInfo } from './paths';
|
|
@ -1,8 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
* or more contributor license agreements. Licensed under the Elastic License
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||||
* 2.0.
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||||
|
* Side Public License, v 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
@ -125,10 +126,7 @@ export class ChromiumArchivePaths {
|
||||||
return BaseUrl.custom + '/' + p.archiveFilename; // revision is not used for URL if package is a custom build
|
return BaseUrl.custom + '/' + p.archiveFilename; // revision is not used for URL if package is a custom build
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBinaryPath(
|
public getBinaryPath(p: PackageInfo, chromiumPath: string) {
|
||||||
p: PackageInfo,
|
|
||||||
chromiumPath = path.resolve(__dirname, '../../../chromium')
|
|
||||||
) {
|
|
||||||
return path.join(chromiumPath, p.binaryRelativePath);
|
return path.join(chromiumPath, p.binaryRelativePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
20
packages/kbn-screenshotting-server/tsconfig.json
Normal file
20
packages/kbn-screenshotting-server/tsconfig.json
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tsconfig.bazel.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"emitDeclarationOnly": true,
|
||||||
|
"outDir": "./target_types",
|
||||||
|
"rootDir": "src",
|
||||||
|
"sourceMap": true,
|
||||||
|
"sourceRoot": "../../../../packages/kbn-screenshotting-server/src",
|
||||||
|
"stripInternal": false,
|
||||||
|
"types": [
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -11,14 +11,14 @@ import del from 'del';
|
||||||
import { mkdtempSync } from 'fs';
|
import { mkdtempSync } from 'fs';
|
||||||
import { uniq } from 'lodash';
|
import { uniq } from 'lodash';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { join } from 'path';
|
import path, { join } from 'path';
|
||||||
import { createInterface } from 'readline';
|
import { createInterface } from 'readline';
|
||||||
import { getDataPath } from '@kbn/utils';
|
import { getDataPath } from '@kbn/utils';
|
||||||
import { fromEvent, merge, of, timer } from 'rxjs';
|
import { fromEvent, merge, of, timer } from 'rxjs';
|
||||||
import { catchError, map, reduce, takeUntil, tap } from 'rxjs/operators';
|
import { catchError, map, reduce, takeUntil, tap } from 'rxjs/operators';
|
||||||
|
import { ChromiumArchivePaths } from '@kbn/screenshotting-server';
|
||||||
import { ReportingCore } from '../../../';
|
import { ReportingCore } from '../../../';
|
||||||
import { LevelLogger } from '../../../lib';
|
import { LevelLogger } from '../../../lib';
|
||||||
import { ChromiumArchivePaths } from '../paths';
|
|
||||||
import { args } from './args';
|
import { args } from './args';
|
||||||
|
|
||||||
const paths = new ChromiumArchivePaths();
|
const paths = new ChromiumArchivePaths();
|
||||||
|
@ -70,7 +70,7 @@ export const browserStartLogs = (
|
||||||
if (!pkg) {
|
if (!pkg) {
|
||||||
throw new Error(`Unsupported platform: ${platform}-${architecture}`);
|
throw new Error(`Unsupported platform: ${platform}-${architecture}`);
|
||||||
}
|
}
|
||||||
const binaryPath = paths.getBinaryPath(pkg);
|
const binaryPath = paths.getBinaryPath(pkg, path.resolve(__dirname, '../../../../chromium'));
|
||||||
|
|
||||||
const kbnArgs = args({
|
const kbnArgs = args({
|
||||||
userDataDir,
|
userDataDir,
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
|
import { ChromiumArchivePaths } from '@kbn/screenshotting-server';
|
||||||
import { BrowserDownload } from '../';
|
import { BrowserDownload } from '../';
|
||||||
import { ReportingCore } from '../../../server';
|
import { ReportingCore } from '../../../server';
|
||||||
import { LevelLogger } from '../../lib';
|
import { LevelLogger } from '../../lib';
|
||||||
import { HeadlessChromiumDriverFactory } from './driver_factory';
|
import { HeadlessChromiumDriverFactory } from './driver_factory';
|
||||||
import { ChromiumArchivePaths } from './paths';
|
|
||||||
|
|
||||||
export const chromium: BrowserDownload = {
|
export const chromium: BrowserDownload = {
|
||||||
paths: new ChromiumArchivePaths(),
|
paths: new ChromiumArchivePaths(),
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { ChromiumArchivePaths, PackageInfo } from '@kbn/screenshotting-server';
|
||||||
import { createMockLevelLogger } from '../../../test_helpers';
|
import { createMockLevelLogger } from '../../../test_helpers';
|
||||||
import { download } from '../../download/download';
|
import { download } from '../../download/download';
|
||||||
import { ChromiumArchivePaths, PackageInfo } from '../paths';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: these test cases download actual browsers. Running the suite could take
|
* NOTE: these test cases download actual browsers. Running the suite could take
|
||||||
|
|
|
@ -35,7 +35,7 @@ export function installBrowser(
|
||||||
}
|
}
|
||||||
|
|
||||||
const backgroundInstall = async () => {
|
const backgroundInstall = async () => {
|
||||||
const binaryPath = paths.getBinaryPath(pkg);
|
const binaryPath = paths.getBinaryPath(pkg, chromiumPath);
|
||||||
const binaryChecksum = await sha256(binaryPath).catch(() => '');
|
const binaryChecksum = await sha256(binaryPath).catch(() => '');
|
||||||
|
|
||||||
if (binaryChecksum !== pkg.binaryChecksum) {
|
if (binaryChecksum !== pkg.binaryChecksum) {
|
||||||
|
|
|
@ -3034,6 +3034,10 @@
|
||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
uid ""
|
uid ""
|
||||||
|
|
||||||
|
"@kbn/screenshotting-server@link:bazel-bin/packages/kbn-screenshotting-server":
|
||||||
|
version "0.0.0"
|
||||||
|
uid ""
|
||||||
|
|
||||||
"@kbn/securitysolution-autocomplete@link:bazel-bin/packages/kbn-securitysolution-autocomplete":
|
"@kbn/securitysolution-autocomplete@link:bazel-bin/packages/kbn-securitysolution-autocomplete":
|
||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
uid ""
|
uid ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue