Skip to content

Commit

Permalink
Merge branch 'master' into enable-sr-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jan 3, 2020
2 parents 3e7c963 + b09653a commit 078864e
Show file tree
Hide file tree
Showing 160 changed files with 9,175 additions and 5,581 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,6 @@ module.exports = {
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['x-pack/legacy/plugins/uptime/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'react-hooks/rules-of-hooks': 'off',
},
},

/**
* Files that require Apache 2.0 headers, settings
Expand Down
261 changes: 261 additions & 0 deletions docs/canvas/canvas-expression-lifecycle.asciidoc

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/maps/maps-aggregations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ To enable top hits:
. Set *Entity* to the field that identifies entities in your documents.
This field will be used in the terms aggregation to group your documents into entity buckets.
. Set *Documents per entity* to configure the maximum number of documents accumulated per entity.
This setting is limited to the `index.max_inner_result_window` index setting, which defaults to 100.

[role="screenshot"]
image::maps/images/top_hits.png[]
Expand Down
2 changes: 1 addition & 1 deletion docs/maps/vector-layer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See map.regionmap.* in <<settings>> for details.
*Documents*:: Vector data from a Kibana index pattern.
The index must contain at least one field mapped as {ref}/geo-point.html[geo_point] or {ref}/geo-shape.html[geo_shape].

NOTE: Document results are limited to the first 10000 matching documents.
NOTE: Document results are limited to the `index.max_result_window` index setting, which defaults to 10000.
Use <<maps-aggregations, aggregations>> to plot large data sets.

*Grid aggregation*:: Geospatial data grouped in grids with metrics for each gridded cell.
Expand Down
4 changes: 3 additions & 1 deletion docs/user/canvas.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ include::{kib-repo-dir}/canvas/canvas-present-workpad.asciidoc[]

include::{kib-repo-dir}/canvas/canvas-share-workpad.asciidoc[]

include::{kib-repo-dir}/canvas/canvas-expression-lifecycle.asciidoc[]

include::{kib-repo-dir}/canvas/canvas-function-reference.asciidoc[]

include::{kib-repo-dir}/canvas/canvas-tinymath-functions.asciidoc[]
include::{kib-repo-dir}/canvas/canvas-tinymath-functions.asciidoc[]
14 changes: 13 additions & 1 deletion test/common/fixtures/plugins/newsfeed/newsfeed_simulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const mockNewsfeed = (version: string) => ({
badge: null,
image_url: null,
publish_on: '2019-06-21T00:00:00',
expire_on: '2019-12-31T00:00:00',
expire_on: '2040-01-31T00:00:00',
hash: '39ca7d409c7eb25f4c69a5a6a11309b2f5ced7ca3f9b3a0109517126e0fd91ca',
},
{
Expand All @@ -100,6 +100,18 @@ const mockNewsfeed = (version: string) => ({
badge: null,
image_url: null,
publish_on: '2019-06-21T00:00:00',
expire_on: '2040-01-31T00:00:00',
hash: 'db445c9443eb50ea2eb15f20edf89cf0f7dac2b058b11cafc2c8c288b6e4ce2a',
},
{
title: { en: 'This item is expired!' },
description: { en: 'This should not show up.' },
link_text: { en: 'Generic feed-viewer could go here' },
link_url: { en: 'https://feeds-staging.elastic.co' },
languages: null,
badge: null,
image_url: null,
publish_on: '2019-06-21T00:00:00',
expire_on: '2019-12-31T00:00:00',
hash: 'db445c9443eb50ea2eb15f20edf89cf0f7dac2b058b11cafc2c8c288b6e4ce2a',
},
Expand Down
3 changes: 1 addition & 2 deletions test/functional/apps/home/_newsfeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
const globalNav = getService('globalNav');
const PageObjects = getPageObjects(['common', 'newsfeed']);

// Failing: https://github.com/elastic/kibana/issues/53860
describe.skip('Newsfeed', () => {
describe('Newsfeed', () => {
before(async () => {
await PageObjects.newsfeed.resetPage();
});
Expand Down
87 changes: 72 additions & 15 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
const defaultTryTimeout = config.get('timeouts.try');
const defaultFindTimeout = config.get('timeouts.find');

interface NavigateProps {
appConfig: {};
ensureCurrentUrl: boolean;
shouldLoginIfPrompted: boolean;
shouldAcceptAlert: boolean;
useActualUrl: boolean;
}

class CommonPage {
/**
* Navigates the browser window to provided URL
Expand Down Expand Up @@ -115,6 +123,34 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
return currentUrl;
}

private async navigate(navigateProps: NavigateProps) {
const {
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
} = navigateProps;
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);

await retry.try(async () => {
if (useActualUrl) {
log.debug(`navigateToActualUrl ${appUrl}`);
await browser.get(appUrl);
} else {
await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
}

const currentUrl = shouldLoginIfPrompted
? await this.loginIfPrompted(appUrl)
: await browser.getCurrentUrl();

if (ensureCurrentUrl && !currentUrl.includes(appUrl)) {
throw new Error(`expected ${currentUrl}.includes(${appUrl})`);
}
});
}

/**
* Navigates browser using the pathname from the appConfig and subUrl as the hash
* @param appName As defined in the apps config, e.g. 'home'
Expand All @@ -137,23 +173,44 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
hash: useActualUrl ? subUrl : `/${appName}/${subUrl}`,
};

const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);

await retry.try(async () => {
if (useActualUrl) {
log.debug(`navigateToActualUrl ${appUrl}`);
await browser.get(appUrl);
} else {
await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
}
await this.navigate({
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
});
}

const currentUrl = shouldLoginIfPrompted
? await this.loginIfPrompted(appUrl)
: await browser.getCurrentUrl();
/**
* Navigates browser using the pathname from the appConfig and subUrl as the extended path.
* This was added to be able to test an application that uses browser history over hash history.
* @param appName As defined in the apps config, e.g. 'home'
* @param subUrl The route after the appUrl, e.g. 'tutorial_directory/sampleData'
* @param args additional arguments
*/
public async navigateToUrlWithBrowserHistory(
appName: string,
subUrl?: string,
{
basePath = '',
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
shouldAcceptAlert = true,
useActualUrl = true,
} = {}
) {
const appConfig = {
// subUrl following the basePath, assumes no hashes. Ex: 'app/endpoint/management'
pathname: `${basePath}${config.get(['apps', appName]).pathname}${subUrl}`,
};

if (ensureCurrentUrl && !currentUrl.includes(appUrl)) {
throw new Error(`expected ${currentUrl}.includes(${appUrl})`);
}
await this.navigate({
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
shouldAcceptAlert,
useActualUrl,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { taskManagerMock } from '../../task_manager/task_manager.mock';
import { taskManagerMock } from '../../task_manager/server/task_manager.mock';
import { ActionTypeRegistry } from './action_type_registry';
import { ExecutorType } from './types';
import { ActionExecutor, ExecutorError, TaskRunnerFactory } from './lib';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import Boom from 'boom';
import { i18n } from '@kbn/i18n';
import { TaskManagerSetupContract } from './shim';
import { RunContext } from '../../task_manager';
import { RunContext } from '../../task_manager/server';
import { ExecutorError, TaskRunnerFactory } from './lib';
import { ActionType } from './types';
import { ActionsConfigurationUtilities } from './actions_config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ActionTypeRegistry } from './action_type_registry';
import { ActionsClient } from './actions_client';
import { ExecutorType } from './types';
import { ActionExecutor, TaskRunnerFactory } from './lib';
import { taskManagerMock } from '../../task_manager/task_manager.mock';
import { taskManagerMock } from '../../task_manager/server/task_manager.mock';
import { configUtilsMock } from './actions_config.mock';
import { getActionsConfigurationUtilities } from './actions_config';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { ActionExecutor, TaskRunnerFactory } from '../lib';
import { ActionTypeRegistry } from '../action_type_registry';
import { taskManagerMock } from '../../../task_manager/task_manager.mock';
import { taskManagerMock } from '../../../task_manager/server/task_manager.mock';
import { registerBuiltInActionTypes } from './index';
import { Logger } from '../../../../../../src/core/server';
import { loggingServiceMock } from '../../../../../../src/core/server/mocks';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 { withoutControlCharacters } from './string_utils';

describe('ensureSingleLineString()', () => {
test('works with plain ole strings', () => {
expect(withoutControlCharacters('')).toEqual('');
expect(withoutControlCharacters(' a b c ')).toEqual(' a b c ');
});

test('works with multiple control characters', () => {
expect(withoutControlCharacters(' \r \n ')).toEqual(' ; ; ');
expect(withoutControlCharacters('\r \n ')).toEqual('; ; ');
expect(withoutControlCharacters(' \r \n')).toEqual(' ; ;');
expect(withoutControlCharacters('\r \n')).toEqual('; ;');
});

test('works with /00-/1F, except tab', () => {
for (let c = 0; c <= 0x1f; c++) {
if (c === 0x09) {
expect(withoutControlCharacters(String.fromCharCode(c))).toEqual('\t');
} else {
expect(withoutControlCharacters(String.fromCharCode(c))).toEqual(';');
}
}
expect(withoutControlCharacters(String.fromCharCode(0x20))).toEqual(' ');
});

test('works with /7F-/9F', () => {
expect(withoutControlCharacters(String.fromCharCode(0x7e))).toEqual('~');
for (let c = 0x7f; c <= 0x9f; c++) {
expect(withoutControlCharacters(String.fromCharCode(c))).toEqual(';');
}
const nbsp = String.fromCharCode(0xa0);
expect(withoutControlCharacters(nbsp)).toEqual(nbsp);
});

test('works with UCS newlines', () => {
expect(withoutControlCharacters('\u2027')).toEqual('\u2027');
expect(withoutControlCharacters('\u2028')).toEqual(';');
expect(withoutControlCharacters('\u2029')).toEqual(';');
expect(withoutControlCharacters('\u202A')).toEqual('\u202A');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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.
*/

// see: https://en.wikipedia.org/wiki/Unicode_control_characters
// but don't include tabs (0x09), they're fine
const CONTROL_CHAR_PATTERN = /[\x00-\x08]|[\x0A-\x1F]|[\x7F-\x9F]|[\u2028-\u2029]/g;

// replaces control characters in string with ;, but leaves tabs
export function withoutControlCharacters(s: string): string {
return s.replace(CONTROL_CHAR_PATTERN, ';');
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ describe('execute()', () => {
config: {},
secrets: {},
});
expect(mockedLogger.info).toHaveBeenCalledWith('message text here');
expect(mockedLogger.info).toHaveBeenCalledWith('server-log: message text here');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,34 @@ import { schema, TypeOf } from '@kbn/config-schema';

import { Logger } from '../../../../../../src/core/server';
import { ActionType, ActionTypeExecutorOptions, ActionTypeExecutorResult } from '../types';
import { withoutControlCharacters } from './lib/string_utils';

const ACTION_NAME = 'server-log';

// params definition

export type ActionParamsType = TypeOf<typeof ParamsSchema>;

const ParamsSchema = schema.object({
message: schema.string(),
level: schema.oneOf([
schema.literal('trace'),
schema.literal('debug'),
schema.literal('info'),
schema.literal('warn'),
schema.literal('error'),
schema.literal('fatal'),
]),
level: schema.oneOf(
[
schema.literal('trace'),
schema.literal('debug'),
schema.literal('info'),
schema.literal('warn'),
schema.literal('error'),
schema.literal('fatal'),
],
{ defaultValue: 'info' }
),
});

// action type definition
export function getActionType({ logger }: { logger: Logger }): ActionType {
return {
id: '.server-log',
name: 'server-log',
name: ACTION_NAME,
validate: {
params: ParamsSchema,
},
Expand All @@ -48,8 +54,9 @@ async function executor(
const actionId = execOptions.actionId;
const params = execOptions.params as ActionParamsType;

const sanitizedMessage = withoutControlCharacters(params.message);
try {
logger[params.level](params.message);
logger[params.level](`${ACTION_NAME}: ${sanitizedMessage}`);
} catch (err) {
const message = i18n.translate('xpack.actions.builtin.serverLog.errorLoggingErrorMessage', {
defaultMessage: 'error logging message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { taskManagerMock } from '../../task_manager/task_manager.mock';
import { taskManagerMock } from '../../task_manager/server/task_manager.mock';
import { createExecuteFunction } from './create_execute_function';
import { savedObjectsClientMock } from '../../../../../src/core/server/mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sinon from 'sinon';
import { ExecutorError } from './executor_error';
import { ActionExecutor } from './action_executor';
import { ConcreteTaskInstance, TaskStatus } from '../../../task_manager';
import { ConcreteTaskInstance, TaskStatus } from '../../../task_manager/server';
import { TaskRunnerFactory } from './task_runner_factory';
import { actionTypeRegistryMock } from '../action_type_registry.mock';
import { actionExecutorMock } from './action_executor.mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { ActionExecutorContract } from './action_executor';
import { ExecutorError } from './executor_error';
import { RunContext } from '../../../task_manager';
import { RunContext } from '../../../task_manager/server';
import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../../../plugins/encrypted_saved_objects/server';
import { ActionTaskParams, GetBasePathFunction, SpaceIdToNamespaceFunction } from '../types';

Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Plugin {
private licenseState: LicenseState | null = null;

constructor(initializerContext: ActionsPluginInitializerContext) {
this.logger = initializerContext.logger.get('plugins', 'alerting');
this.logger = initializerContext.logger.get('plugins', 'actions');
this.config$ = initializerContext.config.create();
this.kibana$ = initializerContext.config.kibana$;
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/server/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Hapi from 'hapi';
import { Legacy } from 'kibana';
import * as Rx from 'rxjs';
import { ActionsConfigType } from './types';
import { TaskManager } from '../../task_manager';
import { TaskManager } from '../../task_manager/server';
import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
import KbnServer from '../../../../../src/legacy/server/kbn_server';
import { LegacySpacesPlugin as SpacesPluginStartContract } from '../../spaces';
Expand Down
Loading

0 comments on commit 078864e

Please sign in to comment.