From 4d9880fa8065d96eeb8bfbeeec5a049baebf6384 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Tue, 28 Jan 2020 15:14:10 -0500 Subject: [PATCH 1/6] Skip tests that depend on other skipped test --- .../visualize/feature_controls/visualize_security.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts index 5f8b3f38436f6..bdcdc4b7cd3ec 100644 --- a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts +++ b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts @@ -124,7 +124,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await savedQueryManagementComponent.closeSavedQueryManagementComponent(); }); - it('allow saving a currently loaded saved query as a new query via the saved query management component ', async () => { + // Depends on skipped test above + it.skip('allow saving a currently loaded saved query as a new query via the saved query management component ', async () => { await savedQueryManagementComponent.saveCurrentlyLoadedAsNewQuery( 'foo2', 'bar2', @@ -135,7 +136,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await savedQueryManagementComponent.closeSavedQueryManagementComponent(); }); - it('allow saving changes to a currently loaded query via the saved query management component', async () => { + // Depends on skipped test above + it.skip('allow saving changes to a currently loaded query via the saved query management component', async () => { await savedQueryManagementComponent.loadSavedQuery('foo2'); await queryBar.setQuery('response:404'); await savedQueryManagementComponent.updateCurrentlyLoadedQuery('bar2', false, false); @@ -145,7 +147,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(queryString).to.eql('response:404'); }); - it('allows deleting saved queries in the saved query management component ', async () => { + // Depends on skipped test above + it.skip('allows deleting saved queries in the saved query management component ', async () => { await savedQueryManagementComponent.deleteSavedQuery('foo2'); await savedQueryManagementComponent.savedQueryMissingOrFail('foo2'); }); From cc45065972b8138dd9d753fd30bf8e14f3026379 Mon Sep 17 00:00:00 2001 From: Poff Poffenberger Date: Tue, 28 Jan 2020 15:08:03 -0600 Subject: [PATCH 2/6] [Canvas] Remove Angular and unnecessary reporting config from Canvas (#54050) (#56067) * Remove Angular from Canvas * Remove reporting config behavior from Canvas since it's no longer needed Co-authored-by: Elastic Machine Co-authored-by: Elastic Machine --- .../canvas/.storybook/storyshots.test.js | 8 --- .../i18n/{angular.ts => capabilities.ts} | 8 +-- x-pack/legacy/plugins/canvas/i18n/index.ts | 2 +- .../canvas/public/angular/config/index.js | 8 --- .../angular/config/location_provider.ts | 21 -------- .../public/angular/config/state_management.js | 13 ----- .../public/angular/controllers/canvas.tsx | 54 ------------------- .../public/angular/controllers/index.ts | 7 --- .../canvas/public/angular/services/index.js | 7 --- .../canvas/public/angular/services/store.js | 31 ----------- .../plugins/canvas/public/application.tsx | 36 +++++++++++++ .../workpad_export.examples.storyshot | 45 ---------------- .../__examples__/disabled_panel.stories.tsx | 31 ----------- .../__examples__/workpad_export.examples.tsx | 33 ++++-------- .../workpad_export/disabled_panel.tsx | 50 ----------------- .../workpad_header/workpad_export/index.ts | 7 +-- .../workpad_export/workpad_export.tsx | 22 +------- x-pack/legacy/plugins/canvas/public/legacy.ts | 6 +-- .../legacy/plugins/canvas/public/plugin.tsx | 45 +++++++++++----- .../canvas/public/state/selectors/app.ts | 4 -- x-pack/legacy/plugins/canvas/public/store.ts | 31 +++++++++++ x-pack/legacy/plugins/canvas/server/plugin.ts | 16 +----- x-pack/legacy/plugins/canvas/types/state.ts | 2 - .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - 25 files changed, 118 insertions(+), 371 deletions(-) rename x-pack/legacy/plugins/canvas/i18n/{angular.ts => capabilities.ts} (83%) delete mode 100644 x-pack/legacy/plugins/canvas/public/angular/config/index.js delete mode 100644 x-pack/legacy/plugins/canvas/public/angular/config/location_provider.ts delete mode 100644 x-pack/legacy/plugins/canvas/public/angular/config/state_management.js delete mode 100644 x-pack/legacy/plugins/canvas/public/angular/controllers/canvas.tsx delete mode 100644 x-pack/legacy/plugins/canvas/public/angular/controllers/index.ts delete mode 100755 x-pack/legacy/plugins/canvas/public/angular/services/index.js delete mode 100644 x-pack/legacy/plugins/canvas/public/angular/services/store.js create mode 100644 x-pack/legacy/plugins/canvas/public/application.tsx delete mode 100644 x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/disabled_panel.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/disabled_panel.tsx create mode 100644 x-pack/legacy/plugins/canvas/public/store.ts diff --git a/x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js b/x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js index 76240d212da15..10842f4268fd3 100644 --- a/x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js +++ b/x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js @@ -50,14 +50,6 @@ jest.mock('@elastic/eui/packages/react-datepicker', () => { jest.mock('plugins/interpreter/registries', () => ({})); -// Disabling this test due to https://github.com/elastic/eui/issues/2242 -jest.mock( - '../public/components/workpad_header/workpad_export/__examples__/disabled_panel.stories', - () => { - return 'Disabled Panel'; - } -); - // Disabling this test due to https://github.com/elastic/eui/issues/2242 jest.mock( '../public/components/workpad_header/workpad_export/flyout/__examples__/share_website_flyout.stories', diff --git a/x-pack/legacy/plugins/canvas/i18n/angular.ts b/x-pack/legacy/plugins/canvas/i18n/capabilities.ts similarity index 83% rename from x-pack/legacy/plugins/canvas/i18n/angular.ts rename to x-pack/legacy/plugins/canvas/i18n/capabilities.ts index 74e5ceb7d6bb7..a4c2d1d3a1be7 100644 --- a/x-pack/legacy/plugins/canvas/i18n/angular.ts +++ b/x-pack/legacy/plugins/canvas/i18n/capabilities.ts @@ -7,13 +7,13 @@ import { i18n } from '@kbn/i18n'; import { CANVAS as canvas } from './constants'; -export const AngularStrings = { - CanvasRootController: { - getReadOnlyBadgeText: () => +export const CapabilitiesStrings = { + ReadOnlyBadge: { + getText: () => i18n.translate('xpack.canvas.badge.readOnly.text', { defaultMessage: 'Read only', }), - getReadOnlyBadgeTooltip: () => + getTooltip: () => i18n.translate('xpack.canvas.badge.readOnly.tooltip', { defaultMessage: 'Unable to save {canvas} workpads', values: { diff --git a/x-pack/legacy/plugins/canvas/i18n/index.ts b/x-pack/legacy/plugins/canvas/i18n/index.ts index 3be5eb89415b0..a671d0ccdb49f 100644 --- a/x-pack/legacy/plugins/canvas/i18n/index.ts +++ b/x-pack/legacy/plugins/canvas/i18n/index.ts @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; -export * from './angular'; +export * from './capabilities'; export * from './components'; export * from './constants'; export * from './errors'; diff --git a/x-pack/legacy/plugins/canvas/public/angular/config/index.js b/x-pack/legacy/plugins/canvas/public/angular/config/index.js deleted file mode 100644 index 020bcf1f7686e..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/config/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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. - */ - -export * from './state_management'; // Requires 6.2.0+ -export * from './location_provider'; diff --git a/x-pack/legacy/plugins/canvas/public/angular/config/location_provider.ts b/x-pack/legacy/plugins/canvas/public/angular/config/location_provider.ts deleted file mode 100644 index 547e354d7fde9..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/config/location_provider.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 { ILocationProvider } from 'angular'; -import { CoreStart, CanvasStartDeps } from '../../plugin'; - -export function initLocationProvider(coreStart: CoreStart, plugins: CanvasStartDeps) { - // disable angular's location provider - const app = plugins.__LEGACY.uiModules.get('apps/canvas'); - - app.config(($locationProvider: ILocationProvider) => { - $locationProvider.html5Mode({ - enabled: false, - requireBase: false, - rewriteLinks: false, - }); - }); -} diff --git a/x-pack/legacy/plugins/canvas/public/angular/config/state_management.js b/x-pack/legacy/plugins/canvas/public/angular/config/state_management.js deleted file mode 100644 index 4347765748c5d..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/config/state_management.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * 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. - */ - -export function initStateManagement(coreStart, plugins) { - // disable the kibana state management - const app = plugins.__LEGACY.uiModules.get('apps/canvas'); - app.config(stateManagementConfigProvider => { - stateManagementConfigProvider.disable(); - }); -} diff --git a/x-pack/legacy/plugins/canvas/public/angular/controllers/canvas.tsx b/x-pack/legacy/plugins/canvas/public/angular/controllers/canvas.tsx deleted file mode 100644 index 0dfa1ceecdbc5..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/controllers/canvas.tsx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 React from 'react'; -import { render, unmountComponentAtNode } from 'react-dom'; -import { I18nProvider } from '@kbn/i18n/react'; -import { Provider } from 'react-redux'; -import { Store } from 'redux'; -import { CanvasStartDeps, CoreStart } from '../../plugin'; -import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; - -// @ts-ignore Untyped local -import { App } from '../../components/app'; -import { AngularStrings } from '../../../i18n'; - -const { CanvasRootController: strings } = AngularStrings; - -export function CanvasRootControllerFactory(coreStart: CoreStart, plugins: CanvasStartDeps) { - return function CanvasRootController( - canvasStore: Store, - $scope: any, // Untyped in Kibana - $element: any // Untyped in Kibana - ) { - const domNode = $element[0]; - - // set the read-only badge when appropriate - coreStart.chrome.setBadge( - coreStart.application.capabilities.canvas.save - ? undefined - : { - text: strings.getReadOnlyBadgeText(), - tooltip: strings.getReadOnlyBadgeTooltip(), - iconType: 'glasses', - } - ); - - render( - - - - - - - , - domNode - ); - - $scope.$on('$destroy', () => { - unmountComponentAtNode(domNode); - }); - }; -} diff --git a/x-pack/legacy/plugins/canvas/public/angular/controllers/index.ts b/x-pack/legacy/plugins/canvas/public/angular/controllers/index.ts deleted file mode 100644 index 01fe3dda9c971..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/controllers/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * 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. - */ - -export { CanvasRootControllerFactory } from './canvas'; diff --git a/x-pack/legacy/plugins/canvas/public/angular/services/index.js b/x-pack/legacy/plugins/canvas/public/angular/services/index.js deleted file mode 100755 index b472b9bbac993..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/services/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * 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. - */ - -export * from './store'; diff --git a/x-pack/legacy/plugins/canvas/public/angular/services/store.js b/x-pack/legacy/plugins/canvas/public/angular/services/store.js deleted file mode 100644 index f6f9d8922b99e..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/angular/services/store.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 { createStore } from '../../state/store'; -import { getInitialState } from '../../state/initial_state'; - -export function initStore(coreStart, plugins) { - const app = plugins.__LEGACY.uiModules.get('apps/canvas'); - app.service('canvasStore', (kbnVersion, basePath, reportingBrowserType, serverFunctions) => { - const initialState = getInitialState(); - - // Set the defaults from Kibana plugin - initialState.app = { - kbnVersion, - basePath, - reportingBrowserType, - serverFunctions, - ready: false, - }; - - const store = createStore(initialState); - - // TODO: debugging, remove this - window.canvasStore = store; - - return store; - }); -} diff --git a/x-pack/legacy/plugins/canvas/public/application.tsx b/x-pack/legacy/plugins/canvas/public/application.tsx new file mode 100644 index 0000000000000..ff22d68772efe --- /dev/null +++ b/x-pack/legacy/plugins/canvas/public/application.tsx @@ -0,0 +1,36 @@ +/* + * 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 React from 'react'; +import { Store } from 'redux'; +import ReactDOM from 'react-dom'; +import { I18nProvider } from '@kbn/i18n/react'; +import { Provider } from 'react-redux'; + +import { AppMountParameters, CoreStart } from 'kibana/public'; + +// @ts-ignore Untyped local +import { App } from './components/app'; +import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; + +export const renderApp = ( + coreStart: CoreStart, + plugins: object, + { element }: AppMountParameters, + canvasStore: Store +) => { + ReactDOM.render( + + + + + + + , + element + ); + return () => ReactDOM.unmountComponentAtNode(element); +}; diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/__snapshots__/workpad_export.examples.storyshot b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/__snapshots__/workpad_export.examples.storyshot index 9c7fca6d78190..a598438564130 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/__snapshots__/workpad_export.examples.storyshot +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/__snapshots__/workpad_export.examples.storyshot @@ -1,50 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Storyshots components/Export/WorkpadExport disabled 1`] = ` -
-
-
- - - -
-
-
-`; - exports[`Storyshots components/Export/WorkpadExport enabled 1`] = `
( -
- -
- )); diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/workpad_export.examples.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/workpad_export.examples.tsx index 7e401194f44f1..92e7cca40ee3a 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/workpad_export.examples.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/__examples__/workpad_export.examples.tsx @@ -8,26 +8,13 @@ import { action } from '@storybook/addon-actions'; import React from 'react'; import { WorkpadExport } from '../workpad_export'; -storiesOf('components/Export/WorkpadExport', module) - .add('enabled', () => ( - { - action(`getExportUrl('${type}')`); - return type; - }} - /> - )) - .add('disabled', () => ( - { - action(`getExportUrl('${type}')`); - return type; - }} - /> - )); +storiesOf('components/Export/WorkpadExport', module).add('enabled', () => ( + { + action(`getExportUrl('${type}')`); + return type; + }} + /> +)); diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/disabled_panel.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/disabled_panel.tsx deleted file mode 100644 index 85d1174f50bbd..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/disabled_panel.tsx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 React from 'react'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiText, EuiSpacer, EuiCodeBlock, EuiCode } from '@elastic/eui'; -import { Clipboard } from '../../clipboard'; - -const REPORTING_CONFIG = `xpack.reporting: - enabled: true - capture.browser.type: chromium`; - -interface Props { - /** Handler to invoke when the Kibana configuration is copied. */ - onCopy: () => void; -} - -/** - * A panel to display within the Export menu when reporting is disabled. - */ -export const DisabledPanel = ({ onCopy }: Props) => ( -
- -

- kibana.yml, - }} - /> -

-
- - - - {REPORTING_CONFIG} - - -
-); diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/index.ts b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/index.ts index 2b2a582fb4526..39611dd6c2994 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/index.ts +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/index.ts @@ -10,8 +10,6 @@ import { jobCompletionNotifications } from '../../../../../reporting/public/lib/ // @ts-ignore Untyped local import { getWorkpad, getPages } from '../../../state/selectors/workpad'; // @ts-ignore Untyped local -import { getReportingBrowserType } from '../../../state/selectors/app'; -// @ts-ignore Untyped local import { notify } from '../../../lib/notify'; import { getWindow } from '../../../lib/get_window'; // @ts-ignore Untyped local @@ -34,7 +32,6 @@ const { WorkpadHeaderWorkpadExport: strings } = ComponentStrings; const mapStateToProps = (state: State) => ({ workpad: getWorkpad(state), pageCount: getPages(state).length, - enabled: getReportingBrowserType(state) === 'chromium', }); const getAbsoluteUrl = (path: string) => { @@ -51,15 +48,13 @@ const getAbsoluteUrl = (path: string) => { interface Props { workpad: CanvasWorkpad; pageCount: number; - enabled: boolean; } export const WorkpadExport = compose( connect(mapStateToProps), withKibana, withProps( - ({ workpad, pageCount, enabled, kibana }: Props & WithKibanaProps): ComponentProps => ({ - enabled, + ({ workpad, pageCount, kibana }: Props & WithKibanaProps): ComponentProps => ({ getExportUrl: type => { if (type === 'pdf') { const pdfUrl = getPdfUrl(workpad, { pageCount }, kibana.services.http.basePath.prepend); diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/workpad_export.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/workpad_export.tsx index 0558652fb6029..522be043ec457 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/workpad_export.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/workpad_export.tsx @@ -9,7 +9,6 @@ import PropTypes from 'prop-types'; import { EuiButtonIcon, EuiContextMenu, EuiIcon } from '@elastic/eui'; // @ts-ignore Untyped local import { Popover } from '../../popover'; -import { DisabledPanel } from './disabled_panel'; import { PDFPanel } from './pdf_panel'; import { ShareWebsiteFlyout } from './flyout'; @@ -29,8 +28,6 @@ export type OnCloseFn = (type: CloseTypes) => void; export type GetExportUrlFn = (type: ExportUrlTypes) => string; export interface Props { - /** True if exporting is enabled, false otherwise. */ - enabled: boolean; /** Handler to invoke when an export URL is copied to the clipboard. */ onCopy: OnCopyFn; /** Handler to invoke when an end product is exported. */ @@ -42,12 +39,7 @@ export interface Props { /** * The Menu for Exporting a Workpad from Canvas. */ -export const WorkpadExport: FunctionComponent = ({ - enabled, - onCopy, - onExport, - getExportUrl, -}) => { +export const WorkpadExport: FunctionComponent = ({ onCopy, onExport, getExportUrl }) => { const [showFlyout, setShowFlyout] = useState(false); const onClose = () => { @@ -106,16 +98,7 @@ export const WorkpadExport: FunctionComponent = ({ panel: { id: 1, title: strings.getShareDownloadPDFTitle(), - content: enabled ? ( - getPDFPanel(closePopover) - ) : ( - { - onCopy('reportingConfig'); - closePopover(); - }} - /> - ), + content: getPDFPanel(closePopover), }, }, { @@ -160,7 +143,6 @@ export const WorkpadExport: FunctionComponent = ({ }; WorkpadExport.propTypes = { - enabled: PropTypes.bool.isRequired, onCopy: PropTypes.func.isRequired, onExport: PropTypes.func.isRequired, getExportUrl: PropTypes.func.isRequired, diff --git a/x-pack/legacy/plugins/canvas/public/legacy.ts b/x-pack/legacy/plugins/canvas/public/legacy.ts index 61e12893b3e02..254fba0f23ad2 100644 --- a/x-pack/legacy/plugins/canvas/public/legacy.ts +++ b/x-pack/legacy/plugins/canvas/public/legacy.ts @@ -9,8 +9,6 @@ import { CanvasStartDeps } from './plugin'; // eslint-disable-line import/order // @ts-ignore Untyped Kibana Lib import chrome, { loadingCount } from 'ui/chrome'; // eslint-disable-line import/order -// @ts-ignore Untyped Module -import { uiModules } from 'ui/modules'; // eslint-disable-line import/order import { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url'; // eslint-disable-line import/order import { Storage } from '../../../../../src/plugins/kibana_utils/public'; // eslint-disable-line import/order // @ts-ignore Untyped Kibana Lib @@ -25,6 +23,7 @@ const shimCoreStart = { ...npStart.core, }; const shimSetupPlugins = {}; + const shimStartPlugins: CanvasStartDeps = { ...npStart.plugins, __LEGACY: { @@ -33,12 +32,9 @@ const shimStartPlugins: CanvasStartDeps = { // ToDo: Copy directly into canvas formatMsg, QueryString, - // ToDo: Remove in favor of core.application.register - setRootController: chrome.setRootController, storage: Storage, // ToDo: Won't be a part of New Platform. Will need to handle internally trackSubUrlForApp: chrome.trackSubUrlForApp, - uiModules, }, }; diff --git a/x-pack/legacy/plugins/canvas/public/plugin.tsx b/x-pack/legacy/plugins/canvas/public/plugin.tsx index 155eef99632a0..7928d46067908 100644 --- a/x-pack/legacy/plugins/canvas/public/plugin.tsx +++ b/x-pack/legacy/plugins/canvas/public/plugin.tsx @@ -7,15 +7,15 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Chrome } from 'ui/chrome'; -import { IModule } from 'angular'; import { i18n } from '@kbn/i18n'; import { Storage } from '../../../../../src/plugins/kibana_utils/public'; import { CoreSetup, CoreStart, Plugin } from '../../../../../src/core/public'; // @ts-ignore: Untyped Local -import { initStateManagement, initLocationProvider } from './angular/config'; -import { CanvasRootControllerFactory } from './angular/controllers'; -// @ts-ignore: Untypled Local -import { initStore } from './angular/services'; +import { CapabilitiesStrings } from '../i18n'; +const { ReadOnlyBadge: strings } = CapabilitiesStrings; + +import { createStore } from './store'; + // @ts-ignore: untyped local component import { HelpMenu } from './components/help_menu/help_menu'; // @ts-ignore: untyped local @@ -40,12 +40,8 @@ export interface CanvasStartDeps { absoluteToParsedUrl: (url: string, basePath: string) => any; formatMsg: any; QueryString: any; - setRootController: Chrome['setRootController']; storage: typeof Storage; trackSubUrlForApp: Chrome['trackSubUrlForApp']; - uiModules: { - get: (module: string) => IModule; - }; }; } @@ -67,6 +63,22 @@ export class CanvasPlugin // Things like registering functions to the interpreter that need // to be available everywhere, not just in Canvas + core.application.register({ + id: 'canvas', + title: 'Canvas App', + async mount(context, params) { + // Load application bundle + const { renderApp } = await import('./application'); + + // Setup our store + const canvasStore = await createStore(core, plugins); + + // Get start services + const [coreStart, depsStart] = await core.getStartServices(); + + return renderApp(coreStart, depsStart, params, canvasStore); + }, + }); return {}; } @@ -74,14 +86,19 @@ export class CanvasPlugin loadExpressionTypes(); loadTransitions(); - initStateManagement(core, plugins); - initLocationProvider(core, plugins); - initStore(core, plugins); initClipboard(plugins.__LEGACY.storage); initLoadingIndicator(core.http.addLoadingCountSource); - const CanvasRootController = CanvasRootControllerFactory(core, plugins); - plugins.__LEGACY.setRootController('canvas', CanvasRootController); + core.chrome.setBadge( + core.application.capabilities.canvas && core.application.capabilities.canvas.save + ? undefined + : { + text: strings.getText(), + tooltip: strings.getTooltip(), + iconType: 'glasses', + } + ); + core.chrome.setHelpExtension({ appName: i18n.translate('xpack.canvas.helpMenu.appName', { defaultMessage: 'Canvas', diff --git a/x-pack/legacy/plugins/canvas/public/state/selectors/app.ts b/x-pack/legacy/plugins/canvas/public/state/selectors/app.ts index 255d45cf558fc..d68702a30d645 100644 --- a/x-pack/legacy/plugins/canvas/public/state/selectors/app.ts +++ b/x-pack/legacy/plugins/canvas/public/state/selectors/app.ts @@ -32,10 +32,6 @@ export function getBasePath(state: State): State['app']['basePath'] { return state.app.basePath; } -export function getReportingBrowserType(state: State): State['app']['reportingBrowserType'] { - return state.app.reportingBrowserType; -} - // return true only when the required parameters are in the state export function isAppReady(state: State): boolean { const appReady = getAppReady(state); diff --git a/x-pack/legacy/plugins/canvas/public/store.ts b/x-pack/legacy/plugins/canvas/public/store.ts new file mode 100644 index 0000000000000..0a378979f6ad9 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/public/store.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// @ts-ignore Untyped local +import { createStore as createReduxStore } from './state/store'; +// @ts-ignore Untyped local +import { getInitialState } from './state/initial_state'; + +import { CoreSetup } from '../../../../../src/core/public'; +import { CanvasSetupDeps } from './plugin'; + +export async function createStore(core: CoreSetup, plugins: CanvasSetupDeps) { + const initialState = getInitialState(); + + const basePath = core.http.basePath.get(); + + // Retrieve server functions + const serverFunctionsResponse = await core.http.get(`/api/interpreter/fns`); + const serverFunctions = Object.values(serverFunctionsResponse); + + initialState.app = { + basePath, + serverFunctions, + ready: false, + }; + + return createReduxStore(initialState); +} diff --git a/x-pack/legacy/plugins/canvas/server/plugin.ts b/x-pack/legacy/plugins/canvas/server/plugin.ts index 07f4b7d9ac6db..ac3edbabce930 100644 --- a/x-pack/legacy/plugins/canvas/server/plugin.ts +++ b/x-pack/legacy/plugins/canvas/server/plugin.ts @@ -13,25 +13,11 @@ export class Plugin { public setup(core: CoreSetup, plugins: PluginsSetup) { routes(core); - const { serverFunctions } = plugins.interpreter.register({ serverFunctions: functions }); + plugins.interpreter.register({ serverFunctions: functions }); core.injectUiAppVars('canvas', async () => { - const config = core.getServerConfig(); - const basePath = config.get('server.basePath'); - const reportingBrowserType = (() => { - const configKey = 'xpack.reporting.capture.browser.type'; - if (!config.has(configKey)) { - return null; - } - return config.get(configKey); - })(); - return { ...plugins.kibana.injectedUiAppVars, - kbnIndex: config.get('kibana.index'), - serverFunctions: serverFunctions.toArray(), - basePath, - reportingBrowserType, }; }); diff --git a/x-pack/legacy/plugins/canvas/types/state.ts b/x-pack/legacy/plugins/canvas/types/state.ts index 3aca3003f9dc5..171c5515fbb2a 100644 --- a/x-pack/legacy/plugins/canvas/types/state.ts +++ b/x-pack/legacy/plugins/canvas/types/state.ts @@ -32,9 +32,7 @@ export interface AppState { } interface StoreAppState { - kbnVersion: string; basePath: string; - reportingBrowserType: string; // TODO: These server functions are actually missing the fn because they are serialized from the server serverFunctions: CanvasFunction[]; ready: boolean; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 0a1ec4876f373..bf59568ba71b0 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5271,7 +5271,6 @@ "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyAriaLabel": "この {URL} を使用してスクリプトから、または Watcher で {PDF} を生成することもできます。{URL} をクリップボードにコピーするにはエンターキーを押してください。", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyButtonLabel": "{POST} {URL} をコピー", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyDescription": "{POST} {URL} をコピーして {KIBANA} 外または ウォッチャー から生成することもできます。", - "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelDisabledDescription": "PDF へのエクスポートは無効になっています。Chromium ブラウザを使用するにはレポートの構成が必要です。これを {fileName} ファイルに追加します。", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelGenerateButtonLabel": "{PDF} を生成", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelGenerateDescription": "ワークパッドのサイズによって、{PDF} の生成には数分かかる場合があります。", "xpack.canvas.workpadHeaderWorkpadExport.shareDownloadJSONTitle": "{JSON} をダウンロード", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 5d368a31c64ab..829b42845c0ab 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5270,7 +5270,6 @@ "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyAriaLabel": "或者,也可以从脚本或使用 {URL} 通过 Watcher 生成 {PDF}。按 Enter 键可将 {URL} 复制到剪贴板。", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyButtonLabel": "复制 {POST} {URL}", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyDescription": "或者,复制此 {POST} {URL} 以从 {KIBANA} 外部或从 Watcher 调用生成。", - "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelDisabledDescription": "导出到 PDF 已禁用。必须配置报告,才能使用 Chromium 浏览器。将其添加到您的 {fileName} 文件中。", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelGenerateButtonLabel": "生成 {PDF}", "xpack.canvas.workpadHeaderWorkpadExport.pdfPanelGenerateDescription": "{PDF} 可能会花费 1 或 2 分钟生成,取决于 Workpad 的大小。", "xpack.canvas.workpadHeaderWorkpadExport.shareDownloadJSONTitle": "下载为 {JSON}", From 753c42be446c577ddfe4007c4c0299921ee206b8 Mon Sep 17 00:00:00 2001 From: Brandon Morelli Date: Tue, 28 Jan 2020 13:19:14 -0800 Subject: [PATCH 3/6] [docs] Remove unused callout (#56032) (#56098) --- docs/api/saved-objects/import.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/saved-objects/import.asciidoc b/docs/api/saved-objects/import.asciidoc index 0331f23284352..63e733863cc85 100644 --- a/docs/api/saved-objects/import.asciidoc +++ b/docs/api/saved-objects/import.asciidoc @@ -49,7 +49,7 @@ Import an index pattern and dashboard: [source,js] -------------------------------------------------- -$ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson <1> +$ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- The `file.ndjson` file contains the following: From 18b8e68f9e7220f8664861de08fd6bb8fe877e95 Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Tue, 28 Jan 2020 14:48:29 -0700 Subject: [PATCH 4/6] [SIEM][Detection Engine] critical blocker bug fixes ancestor mapping (#56200) ## Summary * Fixes critical bug with ancestor mapping being object and not correct mappings. Testing you should now be able to do operations and it will show up on KQL Screen Shot 2020-01-28 at 9 33 59 AM Screen Shot 2020-01-28 at 9 33 22 AM ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] 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/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ ~~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~~ ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers ~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ ~~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~ Co-authored-by: Elastic Machine --- .../routes/index/signals_mapping.json | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json index 4986c100f1b0b..714b39d1557a1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json @@ -23,7 +23,20 @@ } }, "ancestors": { - "type": "object" + "properties": { + "rule": { + "type": "keyword" + }, + "id": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "depth": { + "type": "long" + } + } }, "rule": { "properties": { From 2de2658f4d099e67c64ff74022d01e4e7bcee84a Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Tue, 28 Jan 2020 16:55:29 -0500 Subject: [PATCH 5/6] Remove matrix build support (#54202) (#56170) --- .ci/Jenkinsfile_coverage | 112 ++++++++++++++++++ .ci/es-snapshots/Jenkinsfile_verify_es | 4 +- .ci/jobs.yml | 2 + .ci/run.sh | 50 -------- Jenkinsfile | 4 +- test/scripts/jenkins_accessibility.sh | 19 +-- test/scripts/jenkins_ci_group.sh | 15 +-- test/scripts/jenkins_firefox_smoke.sh | 18 +-- test/scripts/jenkins_test_setup.sh | 10 +- test/scripts/jenkins_test_setup_oss.sh | 11 ++ test/scripts/jenkins_test_setup_xpack.sh | 13 ++ test/scripts/jenkins_unit.sh | 4 +- test/scripts/jenkins_visual_regression.sh | 16 +-- test/scripts/jenkins_xpack.sh | 4 +- test/scripts/jenkins_xpack_accessibility.sh | 28 +---- test/scripts/jenkins_xpack_ci_group.sh | 50 +------- test/scripts/jenkins_xpack_firefox_smoke.sh | 19 +-- .../jenkins_xpack_visual_regression.sh | 19 +-- vars/kibanaPipeline.groovy | 85 +++++++------ 19 files changed, 198 insertions(+), 285 deletions(-) create mode 100644 .ci/Jenkinsfile_coverage delete mode 100755 .ci/run.sh create mode 100644 test/scripts/jenkins_test_setup_oss.sh create mode 100644 test/scripts/jenkins_test_setup_xpack.sh diff --git a/.ci/Jenkinsfile_coverage b/.ci/Jenkinsfile_coverage new file mode 100644 index 0000000000000..01c18b10d0804 --- /dev/null +++ b/.ci/Jenkinsfile_coverage @@ -0,0 +1,112 @@ +#!/bin/groovy + +library 'kibana-pipeline-library' +kibanaLibrary.load() // load from the Jenkins instance + +stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a little bit + timeout(time: 180, unit: 'MINUTES') { + timestamps { + ansiColor('xterm') { + catchError { + withEnv([ + 'CODE_COVERAGE=1', // Needed for multiple ci scripts, such as remote.ts, test/scripts/*.sh, schema.js, etc. + ]) { + parallel([ + 'kibana-intake-agent': { + withEnv([ + 'NODE_ENV=test' // Needed for jest tests only + ]) { + kibanaPipeline.intakeWorker('kibana-intake', './test/scripts/jenkins_unit.sh')() + } + }, + 'x-pack-intake-agent': { + withEnv([ + 'NODE_ENV=test' // Needed for jest tests only + ]) { + kibanaPipeline.intakeWorker('x-pack-intake', './test/scripts/jenkins_xpack.sh')() + } + }, + 'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [ + 'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1), + 'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2), + 'oss-ciGroup3': kibanaPipeline.getOssCiGroupWorker(3), + 'oss-ciGroup4': kibanaPipeline.getOssCiGroupWorker(4), + 'oss-ciGroup5': kibanaPipeline.getOssCiGroupWorker(5), + 'oss-ciGroup6': kibanaPipeline.getOssCiGroupWorker(6), + 'oss-ciGroup7': kibanaPipeline.getOssCiGroupWorker(7), + 'oss-ciGroup8': kibanaPipeline.getOssCiGroupWorker(8), + 'oss-ciGroup9': kibanaPipeline.getOssCiGroupWorker(9), + 'oss-ciGroup10': kibanaPipeline.getOssCiGroupWorker(10), + 'oss-ciGroup11': kibanaPipeline.getOssCiGroupWorker(11), + 'oss-ciGroup12': kibanaPipeline.getOssCiGroupWorker(12), + ]), + 'kibana-xpack-agent-1': kibanaPipeline.withWorkers('kibana-xpack-tests-1', { kibanaPipeline.buildXpack() }, [ + 'xpack-ciGroup1': kibanaPipeline.getXpackCiGroupWorker(1), + 'xpack-ciGroup2': kibanaPipeline.getXpackCiGroupWorker(2), + ]), + 'kibana-xpack-agent-2': kibanaPipeline.withWorkers('kibana-xpack-tests-2', { kibanaPipeline.buildXpack() }, [ + 'xpack-ciGroup3': kibanaPipeline.getXpackCiGroupWorker(3), + 'xpack-ciGroup4': kibanaPipeline.getXpackCiGroupWorker(4), + ]), + + 'kibana-xpack-agent-3': kibanaPipeline.withWorkers('kibana-xpack-tests-3', { kibanaPipeline.buildXpack() }, [ + 'xpack-ciGroup5': kibanaPipeline.getXpackCiGroupWorker(5), + 'xpack-ciGroup6': kibanaPipeline.getXpackCiGroupWorker(6), + 'xpack-ciGroup7': kibanaPipeline.getXpackCiGroupWorker(7), + 'xpack-ciGroup8': kibanaPipeline.getXpackCiGroupWorker(8), + 'xpack-ciGroup9': kibanaPipeline.getXpackCiGroupWorker(9), + 'xpack-ciGroup10': kibanaPipeline.getXpackCiGroupWorker(10), + ]), + ]) + kibanaPipeline.jobRunner('tests-l', false) { + kibanaPipeline.downloadCoverageArtifacts() + kibanaPipeline.bash( + ''' + # bootstrap from x-pack folder + source src/dev/ci_setup/setup_env.sh + cd x-pack + yarn kbn bootstrap --prefer-offline + cd .. + # extract archives + mkdir -p /tmp/extracted_coverage + echo extracting intakes + tar -xzf /tmp/downloaded_coverage/coverage/kibana-intake/kibana-coverage.tar.gz -C /tmp/extracted_coverage + tar -xzf /tmp/downloaded_coverage/coverage/x-pack-intake/kibana-coverage.tar.gz -C /tmp/extracted_coverage + echo extracting kibana-oss-tests + tar -xzf /tmp/downloaded_coverage/coverage/kibana-oss-tests/kibana-coverage.tar.gz -C /tmp/extracted_coverage + echo extracting kibana-xpack-tests + for i in {1..3}; do + tar -xzf /tmp/downloaded_coverage/coverage/kibana-xpack-tests-${i}/kibana-coverage.tar.gz -C /tmp/extracted_coverage + done + # replace path in json files to have valid html report + pwd=$(pwd) + du -sh /tmp/extracted_coverage/target/kibana-coverage/ + echo replacing path in json files + for i in {1..9}; do + sed -i "s|/dev/shm/workspace/kibana|$pwd|g" /tmp/extracted_coverage/target/kibana-coverage/functional/${i}*.json & + done + wait + # merge oss & x-pack reports + echo merging coverage reports + yarn nyc report --temp-dir /tmp/extracted_coverage/target/kibana-coverage/jest --report-dir target/kibana-coverage/jest-combined --reporter=html --reporter=json-summary + yarn nyc report --temp-dir /tmp/extracted_coverage/target/kibana-coverage/functional --report-dir target/kibana-coverage/functional-combined --reporter=html --reporter=json-summary + echo copy mocha reports + mkdir -p target/kibana-coverage/mocha-combined + cp -r /tmp/extracted_coverage/target/kibana-coverage/mocha target/kibana-coverage/mocha-combined + ''', + "run `yarn kbn bootstrap && merge coverage`" + ) + sh 'tar -czf kibana-jest-coverage.tar.gz target/kibana-coverage/jest-combined/*' + kibanaPipeline.uploadCoverageArtifacts("coverage/jest-combined", 'kibana-jest-coverage.tar.gz') + sh 'tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional-combined/*' + kibanaPipeline.uploadCoverageArtifacts("coverage/functional-combined", 'kibana-functional-coverage.tar.gz') + sh 'tar -czf kibana-mocha-coverage.tar.gz target/kibana-coverage/mocha-combined/*' + kibanaPipeline.uploadCoverageArtifacts("coverage/mocha-combined", 'kibana-mocha-coverage.tar.gz') + } + } + } + kibanaPipeline.sendMail() + } + } + } +} diff --git a/.ci/es-snapshots/Jenkinsfile_verify_es b/.ci/es-snapshots/Jenkinsfile_verify_es index 3d5ec75fa0e72..30d52a56547bd 100644 --- a/.ci/es-snapshots/Jenkinsfile_verify_es +++ b/.ci/es-snapshots/Jenkinsfile_verify_es @@ -26,8 +26,8 @@ timeout(time: 120, unit: 'MINUTES') { withEnv(["ES_SNAPSHOT_MANIFEST=${SNAPSHOT_MANIFEST}"]) { parallel([ // TODO we just need to run integration tests from intake? - 'kibana-intake-agent': kibanaPipeline.legacyJobRunner('kibana-intake'), - 'x-pack-intake-agent': kibanaPipeline.legacyJobRunner('x-pack-intake'), + 'kibana-intake-agent': kibanaPipeline.intakeWorker('kibana-intake', './test/scripts/jenkins_unit.sh'), + 'x-pack-intake-agent': kibanaPipeline.intakeWorker('x-pack-intake', './test/scripts/jenkins_xpack.sh'), 'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [ 'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1), 'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2), diff --git a/.ci/jobs.yml b/.ci/jobs.yml index 15fe7b645e5cb..6e54a131d157a 100644 --- a/.ci/jobs.yml +++ b/.ci/jobs.yml @@ -1,3 +1,5 @@ +# This file is needed by functionalTests:ensureAllTestsInCiGroup for the list of ciGroups. That must be changed before this file can be removed + JOB: - kibana-intake - x-pack-intake diff --git a/.ci/run.sh b/.ci/run.sh deleted file mode 100755 index 9f77438be62d0..0000000000000 --- a/.ci/run.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# move to Kibana root -cd "$(dirname "$0")/.." - -source src/dev/ci_setup/load_env_keys.sh -source src/dev/ci_setup/extract_bootstrap_cache.sh -source src/dev/ci_setup/setup.sh -source src/dev/ci_setup/checkout_sibling_es.sh - -case "$JOB" in -kibana-intake) - ./test/scripts/jenkins_unit.sh - ;; -kibana-ciGroup*) - export CI_GROUP="${JOB##kibana-ciGroup}" - ./test/scripts/jenkins_ci_group.sh - ;; -kibana-visualRegression*) - ./test/scripts/jenkins_visual_regression.sh - ;; -kibana-accessibility*) - ./test/scripts/jenkins_accessibility.sh - ;; -kibana-firefoxSmoke*) - ./test/scripts/jenkins_firefox_smoke.sh - ;; -x-pack-intake) - ./test/scripts/jenkins_xpack.sh - ;; -x-pack-ciGroup*) - export CI_GROUP="${JOB##x-pack-ciGroup}" - ./test/scripts/jenkins_xpack_ci_group.sh - ;; -x-pack-visualRegression*) - ./test/scripts/jenkins_xpack_visual_regression.sh - ;; -x-pack-accessibility*) - ./test/scripts/jenkins_xpack_accessibility.sh - ;; -x-pack-firefoxSmoke*) - ./test/scripts/jenkins_xpack_firefox_smoke.sh - ;; -*) - echo "JOB '$JOB' is not implemented." - exit 1 - ;; -esac diff --git a/Jenkinsfile b/Jenkinsfile index 86890042f1c19..bca451a1918ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,8 +11,8 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a catchError { retryable.enable() parallel([ - 'kibana-intake-agent': kibanaPipeline.legacyJobRunner('kibana-intake'), - 'x-pack-intake-agent': kibanaPipeline.legacyJobRunner('x-pack-intake'), + 'kibana-intake-agent': kibanaPipeline.intakeWorker('kibana-intake', './test/scripts/jenkins_unit.sh'), + 'x-pack-intake-agent': kibanaPipeline.intakeWorker('x-pack-intake', './test/scripts/jenkins_xpack.sh'), 'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [ 'oss-firefoxSmoke': kibanaPipeline.getPostBuildWorker('firefoxSmoke', { retryable('kibana-firefoxSmoke') { diff --git a/test/scripts/jenkins_accessibility.sh b/test/scripts/jenkins_accessibility.sh index 0b3d8dc3f85c2..c122d71b58edb 100755 --- a/test/scripts/jenkins_accessibility.sh +++ b/test/scripts/jenkins_accessibility.sh @@ -1,23 +1,6 @@ #!/usr/bin/env bash -set -e - -if [[ -n "$IS_PIPELINE_JOB" ]] ; then - source src/dev/ci_setup/setup_env.sh -fi - -export TEST_BROWSER_HEADLESS=1 - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - yarn run grunt functionalTests:ensureAllTestsInCiGroup; - node scripts/build --debug --oss; -else - installDir="$(realpath $PARENT_DIR/kibana/build/oss/kibana-*-SNAPSHOT-linux-x86_64)" - destDir=${installDir}-${CI_WORKER_NUMBER} - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi +source test/scripts/jenkins_test_setup_oss.sh checks-reporter-with-killswitch "Kibana accessibility tests" \ node scripts/functional_tests \ diff --git a/test/scripts/jenkins_ci_group.sh b/test/scripts/jenkins_ci_group.sh index cf001b230f80f..82d71cbdaae62 100755 --- a/test/scripts/jenkins_ci_group.sh +++ b/test/scripts/jenkins_ci_group.sh @@ -1,17 +1,6 @@ #!/usr/bin/env bash -source test/scripts/jenkins_test_setup.sh - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - yarn run grunt functionalTests:ensureAllTestsInCiGroup; - node scripts/build --debug --oss; -else - installDir="$(realpath $PARENT_DIR/kibana/build/oss/kibana-*-SNAPSHOT-linux-x86_64)" - destDir=${installDir}-${CI_WORKER_NUMBER} - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi +source test/scripts/jenkins_test_setup_oss.sh checks-reporter-with-killswitch "Functional tests / Group ${CI_GROUP}" yarn run grunt "run:functionalTests_ciGroup${CI_GROUP}"; @@ -20,4 +9,4 @@ if [ "$CI_GROUP" == "1" ]; then yarn run grunt run:pluginFunctionalTestsRelease --from=source; yarn run grunt run:exampleFunctionalTestsRelease --from=source; yarn run grunt run:interpreterFunctionalTestsRelease; -fi \ No newline at end of file +fi diff --git a/test/scripts/jenkins_firefox_smoke.sh b/test/scripts/jenkins_firefox_smoke.sh index 9a31f5f43d224..0129d4f1bce9f 100755 --- a/test/scripts/jenkins_firefox_smoke.sh +++ b/test/scripts/jenkins_firefox_smoke.sh @@ -1,22 +1,6 @@ #!/usr/bin/env bash -source test/scripts/jenkins_test_setup.sh - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - node scripts/build --debug --oss; - linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-oss-*-linux-x86_64.tar.gz')" - installDir="$PARENT_DIR/install/kibana" - mkdir -p "$installDir" - tar -xzf "$linuxBuild" -C "$installDir" --strip=1 -else - installDir="$(realpath $PARENT_DIR/kibana/build/oss/kibana-*-SNAPSHOT-linux-x86_64)" - destDir=${installDir}-${CI_WORKER_NUMBER} - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi - -export TEST_BROWSER_HEADLESS=1 +source test/scripts/jenkins_test_setup_oss.sh checks-reporter-with-killswitch "Firefox smoke test" \ node scripts/functional_tests \ diff --git a/test/scripts/jenkins_test_setup.sh b/test/scripts/jenkins_test_setup.sh index e2dd0bc276bb6..49ee8a6b526ca 100644 --- a/test/scripts/jenkins_test_setup.sh +++ b/test/scripts/jenkins_test_setup.sh @@ -1,11 +1,9 @@ +#!/usr/bin/env bash + set -e function post_work() { set +e - if [[ -z "$IS_PIPELINE_JOB" ]] ; then - node "$KIBANA_DIR/scripts/report_failed_tests" - fi - if [[ -z "$REMOVE_KIBANA_INSTALL_DIR" && -z "$KIBANA_INSTALL_DIR" && -d "$KIBANA_INSTALL_DIR" ]]; then rm -rf "$REMOVE_KIBANA_INSTALL_DIR" fi @@ -15,6 +13,4 @@ trap 'post_work' EXIT export TEST_BROWSER_HEADLESS=1 -if [[ -n "$IS_PIPELINE_JOB" ]] ; then - source src/dev/ci_setup/setup_env.sh -fi +source src/dev/ci_setup/setup_env.sh diff --git a/test/scripts/jenkins_test_setup_oss.sh b/test/scripts/jenkins_test_setup_oss.sh new file mode 100644 index 0000000000000..9e68272053221 --- /dev/null +++ b/test/scripts/jenkins_test_setup_oss.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +source test/scripts/jenkins_test_setup.sh + +if [[ -z "$CODE_COVERAGE" ]] ; then + installDir="$(realpath $PARENT_DIR/kibana/build/oss/kibana-*-SNAPSHOT-linux-x86_64)" + destDir=${installDir}-${CI_WORKER_NUMBER} + cp -R "$installDir" "$destDir" + + export KIBANA_INSTALL_DIR="$destDir" +fi diff --git a/test/scripts/jenkins_test_setup_xpack.sh b/test/scripts/jenkins_test_setup_xpack.sh new file mode 100644 index 0000000000000..76fc7cfe6c876 --- /dev/null +++ b/test/scripts/jenkins_test_setup_xpack.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +source test/scripts/jenkins_test_setup.sh + +if [[ -z "$CODE_COVERAGE" ]]; then + installDir="$PARENT_DIR/install/kibana" + destDir="${installDir}-${CI_WORKER_NUMBER}" + cp -R "$installDir" "$destDir" + + export KIBANA_INSTALL_DIR="$destDir" + + cd "$XPACK_DIR" +fi diff --git a/test/scripts/jenkins_unit.sh b/test/scripts/jenkins_unit.sh index 75610884b542f..b7fd955b6d123 100755 --- a/test/scripts/jenkins_unit.sh +++ b/test/scripts/jenkins_unit.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -set -e - -export TEST_BROWSER_HEADLESS=1 +source test/scripts/jenkins_test_setup.sh "$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:unit --dev; diff --git a/test/scripts/jenkins_visual_regression.sh b/test/scripts/jenkins_visual_regression.sh index 9ca1c0f08d2c9..dda966dea98d0 100755 --- a/test/scripts/jenkins_visual_regression.sh +++ b/test/scripts/jenkins_visual_regression.sh @@ -1,22 +1,8 @@ #!/usr/bin/env bash -source test/scripts/jenkins_test_setup.sh +source test/scripts/jenkins_test_setup_xpack.sh source "$KIBANA_DIR/src/dev/ci_setup/setup_percy.sh" -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - node scripts/build --debug --oss; - linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-oss-*-linux-x86_64.tar.gz')" - installDir="$PARENT_DIR/install/kibana" - mkdir -p "$installDir" - tar -xzf "$linuxBuild" -C "$installDir" --strip=1 -else - installDir="$(realpath $PARENT_DIR/kibana/build/oss/kibana-*-SNAPSHOT-linux-x86_64)" - destDir=${installDir}-${CI_WORKER_NUMBER} - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi - checks-reporter-with-killswitch "Kibana visual regression tests" \ yarn run percy exec -t 500 \ node scripts/functional_tests \ diff --git a/test/scripts/jenkins_xpack.sh b/test/scripts/jenkins_xpack.sh index 27f73c0b6e20d..695f85c7d607a 100755 --- a/test/scripts/jenkins_xpack.sh +++ b/test/scripts/jenkins_xpack.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash -set -e - -export TEST_BROWSER_HEADLESS=1 +source test/scripts/jenkins_test_setup.sh echo " -> Running mocha tests" cd "$XPACK_DIR" diff --git a/test/scripts/jenkins_xpack_accessibility.sh b/test/scripts/jenkins_xpack_accessibility.sh index af813c3c40f84..a3c03dd780886 100755 --- a/test/scripts/jenkins_xpack_accessibility.sh +++ b/test/scripts/jenkins_xpack_accessibility.sh @@ -1,32 +1,6 @@ #!/usr/bin/env bash -set -e - -if [[ -n "$IS_PIPELINE_JOB" ]] ; then - source src/dev/ci_setup/setup_env.sh -fi - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - echo " -> building and extracting default Kibana distributable for use in functional tests" - node scripts/build --debug --no-oss - - linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" - installDir="$PARENT_DIR/install/kibana" - - mkdir -p "$installDir" - tar -xzf "$linuxBuild" -C "$installDir" --strip=1 - - export KIBANA_INSTALL_DIR="$installDir" -else - installDir="$PARENT_DIR/install/kibana" - destDir="${installDir}-${CI_WORKER_NUMBER}" - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi - -export TEST_BROWSER_HEADLESS=1 -cd "$XPACK_DIR" +source test/scripts/jenkins_test_setup_xpack.sh checks-reporter-with-killswitch "X-Pack accessibility tests" \ node scripts/functional_tests \ diff --git a/test/scripts/jenkins_xpack_ci_group.sh b/test/scripts/jenkins_xpack_ci_group.sh index fba05f8f252d7..6b37d22cd2138 100755 --- a/test/scripts/jenkins_xpack_ci_group.sh +++ b/test/scripts/jenkins_xpack_ci_group.sh @@ -1,43 +1,6 @@ #!/usr/bin/env bash -source test/scripts/jenkins_test_setup.sh - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - echo " -> Ensuring all functional tests are in a ciGroup" - cd "$XPACK_DIR" - node scripts/functional_tests --assert-none-excluded \ - --include-tag ciGroup1 \ - --include-tag ciGroup2 \ - --include-tag ciGroup3 \ - --include-tag ciGroup4 \ - --include-tag ciGroup5 \ - --include-tag ciGroup6 \ - --include-tag ciGroup7 \ - --include-tag ciGroup8 \ - --include-tag ciGroup9 \ - --include-tag ciGroup10 -fi - -cd "$KIBANA_DIR" - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - echo " -> building and extracting default Kibana distributable for use in functional tests" - node scripts/build --debug --no-oss - - linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" - installDir="$PARENT_DIR/install/kibana" - - mkdir -p "$installDir" - tar -xzf "$linuxBuild" -C "$installDir" --strip=1 - - export KIBANA_INSTALL_DIR="$installDir" -else - installDir="$PARENT_DIR/install/kibana" - destDir="${installDir}-${CI_WORKER_NUMBER}" - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi +source test/scripts/jenkins_test_setup_xpack.sh echo " -> Running functional and api tests" cd "$XPACK_DIR" @@ -47,14 +10,3 @@ checks-reporter-with-killswitch "X-Pack Chrome Functional tests / Group ${CI_GRO --debug --bail \ --kibana-install-dir "$KIBANA_INSTALL_DIR" \ --include-tag "ciGroup$CI_GROUP" - -echo "" -echo "" - -# checks-reporter-with-killswitch "X-Pack Firefox Functional tests / Group ${CI_GROUP}" \ -# node scripts/functional_tests --debug --bail \ -# --kibana-install-dir "$installDir" \ -# --include-tag "ciGroup$CI_GROUP" \ -# --config "test/functional/config.firefox.js" -# echo "" -# echo "" diff --git a/test/scripts/jenkins_xpack_firefox_smoke.sh b/test/scripts/jenkins_xpack_firefox_smoke.sh index 43220459bcb97..5fe8b41cc0010 100755 --- a/test/scripts/jenkins_xpack_firefox_smoke.sh +++ b/test/scripts/jenkins_xpack_firefox_smoke.sh @@ -1,23 +1,6 @@ #!/usr/bin/env bash -source test/scripts/jenkins_test_setup.sh - -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - node scripts/build --debug --no-oss; - linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" - installDir="$PARENT_DIR/install/kibana" - mkdir -p "$installDir" - tar -xzf "$linuxBuild" -C "$installDir" --strip=1 - export KIBANA_INSTALL_DIR="$installDir" -else - installDir="$PARENT_DIR/install/kibana" - destDir="${installDir}-${CI_WORKER_NUMBER}" - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi - -cd "$XPACK_DIR" +source test/scripts/jenkins_test_setup_xpack.sh checks-reporter-with-killswitch "X-Pack firefox smoke test" \ node scripts/functional_tests \ diff --git a/test/scripts/jenkins_xpack_visual_regression.sh b/test/scripts/jenkins_xpack_visual_regression.sh index 5699f9e5ee7c1..6e3d4dd7c249b 100755 --- a/test/scripts/jenkins_xpack_visual_regression.sh +++ b/test/scripts/jenkins_xpack_visual_regression.sh @@ -1,25 +1,8 @@ #!/usr/bin/env bash -source test/scripts/jenkins_test_setup.sh +source test/scripts/jenkins_test_setup_xpack.sh source "$KIBANA_DIR/src/dev/ci_setup/setup_percy.sh" -if [[ -z "$IS_PIPELINE_JOB" ]] ; then - node scripts/build --debug --no-oss; - linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" - installDir="$PARENT_DIR/install/kibana" - mkdir -p "$installDir" - tar -xzf "$linuxBuild" -C "$installDir" --strip=1 - export KIBANA_INSTALL_DIR="$installDir" -else - installDir="$PARENT_DIR/install/kibana" - destDir="${installDir}-${CI_WORKER_NUMBER}" - cp -R "$installDir" "$destDir" - - export KIBANA_INSTALL_DIR="$destDir" -fi - -cd "$XPACK_DIR" - checks-reporter-with-killswitch "X-Pack visual regression tests" \ yarn run percy exec -t 500 \ node scripts/functional_tests \ diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index 3950071b81418..4924be4c0f0da 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -2,7 +2,7 @@ def withWorkers(machineName, preWorkerClosure = {}, workerClosures = [:]) { return { jobRunner('tests-xl', true) { withGcsArtifactUpload(machineName, { - try { + withPostBuildReporting { doSetup() preWorkerClosure() @@ -26,24 +26,53 @@ def withWorkers(machineName, preWorkerClosure = {}, workerClosures = [:]) { } parallel(workers) - } finally { - catchError { - runErrorReporter() - } - - catchError { - runbld.junit() - } - - catchError { - publishJunit() - } } }) } } } +def withWorker(machineName, label, Closure closure) { + return { + jobRunner(label, false) { + withGcsArtifactUpload(machineName) { + withPostBuildReporting { + doSetup() + closure() + } + } + } + } +} + +def intakeWorker(jobName, String script) { + return withWorker(jobName, 'linux && immutable') { + withEnv([ + "JOB=${jobName}", + ]) { + runbld(script, "Execute ${jobName}") + } + } +} + +def withPostBuildReporting(Closure closure) { + try { + closure() + } finally { + catchError { + runErrorReporter() + } + + catchError { + runbld.junit() + } + + catchError { + publishJunit() + } + } +} + def getPostBuildWorker(name, closure) { return { workerNumber -> def kibanaPort = "61${workerNumber}1" @@ -90,34 +119,6 @@ def getXpackCiGroupWorker(ciGroup) { }) } -def legacyJobRunner(name) { - return { - parallel([ - "${name}": { - withEnv([ - "JOB=${name}", - ]) { - jobRunner('linux && immutable', false) { - withGcsArtifactUpload(name, { - try { - runbld('.ci/run.sh', "Execute ${name}", true) - } finally { - catchError { - runErrorReporter() - } - - catchError { - publishJunit() - } - } - }) - } - } - } - ]) - } -} - def jobRunner(label, useRamDisk, closure) { node(label) { agentInfo.print() @@ -168,8 +169,6 @@ def jobRunner(label, useRamDisk, closure) { } } -// TODO what should happen if GCS, Junit, or email publishing fails? Unstable build? Failed build? - def uploadGcsArtifact(uploadPrefix, pattern) { googleStorageUpload( credentialsId: 'kibana-ci-gcs-plugin', From 85b02e27b90765f30bcf5c0da27d6a6a4b0156a1 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Tue, 28 Jan 2020 16:57:39 -0500 Subject: [PATCH 6/6] Fix failing snapshot artifact tests when using env var (#56063) (#56173) --- packages/kbn-es/src/artifact.test.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/kbn-es/src/artifact.test.js b/packages/kbn-es/src/artifact.test.js index 985b65c747563..453eb1a9a7689 100644 --- a/packages/kbn-es/src/artifact.test.js +++ b/packages/kbn-es/src/artifact.test.js @@ -52,21 +52,22 @@ const createArchive = (params = {}) => { const mockFetch = mock => fetch.mockReturnValue(Promise.resolve(new Response(JSON.stringify(mock)))); -let previousSnapshotManifestValue = null; +const previousEnvVars = {}; +const ENV_VARS_TO_RESET = ['ES_SNAPSHOT_MANIFEST', 'KBN_ES_SNAPSHOT_USE_UNVERIFIED']; beforeAll(() => { - if ('ES_SNAPSHOT_MANIFEST' in process.env) { - previousSnapshotManifestValue = process.env.ES_SNAPSHOT_MANIFEST; - delete process.env.ES_SNAPSHOT_MANIFEST; - } + ENV_VARS_TO_RESET.forEach(key => { + if (key in process.env) { + previousEnvVars[key] = process.env[key]; + delete process.env[key]; + } + }); }); afterAll(() => { - if (previousSnapshotManifestValue !== null) { - process.env.ES_SNAPSHOT_MANIFEST = previousSnapshotManifestValue; - } else { - delete process.env.ES_SNAPSHOT_MANIFEST; - } + Object.keys(previousEnvVars).forEach(key => { + process.env[key] = previousEnvVars[key]; + }); }); beforeEach(() => {