Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into fix/kbn-es-sh…
Browse files Browse the repository at this point in the history
…ort-test-timeout
  • Loading branch information
spalger committed Jun 15, 2020
2 parents a171a7e + a7900d0 commit 086a250
Show file tree
Hide file tree
Showing 33 changed files with 115 additions and 315 deletions.
30 changes: 21 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ Distributable packages can be found in `target/` after the build completes.
Kibana documentation is written in [asciidoc](http://asciidoc.org/) format in
the `docs/` directory.

To build the docs, you must clone the [elastic/docs](https://github.com/elastic/docs)
repo as a sibling of your kibana repo. Follow the instructions in that project's
To build the docs, clone the [elastic/docs](https://github.com/elastic/docs)
repo as a sibling of your Kibana repo. Follow the instructions in that project's
README for getting the docs tooling set up.

**To build the Kibana docs and open them in your browser:**
Expand All @@ -676,14 +676,26 @@ node scripts/docs.js --open

Part of this process only applies to maintainers, since it requires access to GitHub labels.

Kibana publishes [Release Notes](https://www.elastic.co/guide/en/kibana/current/release-notes.html) for major and minor releases. To generate the Release Notes, the writers run a script against this repo to collect the merged PRs against the release.
To include your PRs in the Release Notes:
Kibana publishes [Release Notes](https://www.elastic.co/guide/en/kibana/current/release-notes.html) for major and minor releases. The Release Notes summarize what the PRs accomplish in language that is meaningful to users. To generate the Release Notes, the team runs a script against this repo to collect the merged PRs against the release.

1. In the title, summarize what the PR accomplishes in language that is meaningful to the user. In general, use present tense (for example, Adds, Fixes) in sentence case.
2. Label the PR with the targeted version (ex: `v7.3.0`).
3. Label the PR with the appropriate GitHub labels:
#### Create the Release Notes text
The text that appears in the Release Notes is pulled directly from your PR title, or a single paragraph of text that you specify in the PR description.

To use a single paragraph of text, enter `Release note:` or a `## Release note` header in the PR description, followed by your text. For example, refer to this [PR](https://github.com/elastic/kibana/pull/65796) that uses the `## Release note` header.

When you create the Release Notes text, use the following best practices:
* Use present tense.
* Use sentence case.
* When you create a feature PR, start with `Adds`.
* When you create an enhancement PR, start with `Improves`.
* When you create a bug fix PR, start with `Fixes`.
* When you create a deprecation PR, start with `Deprecates`.

#### Add your labels
1. Label the PR with the targeted version (ex: `v7.3.0`).
2. Label the PR with the appropriate GitHub labels:
* For a new feature or functionality, use `release_note:enhancement`.
* For an external-facing fix, use `release_note:fix`. Exception: docs, build, and test fixes do not go in the Release Notes. Neither fixes for issues that were only on `master` and never have been released.
* For an external-facing fix, use `release_note:fix`. We do not include docs, build, and test fixes in the Release Notes, or unreleased issues that are only on `master`.
* For a deprecated feature, use `release_note:deprecation`.
* For a breaking change, use `release_note:breaking`.
* To **NOT** include your changes in the Release Notes, use `release_note:skip`.
Expand All @@ -695,7 +707,7 @@ We also produce a blog post that details more important breaking API changes in
## Name the feature with the break (ex: Visualize Loader)
Summary of the change. Anything Under `#Dev Docs` will be used in the blog.
Summary of the change. Anything Under `#Dev Docs` is used in the blog.
```

## Signing the contributor license agreement
Expand Down
32 changes: 32 additions & 0 deletions src/core/server/plugins/plugins_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { PluginWrapper } from './plugin';
import { PluginName } from './types';
import { PluginsSystem } from './plugins_system';
import { coreMock } from '../mocks';
import { Logger } from '../logging';

const logger = loggingServiceMock.create();
function createPlugin(
Expand Down Expand Up @@ -435,6 +436,21 @@ describe('setup', () => {
`[Error: Setup lifecycle of "timeout-setup" plugin wasn't completed in 30sec. Consider disabling the plugin and re-start.]`
);
});

it('logs only server-side plugins', async () => {
[
createPlugin('order-0'),
createPlugin('order-not-run', { server: false }),
createPlugin('order-1'),
].forEach((plugin, index) => {
jest.spyOn(plugin, 'setup').mockResolvedValue(`setup-as-${index}`);
jest.spyOn(plugin, 'start').mockResolvedValue(`started-as-${index}`);
pluginsSystem.addPlugin(plugin);
});
await pluginsSystem.setupPlugins(setupDeps);
const log = logger.get.mock.results[0].value as jest.Mocked<Logger>;
expect(log.info).toHaveBeenCalledWith(`Setting up [2] plugins: [order-1,order-0]`);
});
});

describe('start', () => {
Expand All @@ -461,4 +477,20 @@ describe('start', () => {
`[Error: Start lifecycle of "timeout-start" plugin wasn't completed in 30sec. Consider disabling the plugin and re-start.]`
);
});

it('logs only server-side plugins', async () => {
[
createPlugin('order-0'),
createPlugin('order-not-run', { server: false }),
createPlugin('order-1'),
].forEach((plugin, index) => {
jest.spyOn(plugin, 'setup').mockResolvedValue(`setup-as-${index}`);
jest.spyOn(plugin, 'start').mockResolvedValue(`started-as-${index}`);
pluginsSystem.addPlugin(plugin);
});
await pluginsSystem.setupPlugins(setupDeps);
await pluginsSystem.startPlugins(startDeps);
const log = logger.get.mock.results[0].value as jest.Mocked<Logger>;
expect(log.info).toHaveBeenCalledWith(`Starting [2] plugins: [order-1,order-0]`);
});
});
17 changes: 9 additions & 8 deletions src/core/server/plugins/plugins_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ export class PluginsSystem {
return contracts;
}

const sortedPlugins = this.getTopologicallySortedPluginNames();
this.log.info(`Setting up [${this.plugins.size}] plugins: [${[...sortedPlugins]}]`);

for (const pluginName of sortedPlugins) {
const plugin = this.plugins.get(pluginName)!;
if (!plugin.includesServerPlugin) {
continue;
}
const sortedPlugins = new Map(
[...this.getTopologicallySortedPluginNames()]
.map((pluginName) => [pluginName, this.plugins.get(pluginName)!] as [string, PluginWrapper])
.filter(([pluginName, plugin]) => plugin.includesServerPlugin)
);
this.log.info(
`Setting up [${sortedPlugins.size}] plugins: [${[...sortedPlugins.keys()].join(',')}]`
);

for (const [pluginName, plugin] of sortedPlugins) {
this.log.debug(`Setting up plugin "${pluginName}"...`);
const pluginDeps = new Set([...plugin.requiredPlugins, ...plugin.optionalPlugins]);
const pluginDepContracts = Array.from(pluginDeps).reduce((depContracts, dependencyName) => {
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/security_solution/common/endpoint/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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 const eventsIndexPattern = 'events-endpoint-*';
export const metadataIndexPattern = 'metrics-endpoint.metadata-*';
export const policyIndexPattern = 'metrics-endpoint.policy-*';
export const telemetryIndexPattern = 'metrics-endpoint.telemetry-*';
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ export class AlertConstants {
* The prefix for all Alert APIs
*/
static BASE_API_URL = '/api/endpoint';
/**
* The path for the Alert's Index Pattern API.
*/
static INDEX_PATTERN_ROUTE = `${AlertConstants.BASE_API_URL}/index_pattern`;
/**
* A paramter passed to Alert's Index Pattern.
*/
static EVENT_DATASET = 'events';
/**
* Alert's Search API default page size
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { eventsIndexPattern } from '../../../common/endpoint/constants';
import { IIndexPattern } from '../../../../../../src/plugins/data/public';
import {
AlertResultList,
AlertDetails,
AlertListState,
} from '../../../common/endpoint_alerts/types';
import { AlertConstants } from '../../../common/endpoint_alerts/alert_constants';
import { ImmutableMiddlewareFactory } from '../../common/store';
import { cloneHttpFetchQuery } from '../../common/utils/clone_http_fetch_query';
import {
Expand All @@ -27,14 +27,11 @@ export const alertMiddlewareFactory: ImmutableMiddlewareFactory<AlertListState>
) => {
async function fetchIndexPatterns(): Promise<IIndexPattern[]> {
const { indexPatterns } = depsStart.data;
const eventsPattern: { indexPattern: string } = await coreStart.http.get(
`${AlertConstants.INDEX_PATTERN_ROUTE}/${AlertConstants.EVENT_DATASET}`
);
const fields = await indexPatterns.getFieldsForWildcard({
pattern: eventsPattern.indexPattern,
pattern: eventsIndexPattern,
});
const indexPattern: IIndexPattern = {
title: eventsPattern.indexPattern,
title: eventsIndexPattern,
fields,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../../../../../../../src/core/server/mocks';
import { registerAlertRoutes } from '../routes';
import { alertingIndexGetQuerySchema } from '../../../../common/endpoint_alerts/schema/alert_index';
import { createMockAgentService, createMockIndexPatternRetriever } from '../../mocks';
import { createMockAgentService } from '../../mocks';
import { EndpointAppContextService } from '../../endpoint_app_context_services';
import { createMockConfig } from '../../../lib/detection_engine/routes/__mocks__';

Expand All @@ -29,7 +29,6 @@ describe('test alerts route', () => {

endpointAppContextService = new EndpointAppContextService();
endpointAppContextService.start({
indexPatternRetriever: createMockIndexPatternRetriever('events-endpoint-*'),
agentService: createMockAgentService(),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import { GetResponse } from 'elasticsearch';
import { KibanaRequest, RequestHandler } from 'kibana/server';
import { eventsIndexPattern } from '../../../../../common/endpoint/constants';
import { AlertEvent } from '../../../../../common/endpoint/types';
import { EndpointAppContext } from '../../../types';
import { AlertDetailsRequestParams } from '../../../../../common/endpoint_alerts/types';
Expand All @@ -27,17 +28,13 @@ export const alertDetailsHandlerWrapper = function (
id: alertId.id,
})) as GetResponse<AlertEvent>;

const indexPattern = await endpointAppContext.service
.getIndexPatternRetriever()
.getEventIndexPattern(ctx);

const config = await endpointAppContext.config();
const pagination: AlertDetailsPagination = new AlertDetailsPagination(
config,
ctx,
req.params,
response,
indexPattern
eventsIndexPattern
);

const currentHostInfo = await getHostData(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { RequestHandler } from 'kibana/server';
import { eventsIndexPattern } from '../../../../../common/endpoint/constants';
import { EndpointAppContext } from '../../../types';
import { searchESForAlerts } from '../lib';
import { getRequestData, mapToAlertResultList } from './lib';
Expand All @@ -18,14 +19,11 @@ export const alertListHandlerWrapper = function (
res
) => {
try {
const indexPattern = await endpointAppContext.service
.getIndexPatternRetriever()
.getEventIndexPattern(ctx);
const reqData = await getRequestData(req, endpointAppContext);
const response = await searchESForAlerts(
ctx.core.elasticsearch.legacy.client,
reqData,
indexPattern
eventsIndexPattern
);
const mappedBody = await mapToAlertResultList(ctx, endpointAppContext, reqData, response);
return res.ok({ body: mappedBody });
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions x-pack/plugins/security_solution/server/endpoint/alerts/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { alertListHandlerWrapper } from './handlers/list';
import { alertDetailsHandlerWrapper } from './handlers/details';
import { alertDetailsReqSchema } from './handlers/details/schemas';
import { alertingIndexGetQuerySchema } from '../../../common/endpoint_alerts/schema/alert_index';
import { indexPatternGetParamsSchema } from '../../../common/endpoint_alerts/schema/index_pattern';
import { handleIndexPattern } from './handlers/index_pattern';

export const BASE_ALERTS_ROUTE = `${AlertConstants.BASE_API_URL}/alerts`;

Expand All @@ -37,15 +35,4 @@ export function registerAlertRoutes(router: IRouter, endpointAppContext: Endpoin
},
alertDetailsHandlerWrapper(endpointAppContext)
);

const log = endpointAppContext.logFactory.get('index_pattern');

router.get(
{
path: `${AlertConstants.INDEX_PATTERN_ROUTE}/{datasetPath}`,
validate: { params: indexPatternGetParamsSchema },
options: { authRequired: true },
},
handleIndexPattern(log, endpointAppContext)
);
}
Loading

0 comments on commit 086a250

Please sign in to comment.