Skip to content

Commit

Permalink
Merge branch 'master' into fix/86278
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 11, 2021
2 parents a1aab98 + facdd55 commit 84e67e7
Show file tree
Hide file tree
Showing 206 changed files with 7,980 additions and 3,151 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ snapshots.js
/src/core/lib/kbn_internal_native_observable
/src/legacy/plugin_discovery/plugin_pack/__tests__/fixtures/plugins/broken
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
/src/plugins/vis_type_timelion/public/_generated_/**
/src/plugins/vis_type_timelion/common/_generated_/**
/x-pack/legacy/plugins/**/__tests__/fixtures/**
/x-pack/plugins/apm/e2e/tmp/*
/x-pack/plugins/canvas/canvas_plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
| [noSearchSessionStorageCapabilityMessage](./kibana-plugin-plugins-data-public.nosearchsessionstoragecapabilitymessage.md) | Message to display in case storing session session is disabled due to turned off capability |
| [parseSearchSourceJSON](./kibana-plugin-plugins-data-public.parsesearchsourcejson.md) | |
| [QueryStringInput](./kibana-plugin-plugins-data-public.querystringinput.md) | |
| [SEARCH\_SESSIONS\_MANAGEMENT\_ID](./kibana-plugin-plugins-data-public.search_sessions_management_id.md) | |
| [search](./kibana-plugin-plugins-data-public.search.md) | |
| [SearchBar](./kibana-plugin-plugins-data-public.searchbar.md) | |
| [syncQueryStateWithUrl](./kibana-plugin-plugins-data-public.syncquerystatewithurl.md) | Helper to setup syncing of global data with the URL |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [SEARCH\_SESSIONS\_MANAGEMENT\_ID](./kibana-plugin-plugins-data-public.search_sessions_management_id.md)

## SEARCH\_SESSIONS\_MANAGEMENT\_ID variable

<b>Signature:</b>

```typescript
SEARCH_SESSIONS_MANAGEMENT_ID = "search_sessions"
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ Because by default tasks are polled at 3 second intervals and only 10 tasks can
For details on the settings that can influence the performance and throughput of Task Manager, see {task-manager-settings}.
==============================================
==============================================

[float]
=== Deployment considerations

{es} and {kib} instances use the system clock to determine the current time. To ensure schedules are triggered when expected, you should synchronize the clocks of all nodes in the cluster using a time service such as http://www.ntp.org/[Network Time Protocol].
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pageLoadAssetSize:
visTypeMetric: 42790
visTypeTable: 94934
visTypeTagcloud: 37575
visTypeTimelion: 51933
visTypeTimelion: 68883
visTypeTimeseries: 155203
visTypeVega: 153573
visTypeVislib: 242838
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ describe('RollingFileAppender', () => {
});

afterEach(async () => {
try {
await rmdir(testDir);
} catch (e) {
/* trap */
if (testDir) {
await rmdir(testDir, { recursive: true });
}

if (root) {
await root.shutdown();
}
Expand Down
77 changes: 31 additions & 46 deletions src/core/server/plugins/discovery/plugin_manifest_parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import { mockReadFile } from './plugin_manifest_parser.test.mocks';

import { PluginDiscoveryErrorType } from './plugin_discovery_error';
import { loggingSystemMock } from '../../logging/logging_system.mock';

import { resolve } from 'path';
import { parseManifest } from './plugin_manifest_parser';

const logger = loggingSystemMock.createLogger();
const pluginPath = resolve('path', 'existent-dir');
const pluginManifestPath = resolve(pluginPath, 'kibana.json');
const packageInfo = {
Expand All @@ -34,7 +32,7 @@ test('return error when manifest is empty', async () => {
cb(null, Buffer.from(''));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Unexpected end of JSON input (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -46,7 +44,7 @@ test('return error when manifest content is null', async () => {
cb(null, Buffer.from('null'));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin manifest must contain a JSON encoded object. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -58,7 +56,7 @@ test('return error when manifest content is not a valid JSON', async () => {
cb(null, Buffer.from('not-json'));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Unexpected token o in JSON at position 1 (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -70,7 +68,7 @@ test('return error when plugin id is missing', async () => {
cb(null, Buffer.from(JSON.stringify({ version: 'some-version' })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin manifest must contain an "id" property. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -82,45 +80,32 @@ test('return error when plugin id includes `.` characters', async () => {
cb(null, Buffer.from(JSON.stringify({ id: 'some.name', version: 'some-version' })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin "id" must not include \`.\` characters. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
});
});

test('logs warning if pluginId is not in camelCase format', async () => {
test('return error when pluginId is not in camelCase format', async () => {
expect.assertions(1);
mockReadFile.mockImplementation((path, cb) => {
cb(null, Buffer.from(JSON.stringify({ id: 'some_name', version: 'kibana', server: true })));
});

expect(loggingSystemMock.collect(logger).warn).toHaveLength(0);
await parseManifest(pluginPath, packageInfo, logger);
expect(loggingSystemMock.collect(logger).warn).toMatchInlineSnapshot(`
Array [
Array [
"Expect plugin \\"id\\" in camelCase, but found: some_name",
],
]
`);
});

test('does not log pluginId format warning in dist mode', async () => {
mockReadFile.mockImplementation((path, cb) => {
cb(null, Buffer.from(JSON.stringify({ id: 'some_name', version: 'kibana', server: true })));
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin "id" must be camelCase, but found: some_name. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
});

expect(loggingSystemMock.collect(logger).warn).toHaveLength(0);
await parseManifest(pluginPath, { ...packageInfo, dist: true }, logger);
expect(loggingSystemMock.collect(logger).warn.length).toBe(0);
});

test('return error when plugin version is missing', async () => {
mockReadFile.mockImplementation((path, cb) => {
cb(null, Buffer.from(JSON.stringify({ id: 'someId' })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin manifest for "someId" must contain a "version" property. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -132,7 +117,7 @@ test('return error when plugin expected Kibana version is lower than actual vers
cb(null, Buffer.from(JSON.stringify({ id: 'someId', version: '6.4.2' })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin "someId" is only compatible with Kibana version "6.4.2", but used Kibana version is "7.0.0-alpha1". (incompatible-version, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.IncompatibleVersion,
path: pluginManifestPath,
Expand All @@ -147,7 +132,7 @@ test('return error when plugin expected Kibana version cannot be interpreted as
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin "someId" is only compatible with Kibana version "non-sem-ver", but used Kibana version is "7.0.0-alpha1". (incompatible-version, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.IncompatibleVersion,
path: pluginManifestPath,
Expand All @@ -159,7 +144,7 @@ test('return error when plugin config path is not a string', async () => {
cb(null, Buffer.from(JSON.stringify({ id: 'someId', version: '7.0.0', configPath: 2 })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `The "configPath" in plugin manifest for "someId" should either be a string or an array of strings. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -174,7 +159,7 @@ test('return error when plugin config path is an array that contains non-string
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `The "configPath" in plugin manifest for "someId" should either be a string or an array of strings. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -186,7 +171,7 @@ test('return error when plugin expected Kibana version is higher than actual ver
cb(null, Buffer.from(JSON.stringify({ id: 'someId', version: '7.0.1' })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Plugin "someId" is only compatible with Kibana version "7.0.1", but used Kibana version is "7.0.0-alpha1". (incompatible-version, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.IncompatibleVersion,
path: pluginManifestPath,
Expand All @@ -198,7 +183,7 @@ test('return error when both `server` and `ui` are set to `false` or missing', a
cb(null, Buffer.from(JSON.stringify({ id: 'someId', version: '7.0.0' })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Both "server" and "ui" are missing or set to "false" in plugin manifest for "someId", but at least one of these must be set to "true". (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -211,7 +196,7 @@ test('return error when both `server` and `ui` are set to `false` or missing', a
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Both "server" and "ui" are missing or set to "false" in plugin manifest for "someId", but at least one of these must be set to "true". (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -234,7 +219,7 @@ test('return error when manifest contains unrecognized properties', async () =>
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).rejects.toMatchObject({
await expect(parseManifest(pluginPath, packageInfo)).rejects.toMatchObject({
message: `Manifest for plugin "someId" contains the following unrecognized properties: unknownOne,unknownTwo. (invalid-manifest, ${pluginManifestPath})`,
type: PluginDiscoveryErrorType.InvalidManifest,
path: pluginManifestPath,
Expand All @@ -247,20 +232,20 @@ describe('configPath', () => {
cb(null, Buffer.from(JSON.stringify({ id: 'plugin', version: '7.0.0', server: true })));
});

const manifest = await parseManifest(pluginPath, packageInfo, logger);
const manifest = await parseManifest(pluginPath, packageInfo);
expect(manifest.configPath).toBe(manifest.id);
});

test('falls back to plugin id in snakeCase format', async () => {
mockReadFile.mockImplementation((path, cb) => {
cb(null, Buffer.from(JSON.stringify({ id: 'SomeId', version: '7.0.0', server: true })));
cb(null, Buffer.from(JSON.stringify({ id: 'someId', version: '7.0.0', server: true })));
});

const manifest = await parseManifest(pluginPath, packageInfo, logger);
const manifest = await parseManifest(pluginPath, packageInfo);
expect(manifest.configPath).toBe('some_id');
});

test('not formated to snakeCase if defined explicitly as string', async () => {
test('not formatted to snakeCase if defined explicitly as string', async () => {
mockReadFile.mockImplementation((path, cb) => {
cb(
null,
Expand All @@ -270,11 +255,11 @@ describe('configPath', () => {
);
});

const manifest = await parseManifest(pluginPath, packageInfo, logger);
const manifest = await parseManifest(pluginPath, packageInfo);
expect(manifest.configPath).toBe('somePath');
});

test('not formated to snakeCase if defined explicitly as an array of strings', async () => {
test('not formatted to snakeCase if defined explicitly as an array of strings', async () => {
mockReadFile.mockImplementation((path, cb) => {
cb(
null,
Expand All @@ -284,7 +269,7 @@ describe('configPath', () => {
);
});

const manifest = await parseManifest(pluginPath, packageInfo, logger);
const manifest = await parseManifest(pluginPath, packageInfo);
expect(manifest.configPath).toEqual(['somePath']);
});
});
Expand All @@ -294,7 +279,7 @@ test('set defaults for all missing optional fields', async () => {
cb(null, Buffer.from(JSON.stringify({ id: 'someId', version: '7.0.0', server: true })));
});

await expect(parseManifest(pluginPath, packageInfo, logger)).resolves.toEqual({
await expect(parseManifest(pluginPath, packageInfo)).resolves.toEqual({
id: 'someId',
configPath: 'some_id',
version: '7.0.0',
Expand Down Expand Up @@ -325,7 +310,7 @@ test('return all set optional fields as they are in manifest', async () => {
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).resolves.toEqual({
await expect(parseManifest(pluginPath, packageInfo)).resolves.toEqual({
id: 'someId',
configPath: ['some', 'path'],
version: 'some-version',
Expand Down Expand Up @@ -355,7 +340,7 @@ test('return manifest when plugin expected Kibana version matches actual version
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).resolves.toEqual({
await expect(parseManifest(pluginPath, packageInfo)).resolves.toEqual({
id: 'someId',
configPath: 'some-path',
version: 'some-version',
Expand Down Expand Up @@ -385,7 +370,7 @@ test('return manifest when plugin expected Kibana version is `kibana`', async ()
);
});

await expect(parseManifest(pluginPath, packageInfo, logger)).resolves.toEqual({
await expect(parseManifest(pluginPath, packageInfo)).resolves.toEqual({
id: 'someId',
configPath: 'some_id',
version: 'some-version',
Expand Down
11 changes: 6 additions & 5 deletions src/core/server/plugins/discovery/plugin_manifest_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { coerce } from 'semver';
import { promisify } from 'util';
import { snakeCase } from 'lodash';
import { isConfigPath, PackageInfo } from '../../config';
import { Logger } from '../../logging';
import { PluginManifest } from '../types';
import { PluginDiscoveryError } from './plugin_discovery_error';
import { isCamelCase } from './is_camel_case';
Expand Down Expand Up @@ -63,8 +62,7 @@ const KNOWN_MANIFEST_FIELDS = (() => {
*/
export async function parseManifest(
pluginPath: string,
packageInfo: PackageInfo,
log: Logger
packageInfo: PackageInfo
): Promise<PluginManifest> {
const manifestPath = resolve(pluginPath, MANIFEST_FILE_NAME);

Expand Down Expand Up @@ -105,8 +103,11 @@ export async function parseManifest(
);
}

if (!packageInfo.dist && !isCamelCase(manifest.id)) {
log.warn(`Expect plugin "id" in camelCase, but found: ${manifest.id}`);
if (!isCamelCase(manifest.id)) {
throw PluginDiscoveryError.invalidManifest(
manifestPath,
new Error(`Plugin "id" must be camelCase, but found: ${manifest.id}.`)
);
}

if (!manifest.version || typeof manifest.version !== 'string') {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/plugins/discovery/plugins_discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function createPlugin$(
coreContext: CoreContext,
instanceInfo: InstanceInfo
) {
return from(parseManifest(path, coreContext.env.packageInfo, log)).pipe(
return from(parseManifest(path, coreContext.env.packageInfo)).pipe(
map((manifest) => {
log.debug(`Successfully discovered plugin "${manifest.id}" at "${path}"`);
const opaqueId = Symbol(manifest.id);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/apm_oss/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const config = {
sourcemapIndices: schema.string({ defaultValue: 'apm-*' }),
onboardingIndices: schema.string({ defaultValue: 'apm-*' }),
indexPattern: schema.string({ defaultValue: 'apm-*' }),
fleetMode: schema.boolean({ defaultValue: true }),
}),
};

Expand Down
Loading

0 comments on commit 84e67e7

Please sign in to comment.